pax_global_header00006660000000000000000000000064132174645310014520gustar00rootroot0000000000000052 comment=f557edc7e1e893fd1f51f922fbc53e61d6db1896 freshplayerplugin-0.3.9/000077500000000000000000000000001321746453100152745ustar00rootroot00000000000000freshplayerplugin-0.3.9/.editorconfig000066400000000000000000000001361321746453100177510ustar00rootroot00000000000000root = true [**] end_of_line = lf indent_size = 4 indent_style = space max_line_length = 100 freshplayerplugin-0.3.9/.gitignore000066400000000000000000000000071321746453100172610ustar00rootroot00000000000000/build freshplayerplugin-0.3.9/3rdparty/000077500000000000000000000000001321746453100170445ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/CMakeLists.txt000066400000000000000000000001211321746453100215760ustar00rootroot00000000000000add_subdirectory(parson) if (NOT WITH_GLES2) add_subdirectory(angle) endif() freshplayerplugin-0.3.9/3rdparty/angle/000077500000000000000000000000001321746453100201325ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/angle/AUTHORS000066400000000000000000000015451321746453100212070ustar00rootroot00000000000000# This is the official list of The ANGLE Project Authors # for copyright purposes. # This file is distinct from the CONTRIBUTORS files. # See the latter for an explanation. # Names should be added to this file as # Name or Organization # Email addresses for individuals are tracked elsewhere to avoid spam. Google Inc. TransGaming Inc. 3DLabs Inc. Ltd. Adobe Systems Inc. Autodesk, Inc. BlackBerry Limited Cable Television Laboratories, Inc. Cloud Party, Inc. Imagination Technologies Ltd. Intel Corporation Mozilla Corporation Turbulenz Klarälvdalens Datakonsult AB Microsoft Corporation Microsoft Open Technologies, Inc. NVIDIA Corporation Opera Software ASA The Qt Company Ltd. Jacek Caban Mark Callow Ginn Chen Tibor den Ouden Régis Fénéon James Hauxwell Sam Hocevar Pierre Leveille Jonathan Liu Boying Lu Aitor Moreno Yuri O'Donnell Josh Soref Maks Naumov freshplayerplugin-0.3.9/3rdparty/angle/CMakeLists.txt000066400000000000000000000050601321746453100226730ustar00rootroot00000000000000include_directories(include) include_directories(src) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") add_library(shader_translator STATIC src/common/Float16ToFloat32.cpp src/common/tls.cpp src/common/utilities.cpp src/compiler/preprocessor/DiagnosticsBase.cpp src/compiler/preprocessor/DirectiveHandlerBase.cpp src/compiler/preprocessor/DirectiveParser.cpp src/compiler/preprocessor/ExpressionParser.cpp src/compiler/preprocessor/Input.cpp src/compiler/preprocessor/Lexer.cpp src/compiler/preprocessor/Macro.cpp src/compiler/preprocessor/MacroExpander.cpp src/compiler/preprocessor/Preprocessor.cpp src/compiler/preprocessor/Token.cpp src/compiler/preprocessor/Tokenizer.cpp src/compiler/translator/BuiltInFunctionEmulator.cpp src/compiler/translator/BuiltInFunctionEmulatorGLSL.cpp src/compiler/translator/Cache.cpp src/compiler/translator/CallDAG.cpp src/compiler/translator/CodeGen.cpp src/compiler/translator/Compiler.cpp src/compiler/translator/Diagnostics.cpp src/compiler/translator/DirectiveHandler.cpp src/compiler/translator/EmulatePrecision.cpp src/compiler/translator/glslang_lex.cpp src/compiler/translator/glslang_tab.cpp src/compiler/translator/InfoSink.cpp src/compiler/translator/Initialize.cpp src/compiler/translator/InitializeDll.cpp src/compiler/translator/InitializeParseContext.cpp src/compiler/translator/Intermediate.cpp src/compiler/translator/intermOut.cpp src/compiler/translator/IntermNode.cpp src/compiler/translator/IntermTraverse.cpp src/compiler/translator/LoopInfo.cpp src/compiler/translator/Operator.cpp src/compiler/translator/OutputGLSLBase.cpp src/compiler/translator/OutputGLSL.cpp src/compiler/translator/parseConst.cpp src/compiler/translator/ParseContext.cpp src/compiler/translator/PoolAlloc.cpp src/compiler/translator/PruneEmptyDeclarations.cpp src/compiler/translator/RecordConstantPrecision.cpp src/compiler/translator/ShaderLang.cpp src/compiler/translator/SymbolTable.cpp src/compiler/translator/TranslatorGLSL.cpp src/compiler/translator/Types.cpp src/compiler/translator/util.cpp src/compiler/translator/ValidateGlobalInitializer.cpp src/compiler/translator/ValidateOutputs.cpp src/compiler/translator/ValidateSwitch.cpp src/compiler/translator/VersionGLSL.cpp ) add_executable(st samples/shader_translator/shader_translator.cpp) target_link_libraries(st shader_translator) freshplayerplugin-0.3.9/3rdparty/angle/CONTRIBUTORS000066400000000000000000000032401321746453100220110ustar00rootroot00000000000000# This is the official list of people who can contribute # (and who have contributed) code to the ANGLE project # repository. # The AUTHORS file lists the copyright holders; this file # lists people. For example, Google employees are listed here # but not in AUTHORS, because Google holds the copyright. # TransGaming Inc. Nicolas Capens Daniel Koch Geoff Lang Andrew Lewycky Jamie Madill Gavriel State Shannon Woods Google Inc. Brent Austin Michael Bai John Bauman Peter Beverloo Steve Block Rachel Blum Eric Boren Henry Bridge Nat Duca Peter Kasting Vangelis Kokkevis Zhenyao Mo Daniel Nicoara Alastair Patrick Alok Priyadarshi Kenneth Russell Brian Salomon Gregg Tavares Jeff Timanus Ben Vanik Adrienne Walker thestig@chromium.org Justin Schuh Scott Graham Corentin Wallez Adobe Systems Inc. Alexandru Chiculita Steve Minns Max Vujovic Autodesk, Inc. Ranger Harke Cloud Party, Inc. Conor Dickinson The Qt Company Ltd. Andrew Knight Imagination Technologies Ltd. Gregoire Payen de La Garanderie Intel Corporation Jin Yang Andy Chen Josh Triplett Sudarsana Nagineni Klarälvdalens Datakonsult AB Milian Wolff Mozilla Corp. Ehsan Akhgari Jeff Gilbert Mike Hommey Benoit Jacob Makoto Kato Vladimir Vukicevic Turbulenz Michael Braithwaite Ulrik Persson (ddefrostt) Mark Banner (standard8mbp) David Kilzer Jacek Caban Tibor den Ouden Régis Fénéon Microsoft Corporation Cooper Partin Austin Kinross Minmin Gong Shawn Hargreaves Microsoft Open Technologies, Inc. Cooper Partin Austin Kinross NVIDIA Corporation Olli Etuaho Arun Patole Qingqing Deng Kimmo Kinnunen Opera Software ASA Daniel Bratell Tomasz Moniuszko freshplayerplugin-0.3.9/3rdparty/angle/LICENSE000066400000000000000000000031671321746453100211460ustar00rootroot00000000000000// Copyright (C) 2002-2013 The ANGLE Project Authors. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // // Neither the name of TransGaming Inc., Google Inc., 3DLabs Inc. // Ltd., nor the names of their contributors may be used to endorse // or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. freshplayerplugin-0.3.9/3rdparty/angle/README.chromium000066400000000000000000000003561321746453100226400ustar00rootroot00000000000000Name: ANGLE URL: https://code.google.com/p/angleproject/ Version: 2422 License: BSD License File: LICENSE Description: ANGLE is a conformant implementation of the OpenGL ES 2.0 specification that is hardware‐accelerated via Direct3D. freshplayerplugin-0.3.9/3rdparty/angle/README.md000066400000000000000000000050501321746453100214110ustar00rootroot00000000000000#ANGLE The goal of ANGLE is to allow Windows users to seamlessly run WebGL and other OpenGL ES content by translating OpenGL ES API calls to DirectX 9 or DirectX 11 API calls. ANGLE is a conformant implementation of the OpenGL ES 2.0 specification that is hardware‐accelerated via Direct3D. ANGLE v1.0.772 was certified compliant by passing the ES 2.0.3 conformance tests in October 2011. ANGLE also provides an implementation of the EGL 1.4 specification. Work on ANGLE's OpenGL ES 3.0 implementation is currently in progress, but should not be considered stable. ANGLE is used as the default WebGL backend for both Google Chrome and Mozilla Firefox on Windows platforms. Chrome uses ANGLE for all graphics rendering on Windows, including the accelerated Canvas2D implementation and the Native Client sandbox environment. Portions of the ANGLE shader compiler are used as a shader validator and translator by WebGL implementations across multiple platforms. It is used on Mac OS X, Linux, and in mobile variants of the browsers. Having one shader validator helps to ensure that a consistent set of GLSL ES shaders are accepted across browsers and platforms. The shader translator can be used to translate shaders to other shading languages, and to optionally apply shader modifications to work around bugs or quirks in the native graphics drivers. The translator targets Desktop GLSL, Direct3D HLSL, and even ESSL for native GLES2 platforms. ##Building View the [Dev setup instructions](doc/DevSetup.md). ##Contributing * Join our [Google group](https://groups.google.com/group/angleproject) to keep up to date. * Join us on IRC in the #ANGLEproject channel on FreeNode. * Read about ANGLE development in our [documentation](doc). * Become a [code contributor](doc/ContributingCode.md). * File bugs in the [issue tracker](http://code.google.com/p/angleproject/issues/list) (preferably with an isolated test-case). * Read about WebGL on the [Khronos WebGL Wiki](http://khronos.org/webgl/wiki/Main_Page). * Learn about implementation details in the [OpenGL Insights chapter on ANGLE](http://www.seas.upenn.edu/~pcozzi/OpenGLInsights/OpenGLInsights-ANGLE.pdf) and this [ANGLE presentation](https://code.google.com/p/angleproject/downloads/detail?name=ANGLE%20and%20Cross-Platform%20WebGL%20Support.pdf&can=2&q=). * Learn about the past, present, and future of the ANGLE implementation in [this recent presentation](https://docs.google.com/presentation/d/1CucIsdGVDmdTWRUbg68IxLE5jXwCb2y1E9YVhQo0thg/pub?start=false&loop=false). * If you use ANGLE in your own project, we'd love to hear about it!freshplayerplugin-0.3.9/3rdparty/angle/include/000077500000000000000000000000001321746453100215555ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/angle/include/EGL/000077500000000000000000000000001321746453100221645ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/angle/include/EGL/egl.h000066400000000000000000000357011321746453100231120ustar00rootroot00000000000000#ifndef __egl_h_ #define __egl_h_ 1 #ifdef __cplusplus extern "C" { #endif /* ** Copyright (c) 2013-2014 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including ** without limitation the rights to use, copy, modify, merge, publish, ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are 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 Materials. ** ** THE MATERIALS ARE 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 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ /* ** This header is generated from the Khronos OpenGL / OpenGL ES XML ** API Registry. The current version of the Registry, generator scripts ** used to make the header, and the header can be found at ** http://www.opengl.org/registry/ ** ** Khronos $Revision: 29318 $ on $Date: 2015-01-02 03:16:10 -0800 (Fri, 02 Jan 2015) $ */ #include /* Generated on date 20150102 */ /* Generated C header for: * API: egl * Versions considered: .* * Versions emitted: .* * Default extensions included: None * Additional extensions included: _nomatch_^ * Extensions removed: _nomatch_^ */ #ifndef EGL_VERSION_1_0 #define EGL_VERSION_1_0 1 typedef unsigned int EGLBoolean; typedef void *EGLDisplay; #include #include typedef void *EGLConfig; typedef void *EGLSurface; typedef void *EGLContext; typedef void (*__eglMustCastToProperFunctionPointerType)(void); #define EGL_ALPHA_SIZE 0x3021 #define EGL_BAD_ACCESS 0x3002 #define EGL_BAD_ALLOC 0x3003 #define EGL_BAD_ATTRIBUTE 0x3004 #define EGL_BAD_CONFIG 0x3005 #define EGL_BAD_CONTEXT 0x3006 #define EGL_BAD_CURRENT_SURFACE 0x3007 #define EGL_BAD_DISPLAY 0x3008 #define EGL_BAD_MATCH 0x3009 #define EGL_BAD_NATIVE_PIXMAP 0x300A #define EGL_BAD_NATIVE_WINDOW 0x300B #define EGL_BAD_PARAMETER 0x300C #define EGL_BAD_SURFACE 0x300D #define EGL_BLUE_SIZE 0x3022 #define EGL_BUFFER_SIZE 0x3020 #define EGL_CONFIG_CAVEAT 0x3027 #define EGL_CONFIG_ID 0x3028 #define EGL_CORE_NATIVE_ENGINE 0x305B #define EGL_DEPTH_SIZE 0x3025 #define EGL_DONT_CARE ((EGLint)-1) #define EGL_DRAW 0x3059 #define EGL_EXTENSIONS 0x3055 #define EGL_FALSE 0 #define EGL_GREEN_SIZE 0x3023 #define EGL_HEIGHT 0x3056 #define EGL_LARGEST_PBUFFER 0x3058 #define EGL_LEVEL 0x3029 #define EGL_MAX_PBUFFER_HEIGHT 0x302A #define EGL_MAX_PBUFFER_PIXELS 0x302B #define EGL_MAX_PBUFFER_WIDTH 0x302C #define EGL_NATIVE_RENDERABLE 0x302D #define EGL_NATIVE_VISUAL_ID 0x302E #define EGL_NATIVE_VISUAL_TYPE 0x302F #define EGL_NONE 0x3038 #define EGL_NON_CONFORMANT_CONFIG 0x3051 #define EGL_NOT_INITIALIZED 0x3001 #define EGL_NO_CONTEXT ((EGLContext)0) #define EGL_NO_DISPLAY ((EGLDisplay)0) #define EGL_NO_SURFACE ((EGLSurface)0) #define EGL_PBUFFER_BIT 0x0001 #define EGL_PIXMAP_BIT 0x0002 #define EGL_READ 0x305A #define EGL_RED_SIZE 0x3024 #define EGL_SAMPLES 0x3031 #define EGL_SAMPLE_BUFFERS 0x3032 #define EGL_SLOW_CONFIG 0x3050 #define EGL_STENCIL_SIZE 0x3026 #define EGL_SUCCESS 0x3000 #define EGL_SURFACE_TYPE 0x3033 #define EGL_TRANSPARENT_BLUE_VALUE 0x3035 #define EGL_TRANSPARENT_GREEN_VALUE 0x3036 #define EGL_TRANSPARENT_RED_VALUE 0x3037 #define EGL_TRANSPARENT_RGB 0x3052 #define EGL_TRANSPARENT_TYPE 0x3034 #define EGL_TRUE 1 #define EGL_VENDOR 0x3053 #define EGL_VERSION 0x3054 #define EGL_WIDTH 0x3057 #define EGL_WINDOW_BIT 0x0004 EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); EGLAPI EGLContext EGLAPIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list); EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx); EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface); EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay (void); EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface (EGLint readdraw); EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay (EGLNativeDisplayType display_id); EGLAPI EGLint EGLAPIENTRY eglGetError (void); EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress (const char *procname); EGLAPI EGLBoolean EGLAPIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor); EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); EGLAPI const char *EGLAPIENTRY eglQueryString (EGLDisplay dpy, EGLint name); EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface surface); EGLAPI EGLBoolean EGLAPIENTRY eglTerminate (EGLDisplay dpy); EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL (void); EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative (EGLint engine); #endif /* EGL_VERSION_1_0 */ #ifndef EGL_VERSION_1_1 #define EGL_VERSION_1_1 1 #define EGL_BACK_BUFFER 0x3084 #define EGL_BIND_TO_TEXTURE_RGB 0x3039 #define EGL_BIND_TO_TEXTURE_RGBA 0x303A #define EGL_CONTEXT_LOST 0x300E #define EGL_MIN_SWAP_INTERVAL 0x303B #define EGL_MAX_SWAP_INTERVAL 0x303C #define EGL_MIPMAP_TEXTURE 0x3082 #define EGL_MIPMAP_LEVEL 0x3083 #define EGL_NO_TEXTURE 0x305C #define EGL_TEXTURE_2D 0x305F #define EGL_TEXTURE_FORMAT 0x3080 #define EGL_TEXTURE_RGB 0x305D #define EGL_TEXTURE_RGBA 0x305E #define EGL_TEXTURE_TARGET 0x3081 EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval (EGLDisplay dpy, EGLint interval); #endif /* EGL_VERSION_1_1 */ #ifndef EGL_VERSION_1_2 #define EGL_VERSION_1_2 1 typedef unsigned int EGLenum; typedef void *EGLClientBuffer; #define EGL_ALPHA_FORMAT 0x3088 #define EGL_ALPHA_FORMAT_NONPRE 0x308B #define EGL_ALPHA_FORMAT_PRE 0x308C #define EGL_ALPHA_MASK_SIZE 0x303E #define EGL_BUFFER_PRESERVED 0x3094 #define EGL_BUFFER_DESTROYED 0x3095 #define EGL_CLIENT_APIS 0x308D #define EGL_COLORSPACE 0x3087 #define EGL_COLORSPACE_sRGB 0x3089 #define EGL_COLORSPACE_LINEAR 0x308A #define EGL_COLOR_BUFFER_TYPE 0x303F #define EGL_CONTEXT_CLIENT_TYPE 0x3097 #define EGL_DISPLAY_SCALING 10000 #define EGL_HORIZONTAL_RESOLUTION 0x3090 #define EGL_LUMINANCE_BUFFER 0x308F #define EGL_LUMINANCE_SIZE 0x303D #define EGL_OPENGL_ES_BIT 0x0001 #define EGL_OPENVG_BIT 0x0002 #define EGL_OPENGL_ES_API 0x30A0 #define EGL_OPENVG_API 0x30A1 #define EGL_OPENVG_IMAGE 0x3096 #define EGL_PIXEL_ASPECT_RATIO 0x3092 #define EGL_RENDERABLE_TYPE 0x3040 #define EGL_RENDER_BUFFER 0x3086 #define EGL_RGB_BUFFER 0x308E #define EGL_SINGLE_BUFFER 0x3085 #define EGL_SWAP_BEHAVIOR 0x3093 #define EGL_UNKNOWN ((EGLint)-1) #define EGL_VERTICAL_RESOLUTION 0x3091 EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI (EGLenum api); EGLAPI EGLenum EGLAPIENTRY eglQueryAPI (void); EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread (void); EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void); #endif /* EGL_VERSION_1_2 */ #ifndef EGL_VERSION_1_3 #define EGL_VERSION_1_3 1 #define EGL_CONFORMANT 0x3042 #define EGL_CONTEXT_CLIENT_VERSION 0x3098 #define EGL_MATCH_NATIVE_PIXMAP 0x3041 #define EGL_OPENGL_ES2_BIT 0x0004 #define EGL_VG_ALPHA_FORMAT 0x3088 #define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B #define EGL_VG_ALPHA_FORMAT_PRE 0x308C #define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 #define EGL_VG_COLORSPACE 0x3087 #define EGL_VG_COLORSPACE_sRGB 0x3089 #define EGL_VG_COLORSPACE_LINEAR 0x308A #define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 #endif /* EGL_VERSION_1_3 */ #ifndef EGL_VERSION_1_4 #define EGL_VERSION_1_4 1 #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) #define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 #define EGL_MULTISAMPLE_RESOLVE 0x3099 #define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A #define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B #define EGL_OPENGL_API 0x30A2 #define EGL_OPENGL_BIT 0x0008 #define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext (void); #endif /* EGL_VERSION_1_4 */ #ifndef EGL_VERSION_1_5 #define EGL_VERSION_1_5 1 typedef void *EGLSync; typedef intptr_t EGLAttrib; typedef khronos_utime_nanoseconds_t EGLTime; typedef void *EGLImage; #define EGL_CONTEXT_MAJOR_VERSION 0x3098 #define EGL_CONTEXT_MINOR_VERSION 0x30FB #define EGL_CONTEXT_OPENGL_PROFILE_MASK 0x30FD #define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD #define EGL_NO_RESET_NOTIFICATION 0x31BE #define EGL_LOSE_CONTEXT_ON_RESET 0x31BF #define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001 #define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT 0x00000002 #define EGL_CONTEXT_OPENGL_DEBUG 0x31B0 #define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1 #define EGL_CONTEXT_OPENGL_ROBUST_ACCESS 0x31B2 #define EGL_OPENGL_ES3_BIT 0x00000040 #define EGL_CL_EVENT_HANDLE 0x309C #define EGL_SYNC_CL_EVENT 0x30FE #define EGL_SYNC_CL_EVENT_COMPLETE 0x30FF #define EGL_SYNC_PRIOR_COMMANDS_COMPLETE 0x30F0 #define EGL_SYNC_TYPE 0x30F7 #define EGL_SYNC_STATUS 0x30F1 #define EGL_SYNC_CONDITION 0x30F8 #define EGL_SIGNALED 0x30F2 #define EGL_UNSIGNALED 0x30F3 #define EGL_SYNC_FLUSH_COMMANDS_BIT 0x0001 #define EGL_FOREVER 0xFFFFFFFFFFFFFFFFull #define EGL_TIMEOUT_EXPIRED 0x30F5 #define EGL_CONDITION_SATISFIED 0x30F6 #define EGL_NO_SYNC ((EGLSync)0) #define EGL_SYNC_FENCE 0x30F9 #define EGL_GL_COLORSPACE 0x309D #define EGL_GL_COLORSPACE_SRGB 0x3089 #define EGL_GL_COLORSPACE_LINEAR 0x308A #define EGL_GL_RENDERBUFFER 0x30B9 #define EGL_GL_TEXTURE_2D 0x30B1 #define EGL_GL_TEXTURE_LEVEL 0x30BC #define EGL_GL_TEXTURE_3D 0x30B2 #define EGL_GL_TEXTURE_ZOFFSET 0x30BD #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3 #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4 #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5 #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6 #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7 #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8 #define EGL_IMAGE_PRESERVED 0x30D2 #define EGL_NO_IMAGE ((EGLImage)0) EGLAPI EGLSync EGLAPIENTRY eglCreateSync (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglDestroySync (EGLDisplay dpy, EGLSync sync); EGLAPI EGLint EGLAPIENTRY eglClientWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout); EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttrib (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value); EGLAPI EGLImage EGLAPIENTRY eglCreateImage (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImage (EGLDisplay dpy, EGLImage image); EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplay (EGLenum platform, void *native_display, const EGLAttrib *attrib_list); EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurface (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list); EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurface (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags); #endif /* EGL_VERSION_1_5 */ #ifdef __cplusplus } #endif #endif freshplayerplugin-0.3.9/3rdparty/angle/include/EGL/eglext.h000066400000000000000000001053221321746453100236300ustar00rootroot00000000000000#ifndef __eglext_h_ #define __eglext_h_ 1 #ifdef __cplusplus extern "C" { #endif /* ** Copyright (c) 2013-2014 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including ** without limitation the rights to use, copy, modify, merge, publish, ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are 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 Materials. ** ** THE MATERIALS ARE 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 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ /* ** This header is generated from the Khronos OpenGL / OpenGL ES XML ** API Registry. The current version of the Registry, generator scripts ** used to make the header, and the header can be found at ** http://www.opengl.org/registry/ ** ** Khronos $Revision: 27018 $ on $Date: 2014-06-10 08:06:12 -0700 (Tue, 10 Jun 2014) $ */ #include #define EGL_EGLEXT_VERSION 20140610 /* Generated C header for: * API: egl * Versions considered: .* * Versions emitted: _nomatch_^ * Default extensions included: egl * Additional extensions included: _nomatch_^ * Extensions removed: _nomatch_^ */ #ifndef EGL_KHR_cl_event #define EGL_KHR_cl_event 1 #define EGL_CL_EVENT_HANDLE_KHR 0x309C #define EGL_SYNC_CL_EVENT_KHR 0x30FE #define EGL_SYNC_CL_EVENT_COMPLETE_KHR 0x30FF #endif /* EGL_KHR_cl_event */ #ifndef EGL_KHR_cl_event2 #define EGL_KHR_cl_event2 1 typedef void *EGLSyncKHR; typedef intptr_t EGLAttribKHR; typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNC64KHRPROC) (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync64KHR (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); #endif #endif /* EGL_KHR_cl_event2 */ #ifndef EGL_KHR_client_get_all_proc_addresses #define EGL_KHR_client_get_all_proc_addresses 1 #endif /* EGL_KHR_client_get_all_proc_addresses */ #ifndef EGL_KHR_config_attribs #define EGL_KHR_config_attribs 1 #define EGL_CONFORMANT_KHR 0x3042 #define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 #define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 #endif /* EGL_KHR_config_attribs */ #ifndef EGL_KHR_create_context #define EGL_KHR_create_context 1 #define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098 #define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB #define EGL_CONTEXT_FLAGS_KHR 0x30FC #define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD #define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD #define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE #define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF #define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 #define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 #define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 #define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 #define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 #define EGL_OPENGL_ES3_BIT_KHR 0x00000040 #endif /* EGL_KHR_create_context */ #ifndef EGL_KHR_fence_sync #define EGL_KHR_fence_sync 1 #ifdef KHRONOS_SUPPORT_INT64 #define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0 #define EGL_SYNC_CONDITION_KHR 0x30F8 #define EGL_SYNC_FENCE_KHR 0x30F9 #endif /* KHRONOS_SUPPORT_INT64 */ #endif /* EGL_KHR_fence_sync */ #ifndef EGL_KHR_get_all_proc_addresses #define EGL_KHR_get_all_proc_addresses 1 #endif /* EGL_KHR_get_all_proc_addresses */ #ifndef EGL_KHR_gl_colorspace #define EGL_KHR_gl_colorspace 1 #define EGL_GL_COLORSPACE_KHR 0x309D #define EGL_GL_COLORSPACE_SRGB_KHR 0x3089 #define EGL_GL_COLORSPACE_LINEAR_KHR 0x308A #endif /* EGL_KHR_gl_colorspace */ #ifndef EGL_KHR_gl_renderbuffer_image #define EGL_KHR_gl_renderbuffer_image 1 #define EGL_GL_RENDERBUFFER_KHR 0x30B9 #endif /* EGL_KHR_gl_renderbuffer_image */ #ifndef EGL_KHR_gl_texture_2D_image #define EGL_KHR_gl_texture_2D_image 1 #define EGL_GL_TEXTURE_2D_KHR 0x30B1 #define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC #endif /* EGL_KHR_gl_texture_2D_image */ #ifndef EGL_KHR_gl_texture_3D_image #define EGL_KHR_gl_texture_3D_image 1 #define EGL_GL_TEXTURE_3D_KHR 0x30B2 #define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD #endif /* EGL_KHR_gl_texture_3D_image */ #ifndef EGL_KHR_gl_texture_cubemap_image #define EGL_KHR_gl_texture_cubemap_image 1 #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 #endif /* EGL_KHR_gl_texture_cubemap_image */ #ifndef EGL_KHR_image #define EGL_KHR_image 1 typedef void *EGLImageKHR; #define EGL_NATIVE_PIXMAP_KHR 0x30B0 #define EGL_NO_IMAGE_KHR ((EGLImageKHR)0) typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image); #endif #endif /* EGL_KHR_image */ #ifndef EGL_KHR_image_base #define EGL_KHR_image_base 1 #define EGL_IMAGE_PRESERVED_KHR 0x30D2 #endif /* EGL_KHR_image_base */ #ifndef EGL_KHR_image_pixmap #define EGL_KHR_image_pixmap 1 #endif /* EGL_KHR_image_pixmap */ #ifndef EGL_KHR_lock_surface #define EGL_KHR_lock_surface 1 #define EGL_READ_SURFACE_BIT_KHR 0x0001 #define EGL_WRITE_SURFACE_BIT_KHR 0x0002 #define EGL_LOCK_SURFACE_BIT_KHR 0x0080 #define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 #define EGL_MATCH_FORMAT_KHR 0x3043 #define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 #define EGL_FORMAT_RGB_565_KHR 0x30C1 #define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 #define EGL_FORMAT_RGBA_8888_KHR 0x30C3 #define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 #define EGL_LOCK_USAGE_HINT_KHR 0x30C5 #define EGL_BITMAP_POINTER_KHR 0x30C6 #define EGL_BITMAP_PITCH_KHR 0x30C7 #define EGL_BITMAP_ORIGIN_KHR 0x30C8 #define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 #define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA #define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB #define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC #define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD #define EGL_LOWER_LEFT_KHR 0x30CE #define EGL_UPPER_LEFT_KHR 0x30CF typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay dpy, EGLSurface surface); #endif #endif /* EGL_KHR_lock_surface */ #ifndef EGL_KHR_lock_surface2 #define EGL_KHR_lock_surface2 1 #define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110 #endif /* EGL_KHR_lock_surface2 */ #ifndef EGL_KHR_lock_surface3 #define EGL_KHR_lock_surface3 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACE64KHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface64KHR (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); #endif #endif /* EGL_KHR_lock_surface3 */ #ifndef EGL_KHR_platform_android #define EGL_KHR_platform_android 1 #define EGL_PLATFORM_ANDROID_KHR 0x3141 #endif /* EGL_KHR_platform_android */ #ifndef EGL_KHR_platform_gbm #define EGL_KHR_platform_gbm 1 #define EGL_PLATFORM_GBM_KHR 0x31D7 #endif /* EGL_KHR_platform_gbm */ #ifndef EGL_KHR_platform_wayland #define EGL_KHR_platform_wayland 1 #define EGL_PLATFORM_WAYLAND_KHR 0x31D8 #endif /* EGL_KHR_platform_wayland */ #ifndef EGL_KHR_platform_x11 #define EGL_KHR_platform_x11 1 #define EGL_PLATFORM_X11_KHR 0x31D5 #define EGL_PLATFORM_X11_SCREEN_KHR 0x31D6 #endif /* EGL_KHR_platform_x11 */ #ifndef EGL_KHR_reusable_sync #define EGL_KHR_reusable_sync 1 typedef khronos_utime_nanoseconds_t EGLTimeKHR; #ifdef KHRONOS_SUPPORT_INT64 #define EGL_SYNC_STATUS_KHR 0x30F1 #define EGL_SIGNALED_KHR 0x30F2 #define EGL_UNSIGNALED_KHR 0x30F3 #define EGL_TIMEOUT_EXPIRED_KHR 0x30F5 #define EGL_CONDITION_SATISFIED_KHR 0x30F6 #define EGL_SYNC_TYPE_KHR 0x30F7 #define EGL_SYNC_REUSABLE_KHR 0x30FA #define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 #define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull #define EGL_NO_SYNC_KHR ((EGLSyncKHR)0) typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync); typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR (EGLDisplay dpy, EGLSyncKHR sync); EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); #endif #endif /* KHRONOS_SUPPORT_INT64 */ #endif /* EGL_KHR_reusable_sync */ #ifndef EGL_KHR_stream #define EGL_KHR_stream 1 typedef void *EGLStreamKHR; typedef khronos_uint64_t EGLuint64KHR; #ifdef KHRONOS_SUPPORT_INT64 #define EGL_NO_STREAM_KHR ((EGLStreamKHR)0) #define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210 #define EGL_PRODUCER_FRAME_KHR 0x3212 #define EGL_CONSUMER_FRAME_KHR 0x3213 #define EGL_STREAM_STATE_KHR 0x3214 #define EGL_STREAM_STATE_CREATED_KHR 0x3215 #define EGL_STREAM_STATE_CONNECTING_KHR 0x3216 #define EGL_STREAM_STATE_EMPTY_KHR 0x3217 #define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218 #define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219 #define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A #define EGL_BAD_STREAM_KHR 0x321B #define EGL_BAD_STATE_KHR 0x321C typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC) (EGLDisplay dpy, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR (EGLDisplay dpy, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR (EGLDisplay dpy, EGLStreamKHR stream); EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); #endif #endif /* KHRONOS_SUPPORT_INT64 */ #endif /* EGL_KHR_stream */ #ifndef EGL_KHR_stream_consumer_gltexture #define EGL_KHR_stream_consumer_gltexture 1 #ifdef EGL_KHR_stream #define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR (EGLDisplay dpy, EGLStreamKHR stream); EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR (EGLDisplay dpy, EGLStreamKHR stream); EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR (EGLDisplay dpy, EGLStreamKHR stream); #endif #endif /* EGL_KHR_stream */ #endif /* EGL_KHR_stream_consumer_gltexture */ #ifndef EGL_KHR_stream_cross_process_fd #define EGL_KHR_stream_cross_process_fd 1 typedef int EGLNativeFileDescriptorKHR; #ifdef EGL_KHR_stream #define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1)) typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR (EGLDisplay dpy, EGLStreamKHR stream); EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); #endif #endif /* EGL_KHR_stream */ #endif /* EGL_KHR_stream_cross_process_fd */ #ifndef EGL_KHR_stream_fifo #define EGL_KHR_stream_fifo 1 #ifdef EGL_KHR_stream #define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC #define EGL_STREAM_TIME_NOW_KHR 0x31FD #define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE #define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); #endif #endif /* EGL_KHR_stream */ #endif /* EGL_KHR_stream_fifo */ #ifndef EGL_KHR_stream_producer_aldatalocator #define EGL_KHR_stream_producer_aldatalocator 1 #ifdef EGL_KHR_stream #endif /* EGL_KHR_stream */ #endif /* EGL_KHR_stream_producer_aldatalocator */ #ifndef EGL_KHR_stream_producer_eglsurface #define EGL_KHR_stream_producer_eglsurface 1 #ifdef EGL_KHR_stream #define EGL_STREAM_BIT_KHR 0x0800 typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC) (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); #endif #endif /* EGL_KHR_stream */ #endif /* EGL_KHR_stream_producer_eglsurface */ #ifndef EGL_KHR_surfaceless_context #define EGL_KHR_surfaceless_context 1 #endif /* EGL_KHR_surfaceless_context */ #ifndef EGL_KHR_vg_parent_image #define EGL_KHR_vg_parent_image 1 #define EGL_VG_PARENT_IMAGE_KHR 0x30BA #endif /* EGL_KHR_vg_parent_image */ #ifndef EGL_KHR_wait_sync #define EGL_KHR_wait_sync 1 typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); #endif #endif /* EGL_KHR_wait_sync */ #ifndef EGL_ANDROID_blob_cache #define EGL_ANDROID_blob_cache 1 typedef khronos_ssize_t EGLsizeiANDROID; typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize); typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize); typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC) (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); #endif #endif /* EGL_ANDROID_blob_cache */ #ifndef EGL_ANDROID_framebuffer_target #define EGL_ANDROID_framebuffer_target 1 #define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147 #endif /* EGL_ANDROID_framebuffer_target */ #ifndef EGL_ANDROID_image_native_buffer #define EGL_ANDROID_image_native_buffer 1 #define EGL_NATIVE_BUFFER_ANDROID 0x3140 #endif /* EGL_ANDROID_image_native_buffer */ #ifndef EGL_ANDROID_native_fence_sync #define EGL_ANDROID_native_fence_sync 1 #define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 #define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145 #define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146 #define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy, EGLSyncKHR sync); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID (EGLDisplay dpy, EGLSyncKHR sync); #endif #endif /* EGL_ANDROID_native_fence_sync */ #ifndef EGL_ANDROID_recordable #define EGL_ANDROID_recordable 1 #define EGL_RECORDABLE_ANDROID 0x3142 #endif /* EGL_ANDROID_recordable */ #ifndef EGL_ANGLE_d3d_share_handle_client_buffer #define EGL_ANGLE_d3d_share_handle_client_buffer 1 #define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200 #endif /* EGL_ANGLE_d3d_share_handle_client_buffer */ #ifndef EGL_ANGLE_window_fixed_size #define EGL_ANGLE_window_fixed_size 1 #define EGL_FIXED_SIZE_ANGLE 0x3201 #endif /* EGL_ANGLE_window_fixed_size */ #ifndef EGL_ANGLE_query_surface_pointer #define EGL_ANGLE_query_surface_pointer 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); #endif #endif /* EGL_ANGLE_query_surface_pointer */ #ifndef EGL_ANGLE_software_display #define EGL_ANGLE_software_display 1 #define EGL_SOFTWARE_DISPLAY_ANGLE ((EGLNativeDisplayType)-1) #endif /* EGL_ANGLE_software_display */ #ifndef EGL_ANGLE_direct3d_display #define EGL_ANGLE_direct3d_display 1 #define EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ((EGLNativeDisplayType)-2) #define EGL_D3D11_ONLY_DISPLAY_ANGLE ((EGLNativeDisplayType)-3) #endif /* EGL_ANGLE_direct3d_display */ #ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle #define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1 #endif /* EGL_ANGLE_surface_d3d_texture_2d_share_handle */ #ifndef EGL_ANGLE_platform_angle #define EGL_ANGLE_platform_angle 1 #define EGL_PLATFORM_ANGLE_ANGLE 0x3202 #define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203 #define EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE 0x3204 #define EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE 0x3205 #define EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE 0x3206 #endif /* EGL_ANGLE_platform_angle */ #ifndef EGL_ANGLE_platform_angle_d3d #define EGL_ANGLE_platform_angle_d3d 1 #define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207 #define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208 #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE 0x3209 #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE 0x320A #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE 0x320B #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_REFERENCE_ANGLE 0x320C #define EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE 0x320F #endif /* EGL_ANGLE_platform_angle_d3d */ #ifndef EGL_ANGLE_platform_angle_opengl #define EGL_ANGLE_platform_angle_opengl 1 #define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320D #define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320E #endif /* EGL_ANGLE_platform_angle_opengl */ #ifndef EGL_ANGLE_device_d3d #define EGL_ANGLE_device_d3d 1 #define EGL_D3D9_DEVICE_ANGLE 0x33A0 #define EGL_D3D11_DEVICE_ANGLE 0x33A1 #endif /* EGL_ANGLE_device_d3d */ #ifndef EGL_ANGLE_keyed_mutex #define EGL_ANGLE_keyed_mutex 1 #define EGL_DXGI_KEYED_MUTEX_ANGLE 0x33A2 #endif /* EGL_ANGLE_keyed_mutex */ #ifndef EGL_ARM_pixmap_multisample_discard #define EGL_ARM_pixmap_multisample_discard 1 #define EGL_DISCARD_SAMPLES_ARM 0x3286 #endif /* EGL_ARM_pixmap_multisample_discard */ #ifndef EGL_EXT_buffer_age #define EGL_EXT_buffer_age 1 #define EGL_BUFFER_AGE_EXT 0x313D #endif /* EGL_EXT_buffer_age */ #ifndef EGL_EXT_client_extensions #define EGL_EXT_client_extensions 1 #endif /* EGL_EXT_client_extensions */ #ifndef EGL_EXT_create_context_robustness #define EGL_EXT_create_context_robustness 1 #define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF #define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138 #define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE #define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF #endif /* EGL_EXT_create_context_robustness */ #ifndef EGL_EXT_device_base #define EGL_EXT_device_base 1 typedef void *EGLDeviceEXT; #define EGL_NO_DEVICE_EXT ((EGLDeviceEXT)(0)) #define EGL_BAD_DEVICE_EXT 0x322B #define EGL_DEVICE_EXT 0x322C typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEATTRIBEXTPROC) (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); typedef const char *(EGLAPIENTRYP PFNEGLQUERYDEVICESTRINGEXTPROC) (EGLDeviceEXT device, EGLint name); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICESEXTPROC) (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBEXTPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglQueryDeviceAttribEXT (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); EGLAPI const char *EGLAPIENTRY eglQueryDeviceStringEXT (EGLDeviceEXT device, EGLint name); EGLAPI EGLBoolean EGLAPIENTRY eglQueryDevicesEXT (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); #endif #endif /* EGL_EXT_device_base */ #ifndef EGL_EXT_device_query #define EGL_EXT_device_query 1 #endif /* EGL_EXT_device_query */ #ifndef EGL_EXT_image_dma_buf_import #define EGL_EXT_image_dma_buf_import 1 #define EGL_LINUX_DMA_BUF_EXT 0x3270 #define EGL_LINUX_DRM_FOURCC_EXT 0x3271 #define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 #define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 #define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 #define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 #define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 #define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 #define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 #define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 #define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A #define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B #define EGL_SAMPLE_RANGE_HINT_EXT 0x327C #define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D #define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E #define EGL_ITU_REC601_EXT 0x327F #define EGL_ITU_REC709_EXT 0x3280 #define EGL_ITU_REC2020_EXT 0x3281 #define EGL_YUV_FULL_RANGE_EXT 0x3282 #define EGL_YUV_NARROW_RANGE_EXT 0x3283 #define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 #define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 #endif /* EGL_EXT_image_dma_buf_import */ #ifndef EGL_EXT_multiview_window #define EGL_EXT_multiview_window 1 #define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134 #endif /* EGL_EXT_multiview_window */ #ifndef EGL_EXT_platform_base #define EGL_EXT_platform_base 1 typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list); typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT (EGLenum platform, void *native_display, const EGLint *attrib_list); EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); #endif #endif /* EGL_EXT_platform_base */ #ifndef EGL_EXT_platform_device #define EGL_EXT_platform_device 1 #define EGL_PLATFORM_DEVICE_EXT 0x313F #endif /* EGL_EXT_platform_device */ #ifndef EGL_EXT_platform_wayland #define EGL_EXT_platform_wayland 1 #define EGL_PLATFORM_WAYLAND_EXT 0x31D8 #endif /* EGL_EXT_platform_wayland */ #ifndef EGL_EXT_platform_x11 #define EGL_EXT_platform_x11 1 #define EGL_PLATFORM_X11_EXT 0x31D5 #define EGL_PLATFORM_X11_SCREEN_EXT 0x31D6 #endif /* EGL_EXT_platform_x11 */ #ifndef EGL_EXT_protected_surface #define EGL_EXT_protected_surface 1 #define EGL_PROTECTED_CONTENT_EXT 0x32C0 #endif /* EGL_EXT_protected_surface */ #ifndef EGL_EXT_swap_buffers_with_damage #define EGL_EXT_swap_buffers_with_damage 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); #endif #endif /* EGL_EXT_swap_buffers_with_damage */ #ifndef EGL_HI_clientpixmap #define EGL_HI_clientpixmap 1 struct EGLClientPixmapHI { void *pData; EGLint iWidth; EGLint iHeight; EGLint iStride; }; #define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74 typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); #endif #endif /* EGL_HI_clientpixmap */ #ifndef EGL_HI_colorformats #define EGL_HI_colorformats 1 #define EGL_COLOR_FORMAT_HI 0x8F70 #define EGL_COLOR_RGB_HI 0x8F71 #define EGL_COLOR_RGBA_HI 0x8F72 #define EGL_COLOR_ARGB_HI 0x8F73 #endif /* EGL_HI_colorformats */ #ifndef EGL_IMG_context_priority #define EGL_IMG_context_priority 1 #define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 #define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 #define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 #define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 #endif /* EGL_IMG_context_priority */ #ifndef EGL_MESA_drm_image #define EGL_MESA_drm_image 1 #define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 #define EGL_DRM_BUFFER_USE_MESA 0x31D1 #define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 #define EGL_DRM_BUFFER_MESA 0x31D3 #define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 #define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 #define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); #endif #endif /* EGL_MESA_drm_image */ #ifndef EGL_MESA_platform_gbm #define EGL_MESA_platform_gbm 1 #define EGL_PLATFORM_GBM_MESA 0x31D7 #endif /* EGL_MESA_platform_gbm */ #ifndef EGL_NOK_swap_region #define EGL_NOK_swap_region 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegionNOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); #endif #endif /* EGL_NOK_swap_region */ #ifndef EGL_NOK_swap_region2 #define EGL_NOK_swap_region2 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGION2NOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegion2NOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); #endif #endif /* EGL_NOK_swap_region2 */ #ifndef EGL_NOK_texture_from_pixmap #define EGL_NOK_texture_from_pixmap 1 #define EGL_Y_INVERTED_NOK 0x307F #endif /* EGL_NOK_texture_from_pixmap */ #ifndef EGL_NV_3dvision_surface #define EGL_NV_3dvision_surface 1 #define EGL_AUTO_STEREO_NV 0x3136 #endif /* EGL_NV_3dvision_surface */ #ifndef EGL_NV_coverage_sample #define EGL_NV_coverage_sample 1 #define EGL_COVERAGE_BUFFERS_NV 0x30E0 #define EGL_COVERAGE_SAMPLES_NV 0x30E1 #endif /* EGL_NV_coverage_sample */ #ifndef EGL_NV_coverage_sample_resolve #define EGL_NV_coverage_sample_resolve 1 #define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131 #define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132 #define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133 #endif /* EGL_NV_coverage_sample_resolve */ #ifndef EGL_NV_depth_nonlinear #define EGL_NV_depth_nonlinear 1 #define EGL_DEPTH_ENCODING_NV 0x30E2 #define EGL_DEPTH_ENCODING_NONE_NV 0 #define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 #endif /* EGL_NV_depth_nonlinear */ #ifndef EGL_NV_native_query #define EGL_NV_native_query 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC) (EGLDisplay dpy, EGLNativeDisplayType *display_id); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV (EGLDisplay dpy, EGLNativeDisplayType *display_id); EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); #endif #endif /* EGL_NV_native_query */ #ifndef EGL_NV_post_convert_rounding #define EGL_NV_post_convert_rounding 1 #endif /* EGL_NV_post_convert_rounding */ #ifndef EGL_NV_post_sub_buffer #define EGL_NV_post_sub_buffer 1 #define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); #endif #endif /* EGL_NV_post_sub_buffer */ #ifndef EGL_NV_stream_sync #define EGL_NV_stream_sync 1 #define EGL_SYNC_NEW_FRAME_NV 0x321F typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESTREAMSYNCNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateStreamSyncNV (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); #endif #endif /* EGL_NV_stream_sync */ #ifndef EGL_NV_sync #define EGL_NV_sync 1 typedef void *EGLSyncNV; typedef khronos_utime_nanoseconds_t EGLTimeNV; #ifdef KHRONOS_SUPPORT_INT64 #define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6 #define EGL_SYNC_STATUS_NV 0x30E7 #define EGL_SIGNALED_NV 0x30E8 #define EGL_UNSIGNALED_NV 0x30E9 #define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001 #define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull #define EGL_ALREADY_SIGNALED_NV 0x30EA #define EGL_TIMEOUT_EXPIRED_NV 0x30EB #define EGL_CONDITION_SATISFIED_NV 0x30EC #define EGL_SYNC_TYPE_NV 0x30ED #define EGL_SYNC_CONDITION_NV 0x30EE #define EGL_SYNC_FENCE_NV 0x30EF #define EGL_NO_SYNC_NV ((EGLSyncNV)0) typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync); typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync); typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode); typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync); EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync); EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode); EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value); #endif #endif /* KHRONOS_SUPPORT_INT64 */ #endif /* EGL_NV_sync */ #ifndef EGL_NV_system_time #define EGL_NV_system_time 1 typedef khronos_utime_nanoseconds_t EGLuint64NV; #ifdef KHRONOS_SUPPORT_INT64 typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void); typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV (void); EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void); #endif #endif /* KHRONOS_SUPPORT_INT64 */ #endif /* EGL_NV_system_time */ #ifdef __cplusplus } #endif #endif freshplayerplugin-0.3.9/3rdparty/angle/include/EGL/eglplatform.h000066400000000000000000000117711321746453100246600ustar00rootroot00000000000000#ifndef __eglplatform_h_ #define __eglplatform_h_ /* ** Copyright (c) 2007-2013 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including ** without limitation the rights to use, copy, modify, merge, publish, ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are 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 Materials. ** ** THE MATERIALS ARE 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 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ /* Platform-specific types and definitions for egl.h * $Revision: 23432 $ on $Date: 2013-10-09 00:57:24 -0700 (Wed, 09 Oct 2013) $ * * 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 "EGL" component "Registry". */ #include /* Macros used in EGL function prototype declarations. * * EGL functions should be prototyped as: * * EGLAPI return-type EGLAPIENTRY eglFunction(arguments); * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); * * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h */ #ifndef EGLAPI #define EGLAPI KHRONOS_APICALL #endif #ifndef EGLAPIENTRY #define EGLAPIENTRY KHRONOS_APIENTRY #endif #define EGLAPIENTRYP EGLAPIENTRY* /* The types NativeDisplayType, NativeWindowType, and NativePixmapType * are aliases of window-system-dependent types, such as X Display * or * Windows Device Context. They must be defined in platform-specific * code below. The EGL-prefixed versions of Native*Type are the same * types, renamed in EGL 1.3 so all types in the API start with "EGL". * * Khronos STRONGLY RECOMMENDS that you use the default definitions * provided below, since these changes affect both binary and source * portability of applications using EGL running on different EGL * implementations. */ #if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif #include typedef HDC EGLNativeDisplayType; typedef HBITMAP EGLNativePixmapType; #if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) /* Windows Desktop */ typedef HWND EGLNativeWindowType; #else /* Windows Store */ #include typedef IInspectable* EGLNativeWindowType; #endif #elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ typedef int EGLNativeDisplayType; typedef void *EGLNativeWindowType; typedef void *EGLNativePixmapType; #elif defined(__ANDROID__) || defined(ANDROID) #include struct egl_native_pixmap_t; typedef struct ANativeWindow* EGLNativeWindowType; typedef struct egl_native_pixmap_t* EGLNativePixmapType; typedef void* EGLNativeDisplayType; #elif defined(USE_OZONE) typedef intptr_t EGLNativeDisplayType; typedef intptr_t EGLNativeWindowType; typedef intptr_t EGLNativePixmapType; #elif defined(__unix__) /* X11 (tentative) */ #include #include typedef Display *EGLNativeDisplayType; typedef Pixmap EGLNativePixmapType; typedef Window EGLNativeWindowType; #elif defined(__GNUC__) && ( defined(__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__MACOS_CLASSIC__) ) // TODO(jmadill): native implementation for OSX typedef void *EGLNativeDisplayType; typedef void *EGLNativePixmapType; typedef void *EGLNativeWindowType; #else #error "Platform not recognized" #endif /* EGL 1.2 types, renamed for consistency in EGL 1.3 */ typedef EGLNativeDisplayType NativeDisplayType; typedef EGLNativePixmapType NativePixmapType; typedef EGLNativeWindowType NativeWindowType; /* Define EGLint. This must be a signed integral type large enough to contain * all legal attribute names and values passed into and out of EGL, whether * their type is boolean, bitmask, enumerant (symbolic constant), integer, * handle, or other. While in general a 32-bit integer will suffice, if * handles are 64 bit types, then EGLint should be defined as a signed 64-bit * integer type. */ typedef khronos_int32_t EGLint; #endif /* __eglplatform_h */ freshplayerplugin-0.3.9/3rdparty/angle/include/GLES2/000077500000000000000000000000001321746453100223715ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/angle/include/GLES2/gl2.h000066400000000000000000000761771321746453100232500ustar00rootroot00000000000000#ifndef __gl2_h_ #define __gl2_h_ /* $Revision: 20555 $ on $Date:: 2013-02-12 14:32:47 -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/ . */ /*------------------------------------------------------------------------- * Data type definitions *-----------------------------------------------------------------------*/ 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; /* GL types for handling large vertex buffer objects */ typedef khronos_intptr_t GLintptr; typedef khronos_ssize_t GLsizeiptr; /* OpenGL ES core versions */ #define GL_ES_VERSION_2_0 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 (not supported in ES20) */ /* GL_NEVER */ /* GL_LESS */ /* GL_EQUAL */ /* GL_LEQUAL */ /* GL_GREATER */ /* GL_NOTEQUAL */ /* GL_GEQUAL */ /* GL_ALWAYS */ /* 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 */ /* BlendEquationSeparate */ #define GL_FUNC_ADD 0x8006 #define GL_BLEND_EQUATION 0x8009 #define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */ #define GL_BLEND_EQUATION_ALPHA 0x883D /* BlendSubtract */ #define GL_FUNC_SUBTRACT 0x800A #define GL_FUNC_REVERSE_SUBTRACT 0x800B /* Separate Blend Functions */ #define GL_BLEND_DST_RGB 0x80C8 #define GL_BLEND_SRC_RGB 0x80C9 #define GL_BLEND_DST_ALPHA 0x80CA #define GL_BLEND_SRC_ALPHA 0x80CB #define GL_CONSTANT_COLOR 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 #define GL_CONSTANT_ALPHA 0x8003 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 #define GL_BLEND_COLOR 0x8005 /* 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_STREAM_DRAW 0x88E0 #define GL_STATIC_DRAW 0x88E4 #define GL_DYNAMIC_DRAW 0x88E8 #define GL_BUFFER_SIZE 0x8764 #define GL_BUFFER_USAGE 0x8765 #define GL_CURRENT_VERTEX_ATTRIB 0x8626 /* 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_TEXTURE_2D 0x0DE1 #define GL_CULL_FACE 0x0B44 #define GL_BLEND 0x0BE2 #define GL_DITHER 0x0BD0 #define GL_STENCIL_TEST 0x0B90 #define GL_DEPTH_TEST 0x0B71 #define GL_SCISSOR_TEST 0x0C11 #define GL_POLYGON_OFFSET_FILL 0x8037 #define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E #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_OUT_OF_MEMORY 0x0505 /* FrontFaceDirection */ #define GL_CW 0x0900 #define GL_CCW 0x0901 /* GetPName */ #define GL_LINE_WIDTH 0x0B21 #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_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_FAIL 0x0B94 #define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 #define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 #define GL_STENCIL_REF 0x0B97 #define GL_STENCIL_VALUE_MASK 0x0B93 #define GL_STENCIL_WRITEMASK 0x0B98 #define GL_STENCIL_BACK_FUNC 0x8800 #define GL_STENCIL_BACK_FAIL 0x8801 #define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 #define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 #define GL_STENCIL_BACK_REF 0x8CA3 #define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 #define GL_STENCIL_BACK_WRITEMASK 0x8CA5 #define GL_VIEWPORT 0x0BA2 #define GL_SCISSOR_BOX 0x0C10 /* GL_SCISSOR_TEST */ #define GL_COLOR_CLEAR_VALUE 0x0C22 #define GL_COLOR_WRITEMASK 0x0C23 #define GL_UNPACK_ALIGNMENT 0x0CF5 #define GL_PACK_ALIGNMENT 0x0D05 #define GL_MAX_TEXTURE_SIZE 0x0D33 #define GL_MAX_VIEWPORT_DIMS 0x0D3A #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 /* GL_POLYGON_OFFSET_FILL */ #define GL_POLYGON_OFFSET_FACTOR 0x8038 #define GL_TEXTURE_BINDING_2D 0x8069 #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_GENERATE_MIPMAP_HINT 0x8192 /* DataType */ #define GL_BYTE 0x1400 #define GL_UNSIGNED_BYTE 0x1401 #define GL_SHORT 0x1402 #define GL_UNSIGNED_SHORT 0x1403 #define GL_INT 0x1404 #define GL_UNSIGNED_INT 0x1405 #define GL_FLOAT 0x1406 #define GL_FIXED 0x140C /* PixelFormat */ #define GL_DEPTH_COMPONENT 0x1902 #define GL_ALPHA 0x1906 #define GL_RGB 0x1907 #define GL_RGBA 0x1908 #define GL_LUMINANCE 0x1909 #define GL_LUMINANCE_ALPHA 0x190A /* 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 /* Shaders */ #define GL_FRAGMENT_SHADER 0x8B30 #define GL_VERTEX_SHADER 0x8B31 #define GL_MAX_VERTEX_ATTRIBS 0x8869 #define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB #define GL_MAX_VARYING_VECTORS 0x8DFC #define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D #define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C #define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 #define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD #define GL_SHADER_TYPE 0x8B4F #define GL_DELETE_STATUS 0x8B80 #define GL_LINK_STATUS 0x8B82 #define GL_VALIDATE_STATUS 0x8B83 #define GL_ATTACHED_SHADERS 0x8B85 #define GL_ACTIVE_UNIFORMS 0x8B86 #define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 #define GL_ACTIVE_ATTRIBUTES 0x8B89 #define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A #define GL_SHADING_LANGUAGE_VERSION 0x8B8C #define GL_CURRENT_PROGRAM 0x8B8D /* StencilFunction */ #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 /* StencilOp */ /* GL_ZERO */ #define GL_KEEP 0x1E00 #define GL_REPLACE 0x1E01 #define GL_INCR 0x1E02 #define GL_DECR 0x1E03 #define GL_INVERT 0x150A #define GL_INCR_WRAP 0x8507 #define GL_DECR_WRAP 0x8508 /* StringName */ #define GL_VENDOR 0x1F00 #define GL_RENDERER 0x1F01 #define GL_VERSION 0x1F02 #define GL_EXTENSIONS 0x1F03 /* 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 /* TextureTarget */ /* GL_TEXTURE_2D */ #define GL_TEXTURE 0x1702 #define GL_TEXTURE_CUBE_MAP 0x8513 #define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A #define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C /* 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 /* TextureWrapMode */ #define GL_REPEAT 0x2901 #define GL_CLAMP_TO_EDGE 0x812F #define GL_MIRRORED_REPEAT 0x8370 /* Uniform Types */ #define GL_FLOAT_VEC2 0x8B50 #define GL_FLOAT_VEC3 0x8B51 #define GL_FLOAT_VEC4 0x8B52 #define GL_INT_VEC2 0x8B53 #define GL_INT_VEC3 0x8B54 #define GL_INT_VEC4 0x8B55 #define GL_BOOL 0x8B56 #define GL_BOOL_VEC2 0x8B57 #define GL_BOOL_VEC3 0x8B58 #define GL_BOOL_VEC4 0x8B59 #define GL_FLOAT_MAT2 0x8B5A #define GL_FLOAT_MAT3 0x8B5B #define GL_FLOAT_MAT4 0x8B5C #define GL_SAMPLER_2D 0x8B5E #define GL_SAMPLER_CUBE 0x8B60 /* Vertex Arrays */ #define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 #define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 #define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 #define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A #define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F /* Read Format */ #define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A #define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B /* Shader Source */ #define GL_COMPILE_STATUS 0x8B81 #define GL_INFO_LOG_LENGTH 0x8B84 #define GL_SHADER_SOURCE_LENGTH 0x8B88 #define GL_SHADER_COMPILER 0x8DFA /* Shader Binary */ #define GL_SHADER_BINARY_FORMATS 0x8DF8 #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 /* Shader Precision-Specified Types */ #define GL_LOW_FLOAT 0x8DF0 #define GL_MEDIUM_FLOAT 0x8DF1 #define GL_HIGH_FLOAT 0x8DF2 #define GL_LOW_INT 0x8DF3 #define GL_MEDIUM_INT 0x8DF4 #define GL_HIGH_INT 0x8DF5 /* Framebuffer Object. */ #define GL_FRAMEBUFFER 0x8D40 #define GL_RENDERBUFFER 0x8D41 #define GL_RGBA4 0x8056 #define GL_RGB5_A1 0x8057 #define GL_RGB565 0x8D62 #define GL_DEPTH_COMPONENT16 0x81A5 #define GL_STENCIL_INDEX8 0x8D48 #define GL_RENDERBUFFER_WIDTH 0x8D42 #define GL_RENDERBUFFER_HEIGHT 0x8D43 #define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 #define GL_RENDERBUFFER_RED_SIZE 0x8D50 #define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 #define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 #define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 #define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 #define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 #define GL_COLOR_ATTACHMENT0 0x8CE0 #define GL_DEPTH_ATTACHMENT 0x8D00 #define GL_STENCIL_ATTACHMENT 0x8D20 #define GL_NONE 0 #define GL_FRAMEBUFFER_COMPLETE 0x8CD5 #define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 #define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 #define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 #define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD #define GL_FRAMEBUFFER_BINDING 0x8CA6 #define GL_RENDERBUFFER_BINDING 0x8CA7 #define GL_MAX_RENDERBUFFER_SIZE 0x84E8 #define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 /*------------------------------------------------------------------------- * GL core functions. *-----------------------------------------------------------------------*/ GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name); GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); GL_APICALL void GL_APIENTRY glBlendEquation ( GLenum mode ); GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth); GL_APICALL void GL_APIENTRY glClearStencil (GLint s); GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data); GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers); GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers); GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers); GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures); GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); GL_APICALL void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); GL_APICALL void GL_APIENTRY glDisable (GLenum cap); GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); GL_APICALL void GL_APIENTRY glEnable (GLenum cap); GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); GL_APICALL void GL_APIENTRY glFinish (void); GL_APICALL void GL_APIENTRY glFlush (void); GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers); GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers); GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers); GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures); GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params); GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params); GL_APICALL GLenum GL_APIENTRY glGetError (void); GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params); GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog); GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name); GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params); GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params); GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params); GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params); GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer); GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length); GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length); GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params); GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params); GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x); GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v); GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x); GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v); GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y); GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v); GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y); GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v); GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z); GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v); GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z); GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v); GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v); GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w); GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v); GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x); GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values); GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y); GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values); GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z); GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values); GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values); GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr); GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); #ifdef __cplusplus } #endif #endif /* __gl2_h_ */ freshplayerplugin-0.3.9/3rdparty/angle/include/GLES2/gl2ext.h000066400000000000000000002745521321746453100237660ustar00rootroot00000000000000#ifndef __gl2ext_h_ #define __gl2ext_h_ /* $Revision: 20795 $ on $Date:: 2013-03-07 01:01:58 -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_compressed_ETC1_RGB8_texture */ #ifndef GL_OES_compressed_ETC1_RGB8_texture #define GL_ETC1_RGB8_OES 0x8D64 #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 /* 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_depth_texture */ /* No new tokens introduced by this extension. */ /* 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_SAMPLER_EXTERNAL_OES 0x8D66 #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_get_program_binary */ #ifndef GL_OES_get_program_binary #define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 #define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE #define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF #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_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_required_internalformat */ #ifndef GL_OES_required_internalformat #define GL_ALPHA8_OES 0x803C #define GL_DEPTH_COMPONENT16_OES 0x81A5 /* reuse GL_DEPTH_COMPONENT24_OES */ /* reuse GL_DEPTH24_STENCIL8_OES */ /* reuse GL_DEPTH_COMPONENT32_OES */ #define GL_LUMINANCE4_ALPHA4_OES 0x8043 #define GL_LUMINANCE8_ALPHA8_OES 0x8045 #define GL_LUMINANCE8_OES 0x8040 #define GL_RGBA4_OES 0x8056 #define GL_RGB5_A1_OES 0x8057 #define GL_RGB565_OES 0x8D62 /* reuse GL_RGB8_OES */ /* reuse GL_RGBA8_OES */ /* reuse GL_RGB10_EXT */ /* reuse GL_RGB10_A2_EXT */ #endif /* GL_OES_rgb8_rgba8 */ #ifndef GL_OES_rgb8_rgba8 #define GL_RGB8_OES 0x8051 #define GL_RGBA8_OES 0x8058 #endif /* GL_OES_standard_derivatives */ #ifndef GL_OES_standard_derivatives #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B #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 #ifndef GL_OES_surfaceless_context #define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219 #endif /* GL_OES_texture_3D */ #ifndef GL_OES_texture_3D #define GL_TEXTURE_WRAP_R_OES 0x8072 #define GL_TEXTURE_3D_OES 0x806F #define GL_TEXTURE_BINDING_3D_OES 0x806A #define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073 #define GL_SAMPLER_3D_OES 0x8B5F #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4 #endif /* GL_OES_texture_float */ /* No new tokens introduced by this extension. */ /* GL_OES_texture_float_linear */ /* No new tokens introduced by this extension. */ /* GL_OES_texture_half_float */ #ifndef GL_OES_texture_half_float #define GL_HALF_FLOAT_OES 0x8D61 #endif /* GL_OES_texture_half_float_linear */ /* No new tokens introduced by this extension. */ /* GL_OES_texture_npot */ /* No new tokens introduced by this extension. */ /* GL_OES_vertex_array_object */ #ifndef GL_OES_vertex_array_object #define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 #endif /* GL_OES_vertex_half_float */ /* GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already. */ /* GL_OES_vertex_type_10_10_10_2 */ #ifndef GL_OES_vertex_type_10_10_10_2 #define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6 #define GL_INT_10_10_10_2_OES 0x8DF7 #endif /*------------------------------------------------------------------------* * KHR extension tokens *------------------------------------------------------------------------*/ #ifndef GL_KHR_debug typedef void (GL_APIENTRYP GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); #define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 #define GL_DEBUG_CALLBACK_FUNCTION 0x8244 #define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 #define GL_DEBUG_SOURCE_API 0x8246 #define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 #define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 #define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 #define GL_DEBUG_SOURCE_APPLICATION 0x824A #define GL_DEBUG_SOURCE_OTHER 0x824B #define GL_DEBUG_TYPE_ERROR 0x824C #define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D #define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E #define GL_DEBUG_TYPE_PORTABILITY 0x824F #define GL_DEBUG_TYPE_PERFORMANCE 0x8250 #define GL_DEBUG_TYPE_OTHER 0x8251 #define GL_DEBUG_TYPE_MARKER 0x8268 #define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 #define GL_DEBUG_TYPE_POP_GROUP 0x826A #define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B #define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C #define GL_DEBUG_GROUP_STACK_DEPTH 0x826D #define GL_BUFFER 0x82E0 #define GL_SHADER 0x82E1 #define GL_PROGRAM 0x82E2 #define GL_QUERY 0x82E3 /* PROGRAM_PIPELINE only in GL */ #define GL_SAMPLER 0x82E6 /* DISPLAY_LIST only in GL */ #define GL_MAX_LABEL_LENGTH 0x82E8 #define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 #define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 #define GL_DEBUG_LOGGED_MESSAGES 0x9145 #define GL_DEBUG_SEVERITY_HIGH 0x9146 #define GL_DEBUG_SEVERITY_MEDIUM 0x9147 #define GL_DEBUG_SEVERITY_LOW 0x9148 #define GL_DEBUG_OUTPUT 0x92E0 #define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 #define GL_STACK_OVERFLOW 0x0503 #define GL_STACK_UNDERFLOW 0x0504 #endif #ifndef GL_KHR_texture_compression_astc_ldr #define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 #define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 #define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 #define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 #define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 #define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 #define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 #define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 #define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 #define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 #define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA #define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB #define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC #define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD #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 /* GL_AMD_performance_monitor */ #ifndef GL_AMD_performance_monitor #define GL_COUNTER_TYPE_AMD 0x8BC0 #define GL_COUNTER_RANGE_AMD 0x8BC1 #define GL_UNSIGNED_INT64_AMD 0x8BC2 #define GL_PERCENTAGE_AMD 0x8BC3 #define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 #define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 #define GL_PERFMON_RESULT_AMD 0x8BC6 #endif /* GL_AMD_program_binary_Z400 */ #ifndef GL_AMD_program_binary_Z400 #define GL_Z400_BINARY_AMD 0x8740 #endif /*------------------------------------------------------------------------* * ANGLE extension tokens *------------------------------------------------------------------------*/ /* GL_ANGLE_depth_texture */ #ifndef GL_ANGLE_depth_texture #define GL_DEPTH_COMPONENT 0x1902 #define GL_DEPTH_STENCIL_OES 0x84F9 #define GL_UNSIGNED_SHORT 0x1403 #define GL_UNSIGNED_INT 0x1405 #define GL_UNSIGNED_INT_24_8_OES 0x84FA #define GL_DEPTH_COMPONENT16 0x81A5 #define GL_DEPTH_COMPONENT32_OES 0x81A7 #define GL_DEPTH24_STENCIL8_OES 0x88F0 #endif /* GL_ANGLE_framebuffer_blit */ #ifndef GL_ANGLE_framebuffer_blit #define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 #define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 #define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 #define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA #endif /* GL_ANGLE_framebuffer_multisample */ #ifndef GL_ANGLE_framebuffer_multisample #define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 #define GL_MAX_SAMPLES_ANGLE 0x8D57 #endif /* GL_ANGLE_instanced_arrays */ #ifndef GL_ANGLE_instanced_arrays #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE #endif /* GL_ANGLE_pack_reverse_row_order */ #ifndef GL_ANGLE_pack_reverse_row_order #define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 #endif /* GL_ANGLE_program_binary */ #ifndef GL_ANGLE_program_binary #define GL_PROGRAM_BINARY_ANGLE 0x93A6 #endif /* GL_ANGLE_texture_compression_dxt3 */ #ifndef GL_ANGLE_texture_compression_dxt3 #define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 #endif /* GL_ANGLE_texture_compression_dxt5 */ #ifndef GL_ANGLE_texture_compression_dxt5 #define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 #endif /* GL_ANGLE_texture_usage */ #ifndef GL_ANGLE_texture_usage #define GL_TEXTURE_USAGE_ANGLE 0x93A2 #define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 #endif /* GL_ANGLE_translated_shader_source */ #ifndef GL_ANGLE_translated_shader_source #define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0 #endif /*------------------------------------------------------------------------* * APPLE extension tokens *------------------------------------------------------------------------*/ /* GL_APPLE_copy_texture_levels */ /* 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_rgb_422 */ #ifndef GL_APPLE_rgb_422 #define GL_RGB_422_APPLE 0x8A1F #define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA #define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB #endif /* GL_APPLE_sync */ #ifndef GL_APPLE_sync #ifndef __gl3_h_ /* These types are defined with reference to * in the Apple extension spec, but here we use the Khronos * portable types in khrplatform.h, and assume those types * are always defined. * If any other extensions using these types are defined, * the typedefs must move out of this block and be shared. */ typedef khronos_int64_t GLint64; typedef khronos_uint64_t GLuint64; typedef struct __GLsync *GLsync; #endif #define GL_SYNC_OBJECT_APPLE 0x8A53 #define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111 #define GL_OBJECT_TYPE_APPLE 0x9112 #define GL_SYNC_CONDITION_APPLE 0x9113 #define GL_SYNC_STATUS_APPLE 0x9114 #define GL_SYNC_FLAGS_APPLE 0x9115 #define GL_SYNC_FENCE_APPLE 0x9116 #define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117 #define GL_UNSIGNALED_APPLE 0x9118 #define GL_SIGNALED_APPLE 0x9119 #define GL_ALREADY_SIGNALED_APPLE 0x911A #define GL_TIMEOUT_EXPIRED_APPLE 0x911B #define GL_CONDITION_SATISFIED_APPLE 0x911C #define GL_WAIT_FAILED_APPLE 0x911D #define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001 #define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull #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_mali_program_binary */ #ifndef GL_ARM_mali_program_binary #define GL_MALI_PROGRAM_BINARY_ARM 0x8F61 #endif /* GL_ARM_mali_shader_binary */ #ifndef GL_ARM_mali_shader_binary #define GL_MALI_SHADER_BINARY_ARM 0x8F60 #endif /* 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_color_buffer_half_float */ #ifndef GL_EXT_color_buffer_half_float #define GL_RGBA16F_EXT 0x881A #define GL_RGB16F_EXT 0x881B #define GL_RG16F_EXT 0x822F #define GL_R16F_EXT 0x822D #define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211 #define GL_UNSIGNED_NORMALIZED_EXT 0x8C17 #endif /* GL_EXT_debug_label */ #ifndef GL_EXT_debug_label #define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F #define GL_PROGRAM_OBJECT_EXT 0x8B40 #define GL_SHADER_OBJECT_EXT 0x8B48 #define GL_BUFFER_OBJECT_EXT 0x9151 #define GL_QUERY_OBJECT_EXT 0x9153 #define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 #endif /* GL_EXT_debug_marker */ /* No new tokens introduced by this extension. */ /* 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_map_buffer_range */ #ifndef GL_EXT_map_buffer_range #define GL_MAP_READ_BIT_EXT 0x0001 #define GL_MAP_WRITE_BIT_EXT 0x0002 #define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004 #define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008 #define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010 #define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020 #endif /* GL_EXT_multisampled_render_to_texture */ #ifndef GL_EXT_multisampled_render_to_texture #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C /* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */ #define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 #define GL_MAX_SAMPLES_EXT 0x8D57 #endif /* GL_EXT_multiview_draw_buffers */ #ifndef GL_EXT_multiview_draw_buffers #define GL_COLOR_ATTACHMENT_EXT 0x90F0 #define GL_MULTIVIEW_EXT 0x90F1 #define GL_DRAW_BUFFER_EXT 0x0C01 #define GL_READ_BUFFER_EXT 0x0C02 #define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2 #endif /* GL_EXT_multi_draw_arrays */ /* No new tokens introduced by this extension. */ /* GL_EXT_occlusion_query_boolean */ #ifndef GL_EXT_occlusion_query_boolean #define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F #define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A #define GL_CURRENT_QUERY_EXT 0x8865 #define GL_QUERY_RESULT_EXT 0x8866 #define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867 #endif /* 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_robustness */ #ifndef GL_EXT_robustness /* reuse GL_NO_ERROR */ #define GL_GUILTY_CONTEXT_RESET_EXT 0x8253 #define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254 #define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255 #define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3 #define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256 #define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252 #define GL_NO_RESET_NOTIFICATION_EXT 0x8261 #endif /* GL_EXT_separate_shader_objects */ #ifndef GL_EXT_separate_shader_objects #define GL_VERTEX_SHADER_BIT_EXT 0x00000001 #define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002 #define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF #define GL_PROGRAM_SEPARABLE_EXT 0x8258 #define GL_ACTIVE_PROGRAM_EXT 0x8259 #define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A #endif /* GL_EXT_shader_framebuffer_fetch */ #ifndef GL_EXT_shader_framebuffer_fetch #define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 #endif /* GL_EXT_shader_texture_lod */ /* No new tokens introduced by this extension. */ /* GL_EXT_shadow_samplers */ #ifndef GL_EXT_shadow_samplers #define GL_TEXTURE_COMPARE_MODE_EXT 0x884C #define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D #define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E #define GL_SAMPLER_2D_SHADOW_EXT 0x8B62 #endif /* GL_EXT_sRGB */ #ifndef GL_EXT_sRGB #define GL_SRGB_EXT 0x8C40 #define GL_SRGB_ALPHA_EXT 0x8C42 #define GL_SRGB8_ALPHA8_EXT 0x8C43 #define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210 #endif /* GL_EXT_texture_compression_dxt1 */ #ifndef GL_EXT_texture_compression_dxt1 #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 #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_rg */ #ifndef GL_EXT_texture_rg #define GL_RED_EXT 0x1903 #define GL_RG_EXT 0x8227 #define GL_R8_EXT 0x8229 #define GL_RG8_EXT 0x822B #endif /* GL_EXT_texture_storage */ #ifndef GL_EXT_texture_storage #define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F #define GL_ALPHA8_EXT 0x803C #define GL_LUMINANCE8_EXT 0x8040 #define GL_LUMINANCE8_ALPHA8_EXT 0x8045 #define GL_RGBA32F_EXT 0x8814 #define GL_RGB32F_EXT 0x8815 #define GL_ALPHA32F_EXT 0x8816 #define GL_LUMINANCE32F_EXT 0x8818 #define GL_LUMINANCE_ALPHA32F_EXT 0x8819 /* reuse GL_RGBA16F_EXT */ /* reuse GL_RGB16F_EXT */ #define GL_ALPHA16F_EXT 0x881C #define GL_LUMINANCE16F_EXT 0x881E #define GL_LUMINANCE_ALPHA16F_EXT 0x881F #define GL_RGB10_A2_EXT 0x8059 #define GL_RGB10_EXT 0x8052 #define GL_BGRA8_EXT 0x93A1 #define GL_R8_EXT 0x8229 #define GL_RG8_EXT 0x822B #define GL_R32F_EXT 0x822E #define GL_RG32F_EXT 0x8230 #define GL_R16F_EXT 0x822D #define GL_RG16F_EXT 0x822F #endif /* GL_EXT_texture_type_2_10_10_10_REV */ #ifndef GL_EXT_texture_type_2_10_10_10_REV #define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 #endif /* GL_EXT_unpack_subimage */ #ifndef GL_EXT_unpack_subimage #define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2 #define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3 #define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4 #endif /*------------------------------------------------------------------------* * DMP extension tokens *------------------------------------------------------------------------*/ /* GL_DMP_shader_binary */ #ifndef GL_DMP_shader_binary #define GL_SHADER_BINARY_DMP 0x9250 #endif /*------------------------------------------------------------------------* * FJ extension tokens *------------------------------------------------------------------------*/ /* GL_FJ_shader_binary_GCCSO */ #ifndef GL_FJ_shader_binary_GCCSO #define GL_GCCSO_SHADER_BINARY_F 0x9260 #endif /*------------------------------------------------------------------------* * IMG extension tokens *------------------------------------------------------------------------*/ /* GL_IMG_program_binary */ #ifndef GL_IMG_program_binary #define GL_SGX_PROGRAM_BINARY_IMG 0x9130 #endif /* 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_shader_binary */ #ifndef GL_IMG_shader_binary #define GL_SGX_BINARY_IMG 0x8C0A #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_compression_pvrtc2 */ #ifndef GL_IMG_texture_compression_pvrtc2 #define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137 #define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138 #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_coverage_sample */ #ifndef GL_NV_coverage_sample #define GL_COVERAGE_COMPONENT_NV 0x8ED0 #define GL_COVERAGE_COMPONENT4_NV 0x8ED1 #define GL_COVERAGE_ATTACHMENT_NV 0x8ED2 #define GL_COVERAGE_BUFFERS_NV 0x8ED3 #define GL_COVERAGE_SAMPLES_NV 0x8ED4 #define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 #define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 #define GL_COVERAGE_AUTOMATIC_NV 0x8ED7 #define GL_COVERAGE_BUFFER_BIT_NV 0x8000 #endif /* GL_NV_depth_nonlinear */ #ifndef GL_NV_depth_nonlinear #define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C #endif /* GL_NV_draw_buffers */ #ifndef GL_NV_draw_buffers #define GL_MAX_DRAW_BUFFERS_NV 0x8824 #define GL_DRAW_BUFFER0_NV 0x8825 #define GL_DRAW_BUFFER1_NV 0x8826 #define GL_DRAW_BUFFER2_NV 0x8827 #define GL_DRAW_BUFFER3_NV 0x8828 #define GL_DRAW_BUFFER4_NV 0x8829 #define GL_DRAW_BUFFER5_NV 0x882A #define GL_DRAW_BUFFER6_NV 0x882B #define GL_DRAW_BUFFER7_NV 0x882C #define GL_DRAW_BUFFER8_NV 0x882D #define GL_DRAW_BUFFER9_NV 0x882E #define GL_DRAW_BUFFER10_NV 0x882F #define GL_DRAW_BUFFER11_NV 0x8830 #define GL_DRAW_BUFFER12_NV 0x8831 #define GL_DRAW_BUFFER13_NV 0x8832 #define GL_DRAW_BUFFER14_NV 0x8833 #define GL_DRAW_BUFFER15_NV 0x8834 #define GL_COLOR_ATTACHMENT0_NV 0x8CE0 #define GL_COLOR_ATTACHMENT1_NV 0x8CE1 #define GL_COLOR_ATTACHMENT2_NV 0x8CE2 #define GL_COLOR_ATTACHMENT3_NV 0x8CE3 #define GL_COLOR_ATTACHMENT4_NV 0x8CE4 #define GL_COLOR_ATTACHMENT5_NV 0x8CE5 #define GL_COLOR_ATTACHMENT6_NV 0x8CE6 #define GL_COLOR_ATTACHMENT7_NV 0x8CE7 #define GL_COLOR_ATTACHMENT8_NV 0x8CE8 #define GL_COLOR_ATTACHMENT9_NV 0x8CE9 #define GL_COLOR_ATTACHMENT10_NV 0x8CEA #define GL_COLOR_ATTACHMENT11_NV 0x8CEB #define GL_COLOR_ATTACHMENT12_NV 0x8CEC #define GL_COLOR_ATTACHMENT13_NV 0x8CED #define GL_COLOR_ATTACHMENT14_NV 0x8CEE #define GL_COLOR_ATTACHMENT15_NV 0x8CEF #endif /* GL_EXT_draw_buffers */ #ifndef GL_EXT_draw_buffers #define GL_MAX_DRAW_BUFFERS_EXT 0x8824 #define GL_DRAW_BUFFER0_EXT 0x8825 #define GL_DRAW_BUFFER1_EXT 0x8826 #define GL_DRAW_BUFFER2_EXT 0x8827 #define GL_DRAW_BUFFER3_EXT 0x8828 #define GL_DRAW_BUFFER4_EXT 0x8829 #define GL_DRAW_BUFFER5_EXT 0x882A #define GL_DRAW_BUFFER6_EXT 0x882B #define GL_DRAW_BUFFER7_EXT 0x882C #define GL_DRAW_BUFFER8_EXT 0x882D #define GL_DRAW_BUFFER9_EXT 0x882E #define GL_DRAW_BUFFER10_EXT 0x882F #define GL_DRAW_BUFFER11_EXT 0x8830 #define GL_DRAW_BUFFER12_EXT 0x8831 #define GL_DRAW_BUFFER13_EXT 0x8832 #define GL_DRAW_BUFFER14_EXT 0x8833 #define GL_DRAW_BUFFER15_EXT 0x8834 #define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 #define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 #define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 #define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 #define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 #define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 #define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 #define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 #define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 #define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 #define GL_COLOR_ATTACHMENT10_EXT 0x8CEA #define GL_COLOR_ATTACHMENT11_EXT 0x8CEB #define GL_COLOR_ATTACHMENT12_EXT 0x8CEC #define GL_COLOR_ATTACHMENT13_EXT 0x8CED #define GL_COLOR_ATTACHMENT14_EXT 0x8CEE #define GL_COLOR_ATTACHMENT15_EXT 0x8CEF #define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF #endif /* GL_NV_draw_instanced */ /* No new tokens introduced by this extension. */ /* GL_NV_fbo_color_attachments */ #ifndef GL_NV_fbo_color_attachments #define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF /* GL_COLOR_ATTACHMENT{0-15}_NV defined in GL_NV_draw_buffers already. */ #endif /* 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 /* GL_NV_framebuffer_blit */ #ifndef GL_NV_framebuffer_blit #define GL_READ_FRAMEBUFFER_NV 0x8CA8 #define GL_DRAW_FRAMEBUFFER_NV 0x8CA9 #define GL_DRAW_FRAMEBUFFER_BINDING_NV 0x8CA6 #define GL_READ_FRAMEBUFFER_BINDING_NV 0x8CAA #endif /* GL_NV_framebuffer_multisample */ #ifndef GL_NV_framebuffer_multisample #define GL_RENDERBUFFER_SAMPLES_NV 0x8CAB #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56 #define GL_MAX_SAMPLES_NV 0x8D57 #endif /* GL_NV_generate_mipmap_sRGB */ /* No new tokens introduced by this extension. */ /* GL_NV_instanced_arrays */ #ifndef GL_NV_instanced_arrays #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE #endif /* GL_NV_read_buffer */ #ifndef GL_NV_read_buffer #define GL_READ_BUFFER_NV 0x0C02 #endif /* GL_NV_read_buffer_front */ /* No new tokens introduced by this extension. */ /* GL_NV_read_depth */ /* No new tokens introduced by this extension. */ /* GL_NV_read_depth_stencil */ /* No new tokens introduced by this extension. */ /* GL_NV_read_stencil */ /* No new tokens introduced by this extension. */ /* GL_NV_shadow_samplers_array */ #ifndef GL_NV_shadow_samplers_array #define GL_SAMPLER_2D_ARRAY_SHADOW_NV 0x8DC4 #endif /* GL_NV_shadow_samplers_cube */ #ifndef GL_NV_shadow_samplers_cube #define GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5 #endif /* GL_NV_sRGB_formats */ #ifndef GL_NV_sRGB_formats #define GL_SLUMINANCE_NV 0x8C46 #define GL_SLUMINANCE_ALPHA_NV 0x8C44 #define GL_SRGB8_NV 0x8C41 #define GL_SLUMINANCE8_NV 0x8C47 #define GL_SLUMINANCE8_ALPHA8_NV 0x8C45 #define GL_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F #define GL_ETC1_SRGB8_NV 0x88EE #endif /* GL_NV_texture_border_clamp */ #ifndef GL_NV_texture_border_clamp #define GL_TEXTURE_BORDER_COLOR_NV 0x1004 #define GL_CLAMP_TO_BORDER_NV 0x812D #endif /* GL_NV_texture_compression_s3tc_update */ /* No new tokens introduced by this extension. */ /* GL_NV_texture_npot_2D_mipmap */ /* No new tokens introduced by this extension. */ /*------------------------------------------------------------------------* * QCOM extension tokens *------------------------------------------------------------------------*/ /* GL_QCOM_alpha_test */ #ifndef GL_QCOM_alpha_test #define GL_ALPHA_TEST_QCOM 0x0BC0 #define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1 #define GL_ALPHA_TEST_REF_QCOM 0x0BC2 #endif /* GL_QCOM_binning_control */ #ifndef GL_QCOM_binning_control #define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0 #define GL_CPU_OPTIMIZED_QCOM 0x8FB1 #define GL_GPU_OPTIMIZED_QCOM 0x8FB2 #define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3 #endif /* 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 /*------------------------------------------------------------------------* * VIV extension tokens *------------------------------------------------------------------------*/ /* GL_VIV_shader_binary */ #ifndef GL_VIV_shader_binary #define GL_SHADER_BINARY_VIV 0x8FC4 #endif /*------------------------------------------------------------------------* * End of extension tokens, start of corresponding extension functions *------------------------------------------------------------------------*/ /*------------------------------------------------------------------------* * OES extension functions *------------------------------------------------------------------------*/ /* GL_OES_compressed_ETC1_RGB8_texture */ #ifndef GL_OES_compressed_ETC1_RGB8_texture #define GL_OES_compressed_ETC1_RGB8_texture 1 #endif /* GL_OES_compressed_paletted_texture */ #ifndef GL_OES_compressed_paletted_texture #define GL_OES_compressed_paletted_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_depth_texture */ #ifndef GL_OES_depth_texture #define GL_OES_depth_texture 1 #endif /* GL_OES_EGL_image */ #ifndef GL_OES_EGL_image #define GL_OES_EGL_image 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); GL_APICALL 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_fbo_render_mipmap */ #ifndef GL_OES_fbo_render_mipmap #define GL_OES_fbo_render_mipmap 1 #endif /* GL_OES_fragment_precision_high */ #ifndef GL_OES_fragment_precision_high #define GL_OES_fragment_precision_high 1 #endif /* GL_OES_get_program_binary */ #ifndef GL_OES_get_program_binary #define GL_OES_get_program_binary 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length); #endif typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length); #endif /* GL_OES_mapbuffer */ #ifndef GL_OES_mapbuffer #define GL_OES_mapbuffer 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access); GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target); GL_APICALL 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_packed_depth_stencil */ #ifndef GL_OES_packed_depth_stencil #define GL_OES_packed_depth_stencil 1 #endif /* GL_OES_required_internalformat */ #ifndef GL_OES_required_internalformat #define GL_OES_required_internalformat 1 #endif /* GL_OES_rgb8_rgba8 */ #ifndef GL_OES_rgb8_rgba8 #define GL_OES_rgb8_rgba8 1 #endif /* GL_OES_standard_derivatives */ #ifndef GL_OES_standard_derivatives #define GL_OES_standard_derivatives 1 #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 #ifndef GL_OES_surfaceless_context #define GL_OES_surfaceless_context 1 #endif /* GL_OES_texture_3D */ #ifndef GL_OES_texture_3D #define GL_OES_texture_3D 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); GL_APICALL void GL_APIENTRY 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_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); GL_APICALL void GL_APIENTRY 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_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); #endif typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOES) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); #endif /* GL_OES_texture_float */ #ifndef GL_OES_texture_float #define GL_OES_texture_float 1 #endif /* GL_OES_texture_float_linear */ #ifndef GL_OES_texture_float_linear #define GL_OES_texture_float_linear 1 #endif /* GL_OES_texture_half_float */ #ifndef GL_OES_texture_half_float #define GL_OES_texture_half_float 1 #endif /* GL_OES_texture_half_float_linear */ #ifndef GL_OES_texture_half_float_linear #define GL_OES_texture_half_float_linear 1 #endif /* GL_OES_texture_npot */ #ifndef GL_OES_texture_npot #define GL_OES_texture_npot 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_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array); GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays); GL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays); GL_APICALL 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 /* GL_OES_vertex_half_float */ #ifndef GL_OES_vertex_half_float #define GL_OES_vertex_half_float 1 #endif /* GL_OES_vertex_type_10_10_10_2 */ #ifndef GL_OES_vertex_type_10_10_10_2 #define GL_OES_vertex_type_10_10_10_2 1 #endif /*------------------------------------------------------------------------* * KHR extension functions *------------------------------------------------------------------------*/ #ifndef GL_KHR_debug #define GL_KHR_debug 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); GL_APICALL void GL_APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); GL_APICALL void GL_APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); GL_APICALL void GL_APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); GL_APICALL void GL_APIENTRY glPopDebugGroup (void); GL_APICALL void GL_APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); GL_APICALL void GL_APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); GL_APICALL void GL_APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); GL_APICALL void GL_APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); GL_APICALL void GL_APIENTRY glGetPointerv (GLenum pname, void **params); #endif typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); typedef void (GL_APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); typedef void (GL_APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, void **params); #endif #ifndef GL_KHR_texture_compression_astc_ldr #define GL_KHR_texture_compression_astc_ldr 1 #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 /* AMD_performance_monitor */ #ifndef GL_AMD_performance_monitor #define GL_AMD_performance_monitor 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList); GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor); GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor); GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); #endif typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList); typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); #endif /* GL_AMD_program_binary_Z400 */ #ifndef GL_AMD_program_binary_Z400 #define GL_AMD_program_binary_Z400 1 #endif /*------------------------------------------------------------------------* * ANGLE extension functions *------------------------------------------------------------------------*/ /* GL_ANGLE_depth_texture */ #ifndef GL_ANGLE_depth_texture #define GL_ANGLE_depth_texture 1 #endif /* GL_ANGLE_framebuffer_blit */ #ifndef GL_ANGLE_framebuffer_blit #define GL_ANGLE_framebuffer_blit 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); #endif typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); #endif /* GL_ANGLE_framebuffer_multisample */ #ifndef GL_ANGLE_framebuffer_multisample #define GL_ANGLE_framebuffer_multisample 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #endif typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #endif #ifndef GL_ANGLE_instanced_arrays #define GL_ANGLE_instanced_arrays 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount); GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor); #endif typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor); #endif /* GL_ANGLE_pack_reverse_row_order */ #ifndef GL_ANGLE_pack_reverse_row_order #define GL_ANGLE_pack_reverse_row_order 1 #endif /* GL_ANGLE_program_binary */ #ifndef GL_ANGLE_program_binary #define GL_ANGLE_program_binary 1 #endif /* GL_ANGLE_texture_compression_dxt3 */ #ifndef GL_ANGLE_texture_compression_dxt3 #define GL_ANGLE_texture_compression_dxt3 1 #endif /* GL_ANGLE_texture_compression_dxt5 */ #ifndef GL_ANGLE_texture_compression_dxt5 #define GL_ANGLE_texture_compression_dxt5 1 #endif /* GL_ANGLE_texture_usage */ #ifndef GL_ANGLE_texture_usage #define GL_ANGLE_texture_usage 1 #endif #ifndef GL_ANGLE_translated_shader_source #define GL_ANGLE_translated_shader_source 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source); #endif typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source); #endif /*------------------------------------------------------------------------* * APPLE extension functions *------------------------------------------------------------------------*/ /* GL_APPLE_copy_texture_levels */ #ifndef GL_APPLE_copy_texture_levels #define GL_APPLE_copy_texture_levels 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); #endif typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); #endif /* GL_APPLE_framebuffer_multisample */ #ifndef GL_APPLE_framebuffer_multisample #define GL_APPLE_framebuffer_multisample 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum, GLsizei, GLenum, GLsizei, GLsizei); GL_APICALL 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_rgb_422 */ #ifndef GL_APPLE_rgb_422 #define GL_APPLE_rgb_422 1 #endif /* GL_APPLE_sync */ #ifndef GL_APPLE_sync #define GL_APPLE_sync 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags); GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync); GL_APICALL void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync); GL_APICALL GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); GL_APICALL void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params); GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); #endif typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags); typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync); typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync); typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params); typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); #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_mali_program_binary */ #ifndef GL_ARM_mali_program_binary #define GL_ARM_mali_program_binary 1 #endif /* GL_ARM_mali_shader_binary */ #ifndef GL_ARM_mali_shader_binary #define GL_ARM_mali_shader_binary 1 #endif /* 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_color_buffer_half_float */ #ifndef GL_EXT_color_buffer_half_float #define GL_EXT_color_buffer_half_float 1 #endif /* GL_EXT_debug_label */ #ifndef GL_EXT_debug_label #define GL_EXT_debug_label 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); GL_APICALL void GL_APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); #endif typedef void (GL_APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); #endif /* GL_EXT_debug_marker */ #ifndef GL_EXT_debug_marker #define GL_EXT_debug_marker 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); GL_APICALL void GL_APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); GL_APICALL void GL_APIENTRY glPopGroupMarkerEXT (void); #endif typedef void (GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); typedef void (GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); typedef void (GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); #endif /* GL_EXT_discard_framebuffer */ #ifndef GL_EXT_discard_framebuffer #define GL_EXT_discard_framebuffer 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL 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_map_buffer_range */ #ifndef GL_EXT_map_buffer_range #define GL_EXT_map_buffer_range 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length); #endif typedef void* (GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length); #endif /* GL_EXT_multisampled_render_to_texture */ #ifndef GL_EXT_multisampled_render_to_texture #define GL_EXT_multisampled_render_to_texture 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum, GLsizei, GLenum, GLsizei, GLsizei); GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); #endif typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); #endif /* GL_EXT_multiview_draw_buffers */ #ifndef GL_EXT_multiview_draw_buffers #define GL_EXT_multiview_draw_buffers 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index); GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices); GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data); #endif typedef void (GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC) (GLenum src, GLint index); typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC) (GLint n, const GLenum *location, const GLint *indices); typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint index, GLint *data); #endif #ifndef GL_EXT_multi_draw_arrays #define GL_EXT_multi_draw_arrays 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, const GLint *, const GLsizei *, GLsizei); GL_APICALL 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_occlusion_query_boolean */ #ifndef GL_EXT_occlusion_query_boolean #define GL_EXT_occlusion_query_boolean 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids); GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids); GL_APICALL GLboolean GL_APIENTRY glIsQueryEXT (GLuint id); GL_APICALL void GL_APIENTRY glBeginQueryEXT (GLenum target, GLuint id); GL_APICALL void GL_APIENTRY glEndQueryEXT (GLenum target); GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params); #endif typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids); typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids); typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id); typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id); typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target); typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params); #endif /* GL_EXT_read_format_bgra */ #ifndef GL_EXT_read_format_bgra #define GL_EXT_read_format_bgra 1 #endif /* GL_EXT_robustness */ #ifndef GL_EXT_robustness #define GL_EXT_robustness 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusEXT (void); GL_APICALL void GL_APIENTRY glReadnPixelsEXT (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); GL_APICALL void GL_APIENTRY glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, float *params); GL_APICALL void GL_APIENTRY glGetnUniformivEXT (GLuint program, GLint location, GLsizei bufSize, GLint *params); #endif typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC) (void); typedef void (GL_APIENTRYP PFNGLREADNPIXELSEXTPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, float *params); typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); #endif /* GL_EXT_separate_shader_objects */ #ifndef GL_EXT_separate_shader_objects #define GL_EXT_separate_shader_objects 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glUseProgramStagesEXT (GLuint pipeline, GLbitfield stages, GLuint program); GL_APICALL void GL_APIENTRY glActiveShaderProgramEXT (GLuint pipeline, GLuint program); GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar **strings); GL_APICALL void GL_APIENTRY glBindProgramPipelineEXT (GLuint pipeline); GL_APICALL void GL_APIENTRY glDeleteProgramPipelinesEXT (GLsizei n, const GLuint *pipelines); GL_APICALL void GL_APIENTRY glGenProgramPipelinesEXT (GLsizei n, GLuint *pipelines); GL_APICALL GLboolean GL_APIENTRY glIsProgramPipelineEXT (GLuint pipeline); GL_APICALL void GL_APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); GL_APICALL void GL_APIENTRY glGetProgramPipelineivEXT (GLuint pipeline, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint x); GL_APICALL void GL_APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint x, GLint y); GL_APICALL void GL_APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z); GL_APICALL void GL_APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w); GL_APICALL void GL_APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat x); GL_APICALL void GL_APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat x, GLfloat y); GL_APICALL void GL_APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z); GL_APICALL void GL_APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); GL_APICALL void GL_APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); GL_APICALL void GL_APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); GL_APICALL void GL_APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); GL_APICALL void GL_APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); GL_APICALL void GL_APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); GL_APICALL void GL_APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); GL_APICALL void GL_APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); GL_APICALL void GL_APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glValidateProgramPipelineEXT (GLuint pipeline); GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); #endif typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESEXTPROC) (GLuint pipeline, GLbitfield stages, GLuint program); typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMEXTPROC) (GLuint pipeline, GLuint program); typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar **strings); typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEEXTPROC) (GLuint pipeline); typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESEXTPROC) (GLsizei n, const GLuint *pipelines); typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESEXTPROC) (GLsizei n, GLuint *pipelines); typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEEXTPROC) (GLuint pipeline); typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVEXTPROC) (GLuint pipeline, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint x); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint x, GLint y); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat x); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline); typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); #endif /* GL_EXT_shader_framebuffer_fetch */ #ifndef GL_EXT_shader_framebuffer_fetch #define GL_EXT_shader_framebuffer_fetch 1 #endif /* GL_EXT_shader_texture_lod */ #ifndef GL_EXT_shader_texture_lod #define GL_EXT_shader_texture_lod 1 #endif /* GL_EXT_shadow_samplers */ #ifndef GL_EXT_shadow_samplers #define GL_EXT_shadow_samplers 1 #endif /* GL_EXT_sRGB */ #ifndef GL_EXT_sRGB #define GL_EXT_sRGB 1 #endif /* GL_EXT_texture_compression_dxt1 */ #ifndef GL_EXT_texture_compression_dxt1 #define GL_EXT_texture_compression_dxt1 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_rg */ #ifndef GL_EXT_texture_rg #define GL_EXT_texture_rg 1 #endif /* GL_EXT_texture_storage */ #ifndef GL_EXT_texture_storage #define GL_EXT_texture_storage 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); GL_APICALL void GL_APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); GL_APICALL void GL_APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); GL_APICALL void GL_APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); #endif typedef void (GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); #endif /* GL_EXT_texture_type_2_10_10_10_REV */ #ifndef GL_EXT_texture_type_2_10_10_10_REV #define GL_EXT_texture_type_2_10_10_10_REV 1 #endif /* GL_EXT_unpack_subimage */ #ifndef GL_EXT_unpack_subimage #define GL_EXT_unpack_subimage 1 #endif /*------------------------------------------------------------------------* * DMP extension functions *------------------------------------------------------------------------*/ /* GL_DMP_shader_binary */ #ifndef GL_DMP_shader_binary #define GL_DMP_shader_binary 1 #endif /*------------------------------------------------------------------------* * FJ extension functions *------------------------------------------------------------------------*/ /* GL_FJ_shader_binary_GCCSO */ #ifndef GL_FJ_shader_binary_GCCSO #define GL_FJ_shader_binary_GCCSO 1 #endif /*------------------------------------------------------------------------* * IMG extension functions *------------------------------------------------------------------------*/ /* GL_IMG_program_binary */ #ifndef GL_IMG_program_binary #define GL_IMG_program_binary 1 #endif /* GL_IMG_read_format */ #ifndef GL_IMG_read_format #define GL_IMG_read_format 1 #endif /* GL_IMG_shader_binary */ #ifndef GL_IMG_shader_binary #define GL_IMG_shader_binary 1 #endif /* GL_IMG_texture_compression_pvrtc */ #ifndef GL_IMG_texture_compression_pvrtc #define GL_IMG_texture_compression_pvrtc 1 #endif /* GL_IMG_texture_compression_pvrtc2 */ #ifndef GL_IMG_texture_compression_pvrtc2 #define GL_IMG_texture_compression_pvrtc2 1 #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_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei); GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); #endif typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); #endif /*------------------------------------------------------------------------* * NV extension functions *------------------------------------------------------------------------*/ /* GL_NV_coverage_sample */ #ifndef GL_NV_coverage_sample #define GL_NV_coverage_sample 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask); GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation); #endif typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask); typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation); #endif /* GL_NV_depth_nonlinear */ #ifndef GL_NV_depth_nonlinear #define GL_NV_depth_nonlinear 1 #endif /* GL_NV_draw_buffers */ #ifndef GL_NV_draw_buffers #define GL_NV_draw_buffers 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs); #endif typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs); #endif /* GL_EXT_draw_buffers */ #ifndef GL_EXT_draw_buffers #define GL_EXT_draw_buffers 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDrawBuffersEXT (GLsizei n, const GLenum *bufs); #endif typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC) (GLsizei n, const GLenum *bufs); #endif /* GL_NV_draw_instanced */ #ifndef GL_NV_draw_instanced #define GL_NV_draw_instanced 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDrawArraysInstancedNV (GLenum mode, GLint first, GLsizei count, GLsizei primcount); GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); #endif typedef void (GL_APIENTRYP PFNDRAWARRAYSINSTANCEDNVPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); typedef void (GL_APIENTRYP PFNDRAWELEMENTSINSTANCEDNVPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); #endif /* GL_NV_fbo_color_attachments */ #ifndef GL_NV_fbo_color_attachments #define GL_NV_fbo_color_attachments 1 #endif /* GL_NV_fence */ #ifndef GL_NV_fence #define GL_NV_fence 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei, GLuint *); GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint); GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint); GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint); GL_APICALL 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 /* GL_NV_framebuffer_blit */ #ifndef GL_NV_framebuffer_blit #define GL_NV_framebuffer_blit 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glBlitFramebufferNV (int srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); #endif typedef void (GL_APIENTRYP PFNBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); #endif /* GL_NV_framebuffer_multisample */ #ifndef GL_NV_framebuffer_multisample #define GL_NV_framebuffer_multisample 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleNV ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #endif typedef void (GL_APIENTRYP PFNRENDERBUFFERSTORAGEMULTISAMPLENVPROC) ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #endif /* GL_NV_generate_mipmap_sRGB */ #ifndef GL_NV_generate_mipmap_sRGB #define GL_NV_generate_mipmap_sRGB 1 #endif /* GL_NV_instanced_arrays */ #ifndef GL_NV_instanced_arrays #define GL_NV_instanced_arrays 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glVertexAttribDivisorNV (GLuint index, GLuint divisor); #endif typedef void (GL_APIENTRYP PFNVERTEXATTRIBDIVISORNVPROC) (GLuint index, GLuint divisor); #endif /* GL_NV_read_buffer */ #ifndef GL_NV_read_buffer #define GL_NV_read_buffer 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode); #endif typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode); #endif /* GL_NV_read_buffer_front */ #ifndef GL_NV_read_buffer_front #define GL_NV_read_buffer_front 1 #endif /* GL_NV_read_depth */ #ifndef GL_NV_read_depth #define GL_NV_read_depth 1 #endif /* GL_NV_read_depth_stencil */ #ifndef GL_NV_read_depth_stencil #define GL_NV_read_depth_stencil 1 #endif /* GL_NV_read_stencil */ #ifndef GL_NV_read_stencil #define GL_NV_read_stencil 1 #endif /* GL_NV_shadow_samplers_array */ #ifndef GL_NV_shadow_samplers_array #define GL_NV_shadow_samplers_array 1 #endif /* GL_NV_shadow_samplers_cube */ #ifndef GL_NV_shadow_samplers_cube #define GL_NV_shadow_samplers_cube 1 #endif /* GL_NV_sRGB_formats */ #ifndef GL_NV_sRGB_formats #define GL_NV_sRGB_formats 1 #endif /* GL_NV_texture_border_clamp */ #ifndef GL_NV_texture_border_clamp #define GL_NV_texture_border_clamp 1 #endif /* GL_NV_texture_compression_s3tc_update */ #ifndef GL_NV_texture_compression_s3tc_update #define GL_NV_texture_compression_s3tc_update 1 #endif /* GL_NV_texture_npot_2D_mipmap */ #ifndef GL_NV_texture_npot_2D_mipmap #define GL_NV_texture_npot_2D_mipmap 1 #endif /*------------------------------------------------------------------------* * QCOM extension functions *------------------------------------------------------------------------*/ /* GL_QCOM_alpha_test */ #ifndef GL_QCOM_alpha_test #define GL_QCOM_alpha_test 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref); #endif typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref); #endif /* GL_QCOM_binning_control */ #ifndef GL_QCOM_binning_control #define GL_QCOM_binning_control 1 #endif /* GL_QCOM_driver_control */ #ifndef GL_QCOM_driver_control #define GL_QCOM_driver_control 1 #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls); GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl); GL_APICALL 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_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures); GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param); GL_APICALL 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_APICALL 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_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders); GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms); GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program); GL_APICALL 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_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); GL_APICALL 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 /*------------------------------------------------------------------------* * VIV extension tokens *------------------------------------------------------------------------*/ /* GL_VIV_shader_binary */ #ifndef GL_VIV_shader_binary #define GL_VIV_shader_binary 1 #endif #ifdef __cplusplus } #endif #endif /* __gl2ext_h_ */ freshplayerplugin-0.3.9/3rdparty/angle/include/GLES2/gl2platform.h000066400000000000000000000016151321746453100247760ustar00rootroot00000000000000#ifndef __gl2platform_h_ #define __gl2platform_h_ /* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -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 2.X gl2.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_APICALL #define GL_APICALL KHRONOS_APICALL #endif #ifndef GL_APIENTRY #define GL_APIENTRY KHRONOS_APIENTRY #endif #endif /* __gl2platform_h_ */ freshplayerplugin-0.3.9/3rdparty/angle/include/GLES3/000077500000000000000000000000001321746453100223725ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/angle/include/GLES3/gl3.h000066400000000000000000002072111321746453100232330ustar00rootroot00000000000000#ifndef __gl3_h_ #define __gl3_h_ /* * gl3.h last updated on $Date: 2013-02-12 14:37:24 -0800 (Tue, 12 Feb 2013) $ */ #include #ifdef __cplusplus extern "C" { #endif /* ** Copyright (c) 2007-2013 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including ** without limitation the rights to use, copy, modify, merge, publish, ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are 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 Materials. ** ** THE MATERIALS ARE 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 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ /*------------------------------------------------------------------------- * Data type definitions *-----------------------------------------------------------------------*/ /* OpenGL ES 2.0 */ 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_intptr_t GLintptr; typedef khronos_ssize_t GLsizeiptr; /* OpenGL ES 3.0 */ typedef unsigned short GLhalf; typedef khronos_int64_t GLint64; typedef khronos_uint64_t GLuint64; typedef struct __GLsync *GLsync; /*------------------------------------------------------------------------- * Token definitions *-----------------------------------------------------------------------*/ /* OpenGL ES core versions */ #define GL_ES_VERSION_3_0 1 #define GL_ES_VERSION_2_0 1 /* OpenGL ES 2.0 */ /* 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 /* 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 */ /* BlendEquationSeparate */ #define GL_FUNC_ADD 0x8006 #define GL_BLEND_EQUATION 0x8009 #define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */ #define GL_BLEND_EQUATION_ALPHA 0x883D /* BlendSubtract */ #define GL_FUNC_SUBTRACT 0x800A #define GL_FUNC_REVERSE_SUBTRACT 0x800B /* Separate Blend Functions */ #define GL_BLEND_DST_RGB 0x80C8 #define GL_BLEND_SRC_RGB 0x80C9 #define GL_BLEND_DST_ALPHA 0x80CA #define GL_BLEND_SRC_ALPHA 0x80CB #define GL_CONSTANT_COLOR 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 #define GL_CONSTANT_ALPHA 0x8003 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 #define GL_BLEND_COLOR 0x8005 /* 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_STREAM_DRAW 0x88E0 #define GL_STATIC_DRAW 0x88E4 #define GL_DYNAMIC_DRAW 0x88E8 #define GL_BUFFER_SIZE 0x8764 #define GL_BUFFER_USAGE 0x8765 #define GL_CURRENT_VERTEX_ATTRIB 0x8626 /* 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_TEXTURE_2D 0x0DE1 #define GL_CULL_FACE 0x0B44 #define GL_BLEND 0x0BE2 #define GL_DITHER 0x0BD0 #define GL_STENCIL_TEST 0x0B90 #define GL_DEPTH_TEST 0x0B71 #define GL_SCISSOR_TEST 0x0C11 #define GL_POLYGON_OFFSET_FILL 0x8037 #define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E #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_OUT_OF_MEMORY 0x0505 /* FrontFaceDirection */ #define GL_CW 0x0900 #define GL_CCW 0x0901 /* GetPName */ #define GL_LINE_WIDTH 0x0B21 #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_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_FAIL 0x0B94 #define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 #define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 #define GL_STENCIL_REF 0x0B97 #define GL_STENCIL_VALUE_MASK 0x0B93 #define GL_STENCIL_WRITEMASK 0x0B98 #define GL_STENCIL_BACK_FUNC 0x8800 #define GL_STENCIL_BACK_FAIL 0x8801 #define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 #define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 #define GL_STENCIL_BACK_REF 0x8CA3 #define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 #define GL_STENCIL_BACK_WRITEMASK 0x8CA5 #define GL_VIEWPORT 0x0BA2 #define GL_SCISSOR_BOX 0x0C10 /* GL_SCISSOR_TEST */ #define GL_COLOR_CLEAR_VALUE 0x0C22 #define GL_COLOR_WRITEMASK 0x0C23 #define GL_UNPACK_ALIGNMENT 0x0CF5 #define GL_PACK_ALIGNMENT 0x0D05 #define GL_MAX_TEXTURE_SIZE 0x0D33 #define GL_MAX_VIEWPORT_DIMS 0x0D3A #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 /* GL_POLYGON_OFFSET_FILL */ #define GL_POLYGON_OFFSET_FACTOR 0x8038 #define GL_TEXTURE_BINDING_2D 0x8069 #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_GENERATE_MIPMAP_HINT 0x8192 /* DataType */ #define GL_BYTE 0x1400 #define GL_UNSIGNED_BYTE 0x1401 #define GL_SHORT 0x1402 #define GL_UNSIGNED_SHORT 0x1403 #define GL_INT 0x1404 #define GL_UNSIGNED_INT 0x1405 #define GL_FLOAT 0x1406 #define GL_FIXED 0x140C /* PixelFormat */ #define GL_DEPTH_COMPONENT 0x1902 #define GL_ALPHA 0x1906 #define GL_RGB 0x1907 #define GL_RGBA 0x1908 #define GL_LUMINANCE 0x1909 #define GL_LUMINANCE_ALPHA 0x190A /* 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 /* Shaders */ #define GL_FRAGMENT_SHADER 0x8B30 #define GL_VERTEX_SHADER 0x8B31 #define GL_MAX_VERTEX_ATTRIBS 0x8869 #define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB #define GL_MAX_VARYING_VECTORS 0x8DFC #define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D #define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C #define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 #define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD #define GL_SHADER_TYPE 0x8B4F #define GL_DELETE_STATUS 0x8B80 #define GL_LINK_STATUS 0x8B82 #define GL_VALIDATE_STATUS 0x8B83 #define GL_ATTACHED_SHADERS 0x8B85 #define GL_ACTIVE_UNIFORMS 0x8B86 #define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 #define GL_ACTIVE_ATTRIBUTES 0x8B89 #define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A #define GL_SHADING_LANGUAGE_VERSION 0x8B8C #define GL_CURRENT_PROGRAM 0x8B8D /* StencilFunction */ #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 /* StencilOp */ /* GL_ZERO */ #define GL_KEEP 0x1E00 #define GL_REPLACE 0x1E01 #define GL_INCR 0x1E02 #define GL_DECR 0x1E03 #define GL_INVERT 0x150A #define GL_INCR_WRAP 0x8507 #define GL_DECR_WRAP 0x8508 /* StringName */ #define GL_VENDOR 0x1F00 #define GL_RENDERER 0x1F01 #define GL_VERSION 0x1F02 #define GL_EXTENSIONS 0x1F03 /* 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 /* TextureTarget */ /* GL_TEXTURE_2D */ #define GL_TEXTURE 0x1702 #define GL_TEXTURE_CUBE_MAP 0x8513 #define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A #define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C /* 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 /* TextureWrapMode */ #define GL_REPEAT 0x2901 #define GL_CLAMP_TO_EDGE 0x812F #define GL_MIRRORED_REPEAT 0x8370 /* Uniform Types */ #define GL_FLOAT_VEC2 0x8B50 #define GL_FLOAT_VEC3 0x8B51 #define GL_FLOAT_VEC4 0x8B52 #define GL_INT_VEC2 0x8B53 #define GL_INT_VEC3 0x8B54 #define GL_INT_VEC4 0x8B55 #define GL_BOOL 0x8B56 #define GL_BOOL_VEC2 0x8B57 #define GL_BOOL_VEC3 0x8B58 #define GL_BOOL_VEC4 0x8B59 #define GL_FLOAT_MAT2 0x8B5A #define GL_FLOAT_MAT3 0x8B5B #define GL_FLOAT_MAT4 0x8B5C #define GL_SAMPLER_2D 0x8B5E #define GL_SAMPLER_CUBE 0x8B60 /* Vertex Arrays */ #define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 #define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 #define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 #define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A #define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F /* Read Format */ #define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A #define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B /* Shader Source */ #define GL_COMPILE_STATUS 0x8B81 #define GL_INFO_LOG_LENGTH 0x8B84 #define GL_SHADER_SOURCE_LENGTH 0x8B88 #define GL_SHADER_COMPILER 0x8DFA /* Shader Binary */ #define GL_SHADER_BINARY_FORMATS 0x8DF8 #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 /* Shader Precision-Specified Types */ #define GL_LOW_FLOAT 0x8DF0 #define GL_MEDIUM_FLOAT 0x8DF1 #define GL_HIGH_FLOAT 0x8DF2 #define GL_LOW_INT 0x8DF3 #define GL_MEDIUM_INT 0x8DF4 #define GL_HIGH_INT 0x8DF5 /* Framebuffer Object. */ #define GL_FRAMEBUFFER 0x8D40 #define GL_RENDERBUFFER 0x8D41 #define GL_RGBA4 0x8056 #define GL_RGB5_A1 0x8057 #define GL_RGB565 0x8D62 #define GL_DEPTH_COMPONENT16 0x81A5 #define GL_STENCIL_INDEX8 0x8D48 #define GL_RENDERBUFFER_WIDTH 0x8D42 #define GL_RENDERBUFFER_HEIGHT 0x8D43 #define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 #define GL_RENDERBUFFER_RED_SIZE 0x8D50 #define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 #define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 #define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 #define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 #define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 #define GL_COLOR_ATTACHMENT0 0x8CE0 #define GL_DEPTH_ATTACHMENT 0x8D00 #define GL_STENCIL_ATTACHMENT 0x8D20 #define GL_NONE 0 #define GL_FRAMEBUFFER_COMPLETE 0x8CD5 #define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 #define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 #define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 #define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD #define GL_FRAMEBUFFER_BINDING 0x8CA6 #define GL_RENDERBUFFER_BINDING 0x8CA7 #define GL_MAX_RENDERBUFFER_SIZE 0x84E8 #define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 /* OpenGL ES 3.0 */ #define GL_READ_BUFFER 0x0C02 #define GL_UNPACK_ROW_LENGTH 0x0CF2 #define GL_UNPACK_SKIP_ROWS 0x0CF3 #define GL_UNPACK_SKIP_PIXELS 0x0CF4 #define GL_PACK_ROW_LENGTH 0x0D02 #define GL_PACK_SKIP_ROWS 0x0D03 #define GL_PACK_SKIP_PIXELS 0x0D04 #define GL_COLOR 0x1800 #define GL_DEPTH 0x1801 #define GL_STENCIL 0x1802 #define GL_RED 0x1903 #define GL_RGB8 0x8051 #define GL_RGBA8 0x8058 #define GL_RGB10_A2 0x8059 #define GL_TEXTURE_BINDING_3D 0x806A #define GL_UNPACK_SKIP_IMAGES 0x806D #define GL_UNPACK_IMAGE_HEIGHT 0x806E #define GL_TEXTURE_3D 0x806F #define GL_TEXTURE_WRAP_R 0x8072 #define GL_MAX_3D_TEXTURE_SIZE 0x8073 #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 #define GL_MAX_ELEMENTS_VERTICES 0x80E8 #define GL_MAX_ELEMENTS_INDICES 0x80E9 #define GL_TEXTURE_MIN_LOD 0x813A #define GL_TEXTURE_MAX_LOD 0x813B #define GL_TEXTURE_BASE_LEVEL 0x813C #define GL_TEXTURE_MAX_LEVEL 0x813D #define GL_MIN 0x8007 #define GL_MAX 0x8008 #define GL_DEPTH_COMPONENT24 0x81A6 #define GL_MAX_TEXTURE_LOD_BIAS 0x84FD #define GL_TEXTURE_COMPARE_MODE 0x884C #define GL_TEXTURE_COMPARE_FUNC 0x884D #define GL_CURRENT_QUERY 0x8865 #define GL_QUERY_RESULT 0x8866 #define GL_QUERY_RESULT_AVAILABLE 0x8867 #define GL_BUFFER_MAPPED 0x88BC #define GL_BUFFER_MAP_POINTER 0x88BD #define GL_STREAM_READ 0x88E1 #define GL_STREAM_COPY 0x88E2 #define GL_STATIC_READ 0x88E5 #define GL_STATIC_COPY 0x88E6 #define GL_DYNAMIC_READ 0x88E9 #define GL_DYNAMIC_COPY 0x88EA #define GL_MAX_DRAW_BUFFERS 0x8824 #define GL_DRAW_BUFFER0 0x8825 #define GL_DRAW_BUFFER1 0x8826 #define GL_DRAW_BUFFER2 0x8827 #define GL_DRAW_BUFFER3 0x8828 #define GL_DRAW_BUFFER4 0x8829 #define GL_DRAW_BUFFER5 0x882A #define GL_DRAW_BUFFER6 0x882B #define GL_DRAW_BUFFER7 0x882C #define GL_DRAW_BUFFER8 0x882D #define GL_DRAW_BUFFER9 0x882E #define GL_DRAW_BUFFER10 0x882F #define GL_DRAW_BUFFER11 0x8830 #define GL_DRAW_BUFFER12 0x8831 #define GL_DRAW_BUFFER13 0x8832 #define GL_DRAW_BUFFER14 0x8833 #define GL_DRAW_BUFFER15 0x8834 #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 #define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A #define GL_SAMPLER_3D 0x8B5F #define GL_SAMPLER_2D_SHADOW 0x8B62 #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B #define GL_PIXEL_PACK_BUFFER 0x88EB #define GL_PIXEL_UNPACK_BUFFER 0x88EC #define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED #define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF #define GL_FLOAT_MAT2x3 0x8B65 #define GL_FLOAT_MAT2x4 0x8B66 #define GL_FLOAT_MAT3x2 0x8B67 #define GL_FLOAT_MAT3x4 0x8B68 #define GL_FLOAT_MAT4x2 0x8B69 #define GL_FLOAT_MAT4x3 0x8B6A #define GL_SRGB 0x8C40 #define GL_SRGB8 0x8C41 #define GL_SRGB8_ALPHA8 0x8C43 #define GL_COMPARE_REF_TO_TEXTURE 0x884E #define GL_MAJOR_VERSION 0x821B #define GL_MINOR_VERSION 0x821C #define GL_NUM_EXTENSIONS 0x821D #define GL_RGBA32F 0x8814 #define GL_RGB32F 0x8815 #define GL_RGBA16F 0x881A #define GL_RGB16F 0x881B #define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD #define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF #define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 #define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 #define GL_MAX_VARYING_COMPONENTS 0x8B4B #define GL_TEXTURE_2D_ARRAY 0x8C1A #define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D #define GL_R11F_G11F_B10F 0x8C3A #define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B #define GL_RGB9_E5 0x8C3D #define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E #define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 #define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 #define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 #define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 #define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 #define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 #define GL_RASTERIZER_DISCARD 0x8C89 #define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B #define GL_INTERLEAVED_ATTRIBS 0x8C8C #define GL_SEPARATE_ATTRIBS 0x8C8D #define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E #define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F #define GL_RGBA32UI 0x8D70 #define GL_RGB32UI 0x8D71 #define GL_RGBA16UI 0x8D76 #define GL_RGB16UI 0x8D77 #define GL_RGBA8UI 0x8D7C #define GL_RGB8UI 0x8D7D #define GL_RGBA32I 0x8D82 #define GL_RGB32I 0x8D83 #define GL_RGBA16I 0x8D88 #define GL_RGB16I 0x8D89 #define GL_RGBA8I 0x8D8E #define GL_RGB8I 0x8D8F #define GL_RED_INTEGER 0x8D94 #define GL_RGB_INTEGER 0x8D98 #define GL_RGBA_INTEGER 0x8D99 #define GL_SAMPLER_2D_ARRAY 0x8DC1 #define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 #define GL_SAMPLER_CUBE_SHADOW 0x8DC5 #define GL_UNSIGNED_INT_VEC2 0x8DC6 #define GL_UNSIGNED_INT_VEC3 0x8DC7 #define GL_UNSIGNED_INT_VEC4 0x8DC8 #define GL_INT_SAMPLER_2D 0x8DCA #define GL_INT_SAMPLER_3D 0x8DCB #define GL_INT_SAMPLER_CUBE 0x8DCC #define GL_INT_SAMPLER_2D_ARRAY 0x8DCF #define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 #define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 #define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 #define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 #define GL_BUFFER_ACCESS_FLAGS 0x911F #define GL_BUFFER_MAP_LENGTH 0x9120 #define GL_BUFFER_MAP_OFFSET 0x9121 #define GL_DEPTH_COMPONENT32F 0x8CAC #define GL_DEPTH32F_STENCIL8 0x8CAD #define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD #define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 #define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 #define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 #define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 #define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 #define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 #define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 #define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 #define GL_FRAMEBUFFER_DEFAULT 0x8218 #define GL_FRAMEBUFFER_UNDEFINED 0x8219 #define GL_DEPTH_STENCIL_ATTACHMENT 0x821A #define GL_DEPTH_STENCIL 0x84F9 #define GL_UNSIGNED_INT_24_8 0x84FA #define GL_DEPTH24_STENCIL8 0x88F0 #define GL_UNSIGNED_NORMALIZED 0x8C17 #define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING #define GL_READ_FRAMEBUFFER 0x8CA8 #define GL_DRAW_FRAMEBUFFER 0x8CA9 #define GL_READ_FRAMEBUFFER_BINDING 0x8CAA #define GL_RENDERBUFFER_SAMPLES 0x8CAB #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 #define GL_MAX_COLOR_ATTACHMENTS 0x8CDF #define GL_COLOR_ATTACHMENT1 0x8CE1 #define GL_COLOR_ATTACHMENT2 0x8CE2 #define GL_COLOR_ATTACHMENT3 0x8CE3 #define GL_COLOR_ATTACHMENT4 0x8CE4 #define GL_COLOR_ATTACHMENT5 0x8CE5 #define GL_COLOR_ATTACHMENT6 0x8CE6 #define GL_COLOR_ATTACHMENT7 0x8CE7 #define GL_COLOR_ATTACHMENT8 0x8CE8 #define GL_COLOR_ATTACHMENT9 0x8CE9 #define GL_COLOR_ATTACHMENT10 0x8CEA #define GL_COLOR_ATTACHMENT11 0x8CEB #define GL_COLOR_ATTACHMENT12 0x8CEC #define GL_COLOR_ATTACHMENT13 0x8CED #define GL_COLOR_ATTACHMENT14 0x8CEE #define GL_COLOR_ATTACHMENT15 0x8CEF #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 #define GL_MAX_SAMPLES 0x8D57 #define GL_HALF_FLOAT 0x140B #define GL_MAP_READ_BIT 0x0001 #define GL_MAP_WRITE_BIT 0x0002 #define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 #define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 #define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 #define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 #define GL_RG 0x8227 #define GL_RG_INTEGER 0x8228 #define GL_R8 0x8229 #define GL_RG8 0x822B #define GL_R16F 0x822D #define GL_R32F 0x822E #define GL_RG16F 0x822F #define GL_RG32F 0x8230 #define GL_R8I 0x8231 #define GL_R8UI 0x8232 #define GL_R16I 0x8233 #define GL_R16UI 0x8234 #define GL_R32I 0x8235 #define GL_R32UI 0x8236 #define GL_RG8I 0x8237 #define GL_RG8UI 0x8238 #define GL_RG16I 0x8239 #define GL_RG16UI 0x823A #define GL_RG32I 0x823B #define GL_RG32UI 0x823C #define GL_VERTEX_ARRAY_BINDING 0x85B5 #define GL_R8_SNORM 0x8F94 #define GL_RG8_SNORM 0x8F95 #define GL_RGB8_SNORM 0x8F96 #define GL_RGBA8_SNORM 0x8F97 #define GL_SIGNED_NORMALIZED 0x8F9C #define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 #define GL_COPY_READ_BUFFER 0x8F36 #define GL_COPY_WRITE_BUFFER 0x8F37 #define GL_COPY_READ_BUFFER_BINDING GL_COPY_READ_BUFFER #define GL_COPY_WRITE_BUFFER_BINDING GL_COPY_WRITE_BUFFER #define GL_UNIFORM_BUFFER 0x8A11 #define GL_UNIFORM_BUFFER_BINDING 0x8A28 #define GL_UNIFORM_BUFFER_START 0x8A29 #define GL_UNIFORM_BUFFER_SIZE 0x8A2A #define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B #define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D #define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E #define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F #define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 #define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 #define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 #define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 #define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 #define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 #define GL_UNIFORM_TYPE 0x8A37 #define GL_UNIFORM_SIZE 0x8A38 #define GL_UNIFORM_NAME_LENGTH 0x8A39 #define GL_UNIFORM_BLOCK_INDEX 0x8A3A #define GL_UNIFORM_OFFSET 0x8A3B #define GL_UNIFORM_ARRAY_STRIDE 0x8A3C #define GL_UNIFORM_MATRIX_STRIDE 0x8A3D #define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E #define GL_UNIFORM_BLOCK_BINDING 0x8A3F #define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 #define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 #define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 #define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 #define GL_INVALID_INDEX 0xFFFFFFFFu #define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 #define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 #define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 #define GL_OBJECT_TYPE 0x9112 #define GL_SYNC_CONDITION 0x9113 #define GL_SYNC_STATUS 0x9114 #define GL_SYNC_FLAGS 0x9115 #define GL_SYNC_FENCE 0x9116 #define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 #define GL_UNSIGNALED 0x9118 #define GL_SIGNALED 0x9119 #define GL_ALREADY_SIGNALED 0x911A #define GL_TIMEOUT_EXPIRED 0x911B #define GL_CONDITION_SATISFIED 0x911C #define GL_WAIT_FAILED 0x911D #define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 #define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE #define GL_ANY_SAMPLES_PASSED 0x8C2F #define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A #define GL_SAMPLER_BINDING 0x8919 #define GL_RGB10_A2UI 0x906F #define GL_TEXTURE_SWIZZLE_R 0x8E42 #define GL_TEXTURE_SWIZZLE_G 0x8E43 #define GL_TEXTURE_SWIZZLE_B 0x8E44 #define GL_TEXTURE_SWIZZLE_A 0x8E45 #define GL_GREEN 0x1904 #define GL_BLUE 0x1905 #define GL_INT_2_10_10_10_REV 0x8D9F #define GL_TRANSFORM_FEEDBACK 0x8E22 #define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 #define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 #define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 #define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 #define GL_PROGRAM_BINARY_LENGTH 0x8741 #define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE #define GL_PROGRAM_BINARY_FORMATS 0x87FF #define GL_COMPRESSED_R11_EAC 0x9270 #define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 #define GL_COMPRESSED_RG11_EAC 0x9272 #define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 #define GL_COMPRESSED_RGB8_ETC2 0x9274 #define GL_COMPRESSED_SRGB8_ETC2 0x9275 #define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 #define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 #define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 #define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 #define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F #define GL_MAX_ELEMENT_INDEX 0x8D6B #define GL_NUM_SAMPLE_COUNTS 0x9380 #define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF /*------------------------------------------------------------------------- * Entrypoint definitions *-----------------------------------------------------------------------*/ /* OpenGL ES 2.0 */ GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name); GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); GL_APICALL void GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); GL_APICALL void GL_APIENTRY glBlendEquation (GLenum mode); GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat depth); GL_APICALL void GL_APIENTRY glClearStencil (GLint s); GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data); GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers); GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers); GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers); GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures); GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); GL_APICALL void GL_APIENTRY glDepthRangef (GLfloat n, GLfloat f); GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); GL_APICALL void GL_APIENTRY glDisable (GLenum cap); GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); GL_APICALL void GL_APIENTRY glEnable (GLenum cap); GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); GL_APICALL void GL_APIENTRY glFinish (void); GL_APICALL void GL_APIENTRY glFlush (void); GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers); GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers); GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers); GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures); GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params); GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params); GL_APICALL GLenum GL_APIENTRY glGetError (void); GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params); GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog); GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name); GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params); GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params); GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params); GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params); GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer); GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length); GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length); GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params); GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params); GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x); GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v); GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x); GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v); GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y); GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v); GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y); GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v); GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z); GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v); GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z); GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v); GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v); GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w); GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v); GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x); GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values); GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y); GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values); GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z); GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values); GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values); GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr); GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); /* OpenGL ES 3.0 */ GL_APICALL void GL_APIENTRY glReadBuffer (GLenum mode); GL_APICALL void GL_APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices); GL_APICALL void GL_APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); GL_APICALL void GL_APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); GL_APICALL void GL_APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); GL_APICALL void GL_APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); GL_APICALL void GL_APIENTRY glGenQueries (GLsizei n, GLuint* ids); GL_APICALL void GL_APIENTRY glDeleteQueries (GLsizei n, const GLuint* ids); GL_APICALL GLboolean GL_APIENTRY glIsQuery (GLuint id); GL_APICALL void GL_APIENTRY glBeginQuery (GLenum target, GLuint id); GL_APICALL void GL_APIENTRY glEndQuery (GLenum target); GL_APICALL void GL_APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint* params); GL_APICALL GLboolean GL_APIENTRY glUnmapBuffer (GLenum target); GL_APICALL void GL_APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid** params); GL_APICALL void GL_APIENTRY glDrawBuffers (GLsizei n, const GLenum* bufs); GL_APICALL void GL_APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); GL_APICALL void GL_APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); GL_APICALL void GL_APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); GL_APICALL void GL_APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); GL_APICALL void GL_APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); GL_APICALL void GL_APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); GL_APICALL void GL_APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); GL_APICALL GLvoid* GL_APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); GL_APICALL void GL_APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); GL_APICALL void GL_APIENTRY glBindVertexArray (GLuint array); GL_APICALL void GL_APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint* arrays); GL_APICALL void GL_APIENTRY glGenVertexArrays (GLsizei n, GLuint* arrays); GL_APICALL GLboolean GL_APIENTRY glIsVertexArray (GLuint array); GL_APICALL void GL_APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint* data); GL_APICALL void GL_APIENTRY glBeginTransformFeedback (GLenum primitiveMode); GL_APICALL void GL_APIENTRY glEndTransformFeedback (void); GL_APICALL void GL_APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); GL_APICALL void GL_APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); GL_APICALL void GL_APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode); GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name); GL_APICALL void GL_APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); GL_APICALL void GL_APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint* params); GL_APICALL void GL_APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); GL_APICALL void GL_APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); GL_APICALL void GL_APIENTRY glVertexAttribI4iv (GLuint index, const GLint* v); GL_APICALL void GL_APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint* v); GL_APICALL void GL_APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint* params); GL_APICALL GLint GL_APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); GL_APICALL void GL_APIENTRY glUniform1ui (GLint location, GLuint v0); GL_APICALL void GL_APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); GL_APICALL void GL_APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); GL_APICALL void GL_APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); GL_APICALL void GL_APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint* value); GL_APICALL void GL_APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint* value); GL_APICALL void GL_APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint* value); GL_APICALL void GL_APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint* value); GL_APICALL void GL_APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint* value); GL_APICALL void GL_APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint* value); GL_APICALL void GL_APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat* value); GL_APICALL void GL_APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); GL_APICALL const GLubyte* GL_APIENTRY glGetStringi (GLenum name, GLuint index); GL_APICALL void GL_APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); GL_APICALL void GL_APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices); GL_APICALL void GL_APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params); GL_APICALL GLuint GL_APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar* uniformBlockName); GL_APICALL void GL_APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName); GL_APICALL void GL_APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); GL_APICALL void GL_APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instanceCount); GL_APICALL void GL_APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount); GL_APICALL GLsync GL_APIENTRY glFenceSync (GLenum condition, GLbitfield flags); GL_APICALL GLboolean GL_APIENTRY glIsSync (GLsync sync); GL_APICALL void GL_APIENTRY glDeleteSync (GLsync sync); GL_APICALL GLenum GL_APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); GL_APICALL void GL_APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); GL_APICALL void GL_APIENTRY glGetInteger64v (GLenum pname, GLint64* params); GL_APICALL void GL_APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values); GL_APICALL void GL_APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64* data); GL_APICALL void GL_APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64* params); GL_APICALL void GL_APIENTRY glGenSamplers (GLsizei count, GLuint* samplers); GL_APICALL void GL_APIENTRY glDeleteSamplers (GLsizei count, const GLuint* samplers); GL_APICALL GLboolean GL_APIENTRY glIsSampler (GLuint sampler); GL_APICALL void GL_APIENTRY glBindSampler (GLuint unit, GLuint sampler); GL_APICALL void GL_APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); GL_APICALL void GL_APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint* param); GL_APICALL void GL_APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); GL_APICALL void GL_APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat* param); GL_APICALL void GL_APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat* params); GL_APICALL void GL_APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); GL_APICALL void GL_APIENTRY glBindTransformFeedback (GLenum target, GLuint id); GL_APICALL void GL_APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint* ids); GL_APICALL void GL_APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint* ids); GL_APICALL GLboolean GL_APIENTRY glIsTransformFeedback (GLuint id); GL_APICALL void GL_APIENTRY glPauseTransformFeedback (void); GL_APICALL void GL_APIENTRY glResumeTransformFeedback (void); GL_APICALL void GL_APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary); GL_APICALL void GL_APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length); GL_APICALL void GL_APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); GL_APICALL void GL_APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum* attachments); GL_APICALL void GL_APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); GL_APICALL void GL_APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params); #ifdef __cplusplus } #endif #endif freshplayerplugin-0.3.9/3rdparty/angle/include/GLES3/gl3ext.h000066400000000000000000000013451321746453100237540ustar00rootroot00000000000000#ifndef __gl3ext_h_ #define __gl3ext_h_ /* $Revision: 17809 $ on $Date:: 2012-05-14 08:03:36 -0700 #$ */ /* * This document is licensed under the SGI Free Software B License Version * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . */ /* OpenGL ES 3 Extensions * * After an OES extension's interactions with OpenGl ES 3.0 have been documented, * its tokens and function definitions should be added to this file in a manner * that does not conflict with gl2ext.h or gl3.h. * * Tokens and function definitions for extensions that have become standard * features in OpenGL ES 3.0 will not be added to this file. * * Applications using OpenGL-ES-2-only extensions should include gl2ext.h */ #endif /* __gl3ext_h_ */ freshplayerplugin-0.3.9/3rdparty/angle/include/GLES3/gl3platform.h000066400000000000000000000016151321746453100250000ustar00rootroot00000000000000#ifndef __gl3platform_h_ #define __gl3platform_h_ /* $Revision: 18437 $ on $Date:: 2012-07-08 23:31:39 -0700 #$ */ /* * 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 3.X gl3.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_APICALL #define GL_APICALL KHRONOS_APICALL #endif #ifndef GL_APIENTRY #define GL_APIENTRY KHRONOS_APIENTRY #endif #endif /* __gl3platform_h_ */ freshplayerplugin-0.3.9/3rdparty/angle/include/GLSLANG/000077500000000000000000000000001321746453100226445ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/angle/include/GLSLANG/ShaderLang.h000066400000000000000000000154611321746453100250340ustar00rootroot00000000000000// // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef GLSLANG_SHADERLANG_H_ #define GLSLANG_SHADERLANG_H_ #if defined(COMPONENT_BUILD) && !defined(ANGLE_TRANSLATOR_STATIC) #if defined(_WIN32) || defined(_WIN64) #if defined(ANGLE_TRANSLATOR_IMPLEMENTATION) #define COMPILER_EXPORT __declspec(dllexport) #else #define COMPILER_EXPORT __declspec(dllimport) #endif // defined(ANGLE_TRANSLATOR_IMPLEMENTATION) #else // defined(_WIN32) || defined(_WIN64) #define COMPILER_EXPORT __attribute__((visibility("default"))) #endif #else // defined(COMPONENT_BUILD) && !defined(ANGLE_TRANSLATOR_STATIC) #define COMPILER_EXPORT #endif #include #include "KHR/khrplatform.h" #include #include #include // // This is the platform independent interface between an OGL driver // and the shading language compiler. // namespace sh { // GLenum alias typedef unsigned int GLenum; } // Version number for shader translation API. // It is incremented every time the API changes. #define ANGLE_SH_VERSION 139 typedef enum { SH_GLES2_SPEC = 0x8B40, } ShShaderSpec; typedef enum { // SH_GLSL_OUTPUT is deprecated. This is to not break the build. SH_GLSL_OUTPUT = 0x8B46, SH_GLSL_COMPATIBILITY_OUTPUT = 0x8B46, } ShShaderOutput; // Compile options. typedef enum { SH_OBJECT_CODE = 0x0004, } ShCompileOptions; // // Driver must call this first, once, before doing any other // compiler operations. // If the function succeeds, the return value is true, else false. // COMPILER_EXPORT bool ShInitialize(); // // Driver should call this at shutdown. // If the function succeeds, the return value is true, else false. // COMPILER_EXPORT bool ShFinalize(); // The 64 bits hash function. The first parameter is the input string; the // second parameter is the string length. typedef khronos_uint64_t (*ShHashFunction64)(const char*, size_t); // // Implementation dependent built-in resources (constants and extensions). // The names for these resources has been obtained by stripping gl_/GL_. // typedef struct { // Constants. int MaxVertexAttribs; int MaxVertexUniformVectors; int MaxVaryingVectors; int MaxVertexTextureImageUnits; int MaxCombinedTextureImageUnits; int MaxTextureImageUnits; int MaxFragmentUniformVectors; int MaxDrawBuffers; // Extensions. // Set to 1 to enable the extension, else 0. int OES_standard_derivatives; int OES_EGL_image_external; int ARB_texture_rectangle; int EXT_blend_func_extended; int EXT_draw_buffers; int EXT_frag_depth; int EXT_shader_texture_lod; int WEBGL_debug_shader_precision; int EXT_shader_framebuffer_fetch; int NV_shader_framebuffer_fetch; int ARM_shader_framebuffer_fetch; // Set to 1 to enable replacing GL_EXT_draw_buffers #extension directives // with GL_NV_draw_buffers in ESSL output. This flag can be used to emulate // EXT_draw_buffers by using it in combination with GLES3.0 glDrawBuffers // function. This applies to Tegra K1 devices. int NV_draw_buffers; // Set to 1 if highp precision is supported in the fragment language. // Default is 0. int FragmentPrecisionHigh; // GLSL ES 3.0 constants. int MaxVertexOutputVectors; int MaxFragmentInputVectors; int MinProgramTexelOffset; int MaxProgramTexelOffset; // Extension constants. // Value of GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT for OpenGL ES output context. // Value of GL_MAX_DUAL_SOURCE_DRAW_BUFFERS for OpenGL output context. // GLES SL version 100 gl_MaxDualSourceDrawBuffersEXT value for EXT_blend_func_extended. int MaxDualSourceDrawBuffers; // Name Hashing. // Set a 64 bit hash function to enable user-defined name hashing. // Default is NULL. ShHashFunction64 HashFunction; // The maximum complexity an expression can be. int MaxExpressionComplexity; // The maximum depth a call stack can be. int MaxCallStackDepth; } ShBuiltInResources; // // Initialize built-in resources with minimum expected values. // Parameters: // resources: The object to initialize. Will be comparable with memcmp. // COMPILER_EXPORT void ShInitBuiltInResources(ShBuiltInResources *resources); // // ShHandle held by but opaque to the driver. It is allocated, // managed, and de-allocated by the compiler. Its contents // are defined by and used by the compiler. // // If handle creation fails, 0 will be returned. // typedef void *ShHandle; // // Returns the a concatenated list of the items in ShBuiltInResources as a // null-terminated string. // This function must be updated whenever ShBuiltInResources is changed. // Parameters: // handle: Specifies the handle of the compiler to be used. COMPILER_EXPORT const std::string &ShGetBuiltInResourcesString(const ShHandle handle); // // Driver calls these to create and destroy compiler objects. // // Returns the handle of constructed compiler, null if the requested compiler is // not supported. // Parameters: // type: Specifies the type of shader - GL_FRAGMENT_SHADER or GL_VERTEX_SHADER. // spec: Specifies the language spec the compiler must conform to SH_GLES2_SPEC // output: Specifies the output code type - SH_GLSL_OUTPUT // resources: Specifies the built-in resources. COMPILER_EXPORT ShHandle ShConstructCompiler( sh::GLenum type, ShShaderSpec spec, ShShaderOutput output, const ShBuiltInResources *resources); COMPILER_EXPORT void ShDestruct(ShHandle handle); // // Compiles the given shader source. // If the function succeeds, the return value is true, else false. // Parameters: // handle: Specifies the handle of compiler to be used. // shaderStrings: Specifies an array of pointers to null-terminated strings // containing the shader source code. // numStrings: Specifies the number of elements in shaderStrings array. // compileOptions: A mask containing the following parameters: // SH_VALIDATE: Validates shader to ensure that it conforms to the spec // specified during compiler construction. // SH_OBJECT_CODE: Translates intermediate tree to glsl or hlsl shader. // Can be queried by calling ShGetObjectCode(). // COMPILER_EXPORT bool ShCompile( const ShHandle handle, const char * const shaderStrings[], size_t numStrings, int compileOptions); // Clears the results from the previous compilation. COMPILER_EXPORT void ShClearResults(const ShHandle handle); // Return the currently set language output type. COMPILER_EXPORT ShShaderOutput ShGetShaderOutputType( const ShHandle handle); // Returns null-terminated object code for a compiled shader. // Parameters: // handle: Specifies the compiler COMPILER_EXPORT const std::string &ShGetObjectCode(const ShHandle handle); #endif // GLSLANG_SHADERLANG_H_ freshplayerplugin-0.3.9/3rdparty/angle/include/KHR/000077500000000000000000000000001321746453100222015ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/angle/include/KHR/khrplatform.h000066400000000000000000000234461321746453100247140ustar00rootroot00000000000000#ifndef __khrplatform_h_ #define __khrplatform_h_ /* ** Copyright (c) 2008-2009 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including ** without limitation the rights to use, copy, modify, merge, publish, ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are 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 Materials. ** ** THE MATERIALS ARE 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 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ /* Khronos platform-specific types and definitions. * * $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $ * * Adopters may modify this file to suit their platform. Adopters are * encouraged to submit platform specific 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 * "Khronos (general)" component "Registry". * * A predefined template which fills in some of the bug fields can be * reached using http://tinyurl.com/khrplatform-h-bugreport, but you * must create a Bugzilla login first. * * * See the Implementer's Guidelines for information about where this file * should be located on your system and for more details of its use: * http://www.khronos.org/registry/implementers_guide.pdf * * This file should be included as * #include * by Khronos client API header files that use its types and defines. * * The types in khrplatform.h should only be used to define API-specific types. * * Types defined in khrplatform.h: * khronos_int8_t signed 8 bit * khronos_uint8_t unsigned 8 bit * khronos_int16_t signed 16 bit * khronos_uint16_t unsigned 16 bit * khronos_int32_t signed 32 bit * khronos_uint32_t unsigned 32 bit * khronos_int64_t signed 64 bit * khronos_uint64_t unsigned 64 bit * khronos_intptr_t signed same number of bits as a pointer * khronos_uintptr_t unsigned same number of bits as a pointer * khronos_ssize_t signed size * khronos_usize_t unsigned size * khronos_float_t signed 32 bit floating point * khronos_time_ns_t unsigned 64 bit time in nanoseconds * khronos_utime_nanoseconds_t unsigned time interval or absolute time in * nanoseconds * khronos_stime_nanoseconds_t signed time interval in nanoseconds * khronos_boolean_enum_t enumerated boolean type. This should * only be used as a base type when a client API's boolean type is * an enum. Client APIs which use an integer or other type for * booleans cannot use this as the base type for their boolean. * * Tokens defined in khrplatform.h: * * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. * * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. * * Calling convention macros defined in this file: * KHRONOS_APICALL * KHRONOS_APIENTRY * KHRONOS_APIATTRIBUTES * * These may be used in function prototypes as: * * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( * int arg1, * int arg2) KHRONOS_APIATTRIBUTES; */ /*------------------------------------------------------------------------- * Definition of KHRONOS_APICALL *------------------------------------------------------------------------- * This precedes the return type of the function in the function prototype. */ #if defined(_WIN32) && !defined(__SCITECH_SNAP__) # define KHRONOS_APICALL __declspec(dllimport) #elif defined (__SYMBIAN32__) # define KHRONOS_APICALL IMPORT_C #else # define KHRONOS_APICALL #endif /*------------------------------------------------------------------------- * Definition of KHRONOS_APIENTRY *------------------------------------------------------------------------- * This follows the return type of the function and precedes the function * name in the function prototype. */ #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) /* Win32 but not WinCE */ # define KHRONOS_APIENTRY __stdcall #else # define KHRONOS_APIENTRY #endif /*------------------------------------------------------------------------- * Definition of KHRONOS_APIATTRIBUTES *------------------------------------------------------------------------- * This follows the closing parenthesis of the function prototype arguments. */ #if defined (__ARMCC_2__) #define KHRONOS_APIATTRIBUTES __softfp #else #define KHRONOS_APIATTRIBUTES #endif /*------------------------------------------------------------------------- * basic type definitions *-----------------------------------------------------------------------*/ #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) /* * Using */ #include typedef int32_t khronos_int32_t; typedef uint32_t khronos_uint32_t; typedef int64_t khronos_int64_t; typedef uint64_t khronos_uint64_t; #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 #elif defined(__VMS ) || defined(__sgi) /* * Using */ #include typedef int32_t khronos_int32_t; typedef uint32_t khronos_uint32_t; typedef int64_t khronos_int64_t; typedef uint64_t khronos_uint64_t; #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 #elif defined(_WIN32) && !defined(__SCITECH_SNAP__) /* * Win32 */ typedef __int32 khronos_int32_t; typedef unsigned __int32 khronos_uint32_t; typedef __int64 khronos_int64_t; typedef unsigned __int64 khronos_uint64_t; #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 #elif defined(__sun__) || defined(__digital__) /* * Sun or Digital */ typedef int khronos_int32_t; typedef unsigned int khronos_uint32_t; #if defined(__arch64__) || defined(_LP64) typedef long int khronos_int64_t; typedef unsigned long int khronos_uint64_t; #else typedef long long int khronos_int64_t; typedef unsigned long long int khronos_uint64_t; #endif /* __arch64__ */ #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 #elif 0 /* * Hypothetical platform with no float or int64 support */ typedef int khronos_int32_t; typedef unsigned int khronos_uint32_t; #define KHRONOS_SUPPORT_INT64 0 #define KHRONOS_SUPPORT_FLOAT 0 #else /* * Generic fallback */ #include typedef int32_t khronos_int32_t; typedef uint32_t khronos_uint32_t; typedef int64_t khronos_int64_t; typedef uint64_t khronos_uint64_t; #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 #endif /* * Types that are (so far) the same on all platforms */ typedef signed char khronos_int8_t; typedef unsigned char khronos_uint8_t; typedef signed short int khronos_int16_t; typedef unsigned short int khronos_uint16_t; /* * Types that differ between LLP64 and LP64 architectures - in LLP64, * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears * to be the only LLP64 architecture in current use. */ #ifdef _WIN64 typedef signed long long int khronos_intptr_t; typedef unsigned long long int khronos_uintptr_t; typedef signed long long int khronos_ssize_t; typedef unsigned long long int khronos_usize_t; #else typedef signed long int khronos_intptr_t; typedef unsigned long int khronos_uintptr_t; typedef signed long int khronos_ssize_t; typedef unsigned long int khronos_usize_t; #endif #if KHRONOS_SUPPORT_FLOAT /* * Float type */ typedef float khronos_float_t; #endif #if KHRONOS_SUPPORT_INT64 /* Time types * * These types can be used to represent a time interval in nanoseconds or * an absolute Unadjusted System Time. Unadjusted System Time is the number * of nanoseconds since some arbitrary system event (e.g. since the last * time the system booted). The Unadjusted System Time is an unsigned * 64 bit value that wraps back to 0 every 584 years. Time intervals * may be either signed or unsigned. */ typedef khronos_uint64_t khronos_utime_nanoseconds_t; typedef khronos_int64_t khronos_stime_nanoseconds_t; #endif /* * Dummy value used to pad enum types to 32 bits. */ #ifndef KHRONOS_MAX_ENUM #define KHRONOS_MAX_ENUM 0x7FFFFFFF #endif /* * Enumerated boolean type * * Values other than zero should be considered to be true. Therefore * comparisons should not be made against KHRONOS_TRUE. */ typedef enum { KHRONOS_FALSE = 0, KHRONOS_TRUE = 1, KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM } khronos_boolean_enum_t; #endif /* __khrplatform_h_ */ freshplayerplugin-0.3.9/3rdparty/angle/include/angle_gl.h000066400000000000000000000010641321746453100234770ustar00rootroot00000000000000// // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // angle_gl.h: // Includes all necessary GL headers and definitions for ANGLE. // #ifndef ANGLEGL_H_ #define ANGLEGL_H_ #include "GLES2/gl2.h" #include "GLES2/gl2ext.h" #include "GLES3/gl3.h" #include "GLES3/gl3ext.h" // The following enum is used in ANGLE, but is from desktop GL #ifndef GL_SAMPLER_2D_RECT_ARB #define GL_SAMPLER_2D_RECT_ARB 0x8B63 #endif #endif // ANGLEGL_H_ freshplayerplugin-0.3.9/3rdparty/angle/samples/000077500000000000000000000000001321746453100215765ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/angle/samples/shader_translator/000077500000000000000000000000001321746453100253155ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/angle/samples/shader_translator/shader_translator.cpp000066400000000000000000000302611321746453100315420ustar00rootroot00000000000000// // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "GLSLANG/ShaderLang.h" #include #include #include #include #include #include #include #include "angle_gl.h" // // Return codes from main. // enum TFailCode { ESuccess = 0, EFailUsage, EFailCompile, EFailCompilerCreate, }; static void usage(); static sh::GLenum FindShaderType(const char *fileName); static bool CompileFile(char *fileName, ShHandle compiler, int compileOptions); static void LogMsg(const char *msg, const char *name, const int num, const char *logName); // If NUM_SOURCE_STRINGS is set to a value > 1, the input file data is // broken into that many chunks. const unsigned int NUM_SOURCE_STRINGS = 2; typedef std::vector ShaderSource; static bool ReadShaderSource(const char *fileName, ShaderSource &source); static void FreeShaderSource(ShaderSource &source); static bool ParseGLSLOutputVersion(const std::string &, ShShaderOutput *outResult); static bool ParseIntValue(const std::string &, int emptyDefault, int *outValue); // // Set up the per compile resources // void GenerateResources(ShBuiltInResources *resources) { ShInitBuiltInResources(resources); resources->MaxVertexAttribs = 8; resources->MaxVertexUniformVectors = 128; resources->MaxVaryingVectors = 8; resources->MaxVertexTextureImageUnits = 0; resources->MaxCombinedTextureImageUnits = 8; resources->MaxTextureImageUnits = 8; resources->MaxFragmentUniformVectors = 16; resources->MaxDrawBuffers = 1; resources->MaxDualSourceDrawBuffers = 1; resources->OES_standard_derivatives = 0; resources->OES_EGL_image_external = 0; } int main(int argc, char *argv[]) { TFailCode failCode = ESuccess; int compileOptions = 0; int numCompiles = 0; ShHandle vertexCompiler = 0; ShHandle fragmentCompiler = 0; ShShaderSpec spec = SH_GLES2_SPEC; ShShaderOutput output = SH_GLSL_OUTPUT; ShInitialize(); ShBuiltInResources resources; GenerateResources(&resources); argc--; argv++; for (; (argc >= 1) && (failCode == ESuccess); argc--, argv++) { if (argv[0][0] == '-') { switch (argv[0][1]) { case 'o': compileOptions |= SH_OBJECT_CODE; break; case 's': if (argv[0][2] == '=') { switch (argv[0][3]) { case 'e': { spec = SH_GLES2_SPEC; } break; default: failCode = EFailUsage; } } else { failCode = EFailUsage; } break; case 'b': if (argv[0][2] == '=') { switch (argv[0][3]) { case 'g': if (!ParseGLSLOutputVersion(&argv[0][sizeof("-b=g") - 1], &output)) { failCode = EFailUsage; } break; default: failCode = EFailUsage; } } else { failCode = EFailUsage; } break; case 'x': if (argv[0][2] == '=') { switch (argv[0][3]) { case 'i': resources.OES_EGL_image_external = 1; break; case 'd': resources.OES_standard_derivatives = 1; break; case 'r': resources.ARB_texture_rectangle = 1; break; case 'b': if (ParseIntValue(&argv[0][sizeof("-x=b") - 1], 1, &resources.MaxDualSourceDrawBuffers)) { resources.EXT_blend_func_extended = 1; } else { failCode = EFailUsage; } break; case 'w': if (ParseIntValue(&argv[0][sizeof("-x=w") - 1], 1, &resources.MaxDrawBuffers)) { resources.EXT_draw_buffers = 1; } else { failCode = EFailUsage; } break; case 'g': resources.EXT_frag_depth = 1; break; case 'l': resources.EXT_shader_texture_lod = 1; break; case 'f': resources.EXT_shader_framebuffer_fetch = 1; break; case 'n': resources.NV_shader_framebuffer_fetch = 1; break; case 'a': resources.ARM_shader_framebuffer_fetch = 1; break; default: failCode = EFailUsage; } } else { failCode = EFailUsage; } break; default: failCode = EFailUsage; } } else { ShHandle compiler = 0; switch (FindShaderType(argv[0])) { case GL_VERTEX_SHADER: if (vertexCompiler == 0) { vertexCompiler = ShConstructCompiler( GL_VERTEX_SHADER, spec, output, &resources); } compiler = vertexCompiler; break; case GL_FRAGMENT_SHADER: if (fragmentCompiler == 0) { fragmentCompiler = ShConstructCompiler( GL_FRAGMENT_SHADER, spec, output, &resources); } compiler = fragmentCompiler; break; default: break; } if (compiler) { bool compiled = CompileFile(argv[0], compiler, compileOptions); if (compiled && (compileOptions & SH_OBJECT_CODE)) { LogMsg("BEGIN", "COMPILER", numCompiles, "OBJ CODE"); std::string code = ShGetObjectCode(compiler); puts(code.c_str()); LogMsg("END", "COMPILER", numCompiles, "OBJ CODE"); printf("\n\n"); } if (!compiled) failCode = EFailCompile; ++numCompiles; } else { failCode = EFailCompilerCreate; } } } if ((vertexCompiler == 0) && (fragmentCompiler == 0)) failCode = EFailUsage; if (failCode == EFailUsage) usage(); if (vertexCompiler) ShDestruct(vertexCompiler); if (fragmentCompiler) ShDestruct(fragmentCompiler); ShFinalize(); return failCode; } // // print usage to stdout // void usage() { printf( "Usage: translate [-i -o -u -l -e -t -d -p -b=e -b=g -b=h9 -x=i -x=d] file1 file2 ...\n" "Where: filename : filename ending in .frag or .vert\n" " -i : print intermediate tree\n" " -o : print translated code\n" " -u : print active attribs, uniforms, varyings and program outputs\n" " -l : unroll for-loops with integer indices\n" " -e : emulate certain built-in functions (workaround for driver bugs)\n" " -t : enforce experimental timing restrictions\n" " -d : print dependency graph used to enforce timing restrictions\n" " -p : use precision emulation\n" " -s=e2 : use GLES2 spec (this is by default)\n" " -s=e3 : use GLES3 spec (in development)\n" " -s=w : use WebGL spec\n" " -s=w2 : use WebGL 2 spec (in development)\n" " -s=c : use CSS Shaders spec\n" " -b=e : output GLSL ES code (this is by default)\n" " -b=g : output GLSL code (compatibility profile)\n" " -b=g[NUM]: output GLSL code (NUM can be 130, 140, 150, 330, 400, 410, 420, 430, " "440, 450)\n" " -b=h9 : output HLSL9 code\n" " -b=h11 : output HLSL11 code\n" " -x=i : enable GL_OES_EGL_image_external\n" " -x=d : enable GL_OES_EGL_standard_derivatives\n" " -x=r : enable ARB_texture_rectangle\n" " -x=b[NUM]: enable EXT_blend_func_extended (NUM default 1)\n" " -x=w[NUM]: enable EXT_draw_buffers (NUM default 1)\n" " -x=l : enable EXT_shader_texture_lod\n" " -x=f : enable EXT_shader_framebuffer_fetch\n" " -x=n : enable NV_shader_framebuffer_fetch\n" " -x=a : enable ARM_shader_framebuffer_fetch\n"); } // // Deduce the shader type from the filename. Files must end in one of the // following extensions: // // .frag* = fragment shader // .vert* = vertex shader // sh::GLenum FindShaderType(const char *fileName) { assert(fileName); const char *ext = strrchr(fileName, '.'); if (ext && strcmp(ext, ".sl") == 0) for (; ext > fileName && ext[0] != '.'; ext--); ext = strrchr(fileName, '.'); if (ext) { if (strncmp(ext, ".frag", 4) == 0) return GL_FRAGMENT_SHADER; if (strncmp(ext, ".vert", 4) == 0) return GL_VERTEX_SHADER; } return GL_FRAGMENT_SHADER; } // // Read a file's data into a string, and compile it using ShCompile // bool CompileFile(char *fileName, ShHandle compiler, int compileOptions) { ShaderSource source; if (!ReadShaderSource(fileName, source)) return false; int ret = ShCompile(compiler, &source[0], source.size(), compileOptions); FreeShaderSource(source); return ret ? true : false; } void LogMsg(const char *msg, const char *name, const int num, const char *logName) { printf("#### %s %s %d %s ####\n", msg, name, num, logName); } static bool ReadShaderSource(const char *fileName, ShaderSource &source) { FILE *in = fopen(fileName, "rb"); if (!in) { printf("Error: unable to open input file: %s\n", fileName); return false; } // Obtain file size. fseek(in, 0, SEEK_END); size_t count = ftell(in); rewind(in); int len = (int)ceil((float)count / (float)NUM_SOURCE_STRINGS); source.reserve(NUM_SOURCE_STRINGS); // Notice the usage of do-while instead of a while loop here. // It is there to handle empty files in which case a single empty // string is added to vector. do { char *data = new char[len + 1]; size_t nread = fread(data, 1, len, in); data[nread] = '\0'; source.push_back(data); count -= nread; } while (count > 0); fclose(in); return true; } static void FreeShaderSource(ShaderSource &source) { for (ShaderSource::size_type i = 0; i < source.size(); ++i) { delete [] source[i]; } source.clear(); } static bool ParseGLSLOutputVersion(const std::string &num, ShShaderOutput *outResult) { if (num.length() == 0) { *outResult = SH_GLSL_COMPATIBILITY_OUTPUT; return true; } std::istringstream input(num); int value; if (!(input >> value && input.eof())) { return false; } return false; } static bool ParseIntValue(const std::string &num, int emptyDefault, int *outValue) { if (num.length() == 0) { *outValue = emptyDefault; return true; } std::istringstream input(num); int value; if (!(input >> value && input.eof())) { return false; } *outValue = value; return true; } freshplayerplugin-0.3.9/3rdparty/angle/src/000077500000000000000000000000001321746453100207215ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/angle/src/common/000077500000000000000000000000001321746453100222115ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/angle/src/common/Float16ToFloat32.cpp000066400000000000000000001050271321746453100255740ustar00rootroot00000000000000// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // This file is automatically generated. namespace gl { const static unsigned g_mantissa[2048] = { 0x00000000, 0x33800000, 0x34000000, 0x34400000, 0x34800000, 0x34a00000, 0x34c00000, 0x34e00000, 0x35000000, 0x35100000, 0x35200000, 0x35300000, 0x35400000, 0x35500000, 0x35600000, 0x35700000, 0x35800000, 0x35880000, 0x35900000, 0x35980000, 0x35a00000, 0x35a80000, 0x35b00000, 0x35b80000, 0x35c00000, 0x35c80000, 0x35d00000, 0x35d80000, 0x35e00000, 0x35e80000, 0x35f00000, 0x35f80000, 0x36000000, 0x36040000, 0x36080000, 0x360c0000, 0x36100000, 0x36140000, 0x36180000, 0x361c0000, 0x36200000, 0x36240000, 0x36280000, 0x362c0000, 0x36300000, 0x36340000, 0x36380000, 0x363c0000, 0x36400000, 0x36440000, 0x36480000, 0x364c0000, 0x36500000, 0x36540000, 0x36580000, 0x365c0000, 0x36600000, 0x36640000, 0x36680000, 0x366c0000, 0x36700000, 0x36740000, 0x36780000, 0x367c0000, 0x36800000, 0x36820000, 0x36840000, 0x36860000, 0x36880000, 0x368a0000, 0x368c0000, 0x368e0000, 0x36900000, 0x36920000, 0x36940000, 0x36960000, 0x36980000, 0x369a0000, 0x369c0000, 0x369e0000, 0x36a00000, 0x36a20000, 0x36a40000, 0x36a60000, 0x36a80000, 0x36aa0000, 0x36ac0000, 0x36ae0000, 0x36b00000, 0x36b20000, 0x36b40000, 0x36b60000, 0x36b80000, 0x36ba0000, 0x36bc0000, 0x36be0000, 0x36c00000, 0x36c20000, 0x36c40000, 0x36c60000, 0x36c80000, 0x36ca0000, 0x36cc0000, 0x36ce0000, 0x36d00000, 0x36d20000, 0x36d40000, 0x36d60000, 0x36d80000, 0x36da0000, 0x36dc0000, 0x36de0000, 0x36e00000, 0x36e20000, 0x36e40000, 0x36e60000, 0x36e80000, 0x36ea0000, 0x36ec0000, 0x36ee0000, 0x36f00000, 0x36f20000, 0x36f40000, 0x36f60000, 0x36f80000, 0x36fa0000, 0x36fc0000, 0x36fe0000, 0x37000000, 0x37010000, 0x37020000, 0x37030000, 0x37040000, 0x37050000, 0x37060000, 0x37070000, 0x37080000, 0x37090000, 0x370a0000, 0x370b0000, 0x370c0000, 0x370d0000, 0x370e0000, 0x370f0000, 0x37100000, 0x37110000, 0x37120000, 0x37130000, 0x37140000, 0x37150000, 0x37160000, 0x37170000, 0x37180000, 0x37190000, 0x371a0000, 0x371b0000, 0x371c0000, 0x371d0000, 0x371e0000, 0x371f0000, 0x37200000, 0x37210000, 0x37220000, 0x37230000, 0x37240000, 0x37250000, 0x37260000, 0x37270000, 0x37280000, 0x37290000, 0x372a0000, 0x372b0000, 0x372c0000, 0x372d0000, 0x372e0000, 0x372f0000, 0x37300000, 0x37310000, 0x37320000, 0x37330000, 0x37340000, 0x37350000, 0x37360000, 0x37370000, 0x37380000, 0x37390000, 0x373a0000, 0x373b0000, 0x373c0000, 0x373d0000, 0x373e0000, 0x373f0000, 0x37400000, 0x37410000, 0x37420000, 0x37430000, 0x37440000, 0x37450000, 0x37460000, 0x37470000, 0x37480000, 0x37490000, 0x374a0000, 0x374b0000, 0x374c0000, 0x374d0000, 0x374e0000, 0x374f0000, 0x37500000, 0x37510000, 0x37520000, 0x37530000, 0x37540000, 0x37550000, 0x37560000, 0x37570000, 0x37580000, 0x37590000, 0x375a0000, 0x375b0000, 0x375c0000, 0x375d0000, 0x375e0000, 0x375f0000, 0x37600000, 0x37610000, 0x37620000, 0x37630000, 0x37640000, 0x37650000, 0x37660000, 0x37670000, 0x37680000, 0x37690000, 0x376a0000, 0x376b0000, 0x376c0000, 0x376d0000, 0x376e0000, 0x376f0000, 0x37700000, 0x37710000, 0x37720000, 0x37730000, 0x37740000, 0x37750000, 0x37760000, 0x37770000, 0x37780000, 0x37790000, 0x377a0000, 0x377b0000, 0x377c0000, 0x377d0000, 0x377e0000, 0x377f0000, 0x37800000, 0x37808000, 0x37810000, 0x37818000, 0x37820000, 0x37828000, 0x37830000, 0x37838000, 0x37840000, 0x37848000, 0x37850000, 0x37858000, 0x37860000, 0x37868000, 0x37870000, 0x37878000, 0x37880000, 0x37888000, 0x37890000, 0x37898000, 0x378a0000, 0x378a8000, 0x378b0000, 0x378b8000, 0x378c0000, 0x378c8000, 0x378d0000, 0x378d8000, 0x378e0000, 0x378e8000, 0x378f0000, 0x378f8000, 0x37900000, 0x37908000, 0x37910000, 0x37918000, 0x37920000, 0x37928000, 0x37930000, 0x37938000, 0x37940000, 0x37948000, 0x37950000, 0x37958000, 0x37960000, 0x37968000, 0x37970000, 0x37978000, 0x37980000, 0x37988000, 0x37990000, 0x37998000, 0x379a0000, 0x379a8000, 0x379b0000, 0x379b8000, 0x379c0000, 0x379c8000, 0x379d0000, 0x379d8000, 0x379e0000, 0x379e8000, 0x379f0000, 0x379f8000, 0x37a00000, 0x37a08000, 0x37a10000, 0x37a18000, 0x37a20000, 0x37a28000, 0x37a30000, 0x37a38000, 0x37a40000, 0x37a48000, 0x37a50000, 0x37a58000, 0x37a60000, 0x37a68000, 0x37a70000, 0x37a78000, 0x37a80000, 0x37a88000, 0x37a90000, 0x37a98000, 0x37aa0000, 0x37aa8000, 0x37ab0000, 0x37ab8000, 0x37ac0000, 0x37ac8000, 0x37ad0000, 0x37ad8000, 0x37ae0000, 0x37ae8000, 0x37af0000, 0x37af8000, 0x37b00000, 0x37b08000, 0x37b10000, 0x37b18000, 0x37b20000, 0x37b28000, 0x37b30000, 0x37b38000, 0x37b40000, 0x37b48000, 0x37b50000, 0x37b58000, 0x37b60000, 0x37b68000, 0x37b70000, 0x37b78000, 0x37b80000, 0x37b88000, 0x37b90000, 0x37b98000, 0x37ba0000, 0x37ba8000, 0x37bb0000, 0x37bb8000, 0x37bc0000, 0x37bc8000, 0x37bd0000, 0x37bd8000, 0x37be0000, 0x37be8000, 0x37bf0000, 0x37bf8000, 0x37c00000, 0x37c08000, 0x37c10000, 0x37c18000, 0x37c20000, 0x37c28000, 0x37c30000, 0x37c38000, 0x37c40000, 0x37c48000, 0x37c50000, 0x37c58000, 0x37c60000, 0x37c68000, 0x37c70000, 0x37c78000, 0x37c80000, 0x37c88000, 0x37c90000, 0x37c98000, 0x37ca0000, 0x37ca8000, 0x37cb0000, 0x37cb8000, 0x37cc0000, 0x37cc8000, 0x37cd0000, 0x37cd8000, 0x37ce0000, 0x37ce8000, 0x37cf0000, 0x37cf8000, 0x37d00000, 0x37d08000, 0x37d10000, 0x37d18000, 0x37d20000, 0x37d28000, 0x37d30000, 0x37d38000, 0x37d40000, 0x37d48000, 0x37d50000, 0x37d58000, 0x37d60000, 0x37d68000, 0x37d70000, 0x37d78000, 0x37d80000, 0x37d88000, 0x37d90000, 0x37d98000, 0x37da0000, 0x37da8000, 0x37db0000, 0x37db8000, 0x37dc0000, 0x37dc8000, 0x37dd0000, 0x37dd8000, 0x37de0000, 0x37de8000, 0x37df0000, 0x37df8000, 0x37e00000, 0x37e08000, 0x37e10000, 0x37e18000, 0x37e20000, 0x37e28000, 0x37e30000, 0x37e38000, 0x37e40000, 0x37e48000, 0x37e50000, 0x37e58000, 0x37e60000, 0x37e68000, 0x37e70000, 0x37e78000, 0x37e80000, 0x37e88000, 0x37e90000, 0x37e98000, 0x37ea0000, 0x37ea8000, 0x37eb0000, 0x37eb8000, 0x37ec0000, 0x37ec8000, 0x37ed0000, 0x37ed8000, 0x37ee0000, 0x37ee8000, 0x37ef0000, 0x37ef8000, 0x37f00000, 0x37f08000, 0x37f10000, 0x37f18000, 0x37f20000, 0x37f28000, 0x37f30000, 0x37f38000, 0x37f40000, 0x37f48000, 0x37f50000, 0x37f58000, 0x37f60000, 0x37f68000, 0x37f70000, 0x37f78000, 0x37f80000, 0x37f88000, 0x37f90000, 0x37f98000, 0x37fa0000, 0x37fa8000, 0x37fb0000, 0x37fb8000, 0x37fc0000, 0x37fc8000, 0x37fd0000, 0x37fd8000, 0x37fe0000, 0x37fe8000, 0x37ff0000, 0x37ff8000, 0x38000000, 0x38004000, 0x38008000, 0x3800c000, 0x38010000, 0x38014000, 0x38018000, 0x3801c000, 0x38020000, 0x38024000, 0x38028000, 0x3802c000, 0x38030000, 0x38034000, 0x38038000, 0x3803c000, 0x38040000, 0x38044000, 0x38048000, 0x3804c000, 0x38050000, 0x38054000, 0x38058000, 0x3805c000, 0x38060000, 0x38064000, 0x38068000, 0x3806c000, 0x38070000, 0x38074000, 0x38078000, 0x3807c000, 0x38080000, 0x38084000, 0x38088000, 0x3808c000, 0x38090000, 0x38094000, 0x38098000, 0x3809c000, 0x380a0000, 0x380a4000, 0x380a8000, 0x380ac000, 0x380b0000, 0x380b4000, 0x380b8000, 0x380bc000, 0x380c0000, 0x380c4000, 0x380c8000, 0x380cc000, 0x380d0000, 0x380d4000, 0x380d8000, 0x380dc000, 0x380e0000, 0x380e4000, 0x380e8000, 0x380ec000, 0x380f0000, 0x380f4000, 0x380f8000, 0x380fc000, 0x38100000, 0x38104000, 0x38108000, 0x3810c000, 0x38110000, 0x38114000, 0x38118000, 0x3811c000, 0x38120000, 0x38124000, 0x38128000, 0x3812c000, 0x38130000, 0x38134000, 0x38138000, 0x3813c000, 0x38140000, 0x38144000, 0x38148000, 0x3814c000, 0x38150000, 0x38154000, 0x38158000, 0x3815c000, 0x38160000, 0x38164000, 0x38168000, 0x3816c000, 0x38170000, 0x38174000, 0x38178000, 0x3817c000, 0x38180000, 0x38184000, 0x38188000, 0x3818c000, 0x38190000, 0x38194000, 0x38198000, 0x3819c000, 0x381a0000, 0x381a4000, 0x381a8000, 0x381ac000, 0x381b0000, 0x381b4000, 0x381b8000, 0x381bc000, 0x381c0000, 0x381c4000, 0x381c8000, 0x381cc000, 0x381d0000, 0x381d4000, 0x381d8000, 0x381dc000, 0x381e0000, 0x381e4000, 0x381e8000, 0x381ec000, 0x381f0000, 0x381f4000, 0x381f8000, 0x381fc000, 0x38200000, 0x38204000, 0x38208000, 0x3820c000, 0x38210000, 0x38214000, 0x38218000, 0x3821c000, 0x38220000, 0x38224000, 0x38228000, 0x3822c000, 0x38230000, 0x38234000, 0x38238000, 0x3823c000, 0x38240000, 0x38244000, 0x38248000, 0x3824c000, 0x38250000, 0x38254000, 0x38258000, 0x3825c000, 0x38260000, 0x38264000, 0x38268000, 0x3826c000, 0x38270000, 0x38274000, 0x38278000, 0x3827c000, 0x38280000, 0x38284000, 0x38288000, 0x3828c000, 0x38290000, 0x38294000, 0x38298000, 0x3829c000, 0x382a0000, 0x382a4000, 0x382a8000, 0x382ac000, 0x382b0000, 0x382b4000, 0x382b8000, 0x382bc000, 0x382c0000, 0x382c4000, 0x382c8000, 0x382cc000, 0x382d0000, 0x382d4000, 0x382d8000, 0x382dc000, 0x382e0000, 0x382e4000, 0x382e8000, 0x382ec000, 0x382f0000, 0x382f4000, 0x382f8000, 0x382fc000, 0x38300000, 0x38304000, 0x38308000, 0x3830c000, 0x38310000, 0x38314000, 0x38318000, 0x3831c000, 0x38320000, 0x38324000, 0x38328000, 0x3832c000, 0x38330000, 0x38334000, 0x38338000, 0x3833c000, 0x38340000, 0x38344000, 0x38348000, 0x3834c000, 0x38350000, 0x38354000, 0x38358000, 0x3835c000, 0x38360000, 0x38364000, 0x38368000, 0x3836c000, 0x38370000, 0x38374000, 0x38378000, 0x3837c000, 0x38380000, 0x38384000, 0x38388000, 0x3838c000, 0x38390000, 0x38394000, 0x38398000, 0x3839c000, 0x383a0000, 0x383a4000, 0x383a8000, 0x383ac000, 0x383b0000, 0x383b4000, 0x383b8000, 0x383bc000, 0x383c0000, 0x383c4000, 0x383c8000, 0x383cc000, 0x383d0000, 0x383d4000, 0x383d8000, 0x383dc000, 0x383e0000, 0x383e4000, 0x383e8000, 0x383ec000, 0x383f0000, 0x383f4000, 0x383f8000, 0x383fc000, 0x38400000, 0x38404000, 0x38408000, 0x3840c000, 0x38410000, 0x38414000, 0x38418000, 0x3841c000, 0x38420000, 0x38424000, 0x38428000, 0x3842c000, 0x38430000, 0x38434000, 0x38438000, 0x3843c000, 0x38440000, 0x38444000, 0x38448000, 0x3844c000, 0x38450000, 0x38454000, 0x38458000, 0x3845c000, 0x38460000, 0x38464000, 0x38468000, 0x3846c000, 0x38470000, 0x38474000, 0x38478000, 0x3847c000, 0x38480000, 0x38484000, 0x38488000, 0x3848c000, 0x38490000, 0x38494000, 0x38498000, 0x3849c000, 0x384a0000, 0x384a4000, 0x384a8000, 0x384ac000, 0x384b0000, 0x384b4000, 0x384b8000, 0x384bc000, 0x384c0000, 0x384c4000, 0x384c8000, 0x384cc000, 0x384d0000, 0x384d4000, 0x384d8000, 0x384dc000, 0x384e0000, 0x384e4000, 0x384e8000, 0x384ec000, 0x384f0000, 0x384f4000, 0x384f8000, 0x384fc000, 0x38500000, 0x38504000, 0x38508000, 0x3850c000, 0x38510000, 0x38514000, 0x38518000, 0x3851c000, 0x38520000, 0x38524000, 0x38528000, 0x3852c000, 0x38530000, 0x38534000, 0x38538000, 0x3853c000, 0x38540000, 0x38544000, 0x38548000, 0x3854c000, 0x38550000, 0x38554000, 0x38558000, 0x3855c000, 0x38560000, 0x38564000, 0x38568000, 0x3856c000, 0x38570000, 0x38574000, 0x38578000, 0x3857c000, 0x38580000, 0x38584000, 0x38588000, 0x3858c000, 0x38590000, 0x38594000, 0x38598000, 0x3859c000, 0x385a0000, 0x385a4000, 0x385a8000, 0x385ac000, 0x385b0000, 0x385b4000, 0x385b8000, 0x385bc000, 0x385c0000, 0x385c4000, 0x385c8000, 0x385cc000, 0x385d0000, 0x385d4000, 0x385d8000, 0x385dc000, 0x385e0000, 0x385e4000, 0x385e8000, 0x385ec000, 0x385f0000, 0x385f4000, 0x385f8000, 0x385fc000, 0x38600000, 0x38604000, 0x38608000, 0x3860c000, 0x38610000, 0x38614000, 0x38618000, 0x3861c000, 0x38620000, 0x38624000, 0x38628000, 0x3862c000, 0x38630000, 0x38634000, 0x38638000, 0x3863c000, 0x38640000, 0x38644000, 0x38648000, 0x3864c000, 0x38650000, 0x38654000, 0x38658000, 0x3865c000, 0x38660000, 0x38664000, 0x38668000, 0x3866c000, 0x38670000, 0x38674000, 0x38678000, 0x3867c000, 0x38680000, 0x38684000, 0x38688000, 0x3868c000, 0x38690000, 0x38694000, 0x38698000, 0x3869c000, 0x386a0000, 0x386a4000, 0x386a8000, 0x386ac000, 0x386b0000, 0x386b4000, 0x386b8000, 0x386bc000, 0x386c0000, 0x386c4000, 0x386c8000, 0x386cc000, 0x386d0000, 0x386d4000, 0x386d8000, 0x386dc000, 0x386e0000, 0x386e4000, 0x386e8000, 0x386ec000, 0x386f0000, 0x386f4000, 0x386f8000, 0x386fc000, 0x38700000, 0x38704000, 0x38708000, 0x3870c000, 0x38710000, 0x38714000, 0x38718000, 0x3871c000, 0x38720000, 0x38724000, 0x38728000, 0x3872c000, 0x38730000, 0x38734000, 0x38738000, 0x3873c000, 0x38740000, 0x38744000, 0x38748000, 0x3874c000, 0x38750000, 0x38754000, 0x38758000, 0x3875c000, 0x38760000, 0x38764000, 0x38768000, 0x3876c000, 0x38770000, 0x38774000, 0x38778000, 0x3877c000, 0x38780000, 0x38784000, 0x38788000, 0x3878c000, 0x38790000, 0x38794000, 0x38798000, 0x3879c000, 0x387a0000, 0x387a4000, 0x387a8000, 0x387ac000, 0x387b0000, 0x387b4000, 0x387b8000, 0x387bc000, 0x387c0000, 0x387c4000, 0x387c8000, 0x387cc000, 0x387d0000, 0x387d4000, 0x387d8000, 0x387dc000, 0x387e0000, 0x387e4000, 0x387e8000, 0x387ec000, 0x387f0000, 0x387f4000, 0x387f8000, 0x387fc000, 0x38000000, 0x38002000, 0x38004000, 0x38006000, 0x38008000, 0x3800a000, 0x3800c000, 0x3800e000, 0x38010000, 0x38012000, 0x38014000, 0x38016000, 0x38018000, 0x3801a000, 0x3801c000, 0x3801e000, 0x38020000, 0x38022000, 0x38024000, 0x38026000, 0x38028000, 0x3802a000, 0x3802c000, 0x3802e000, 0x38030000, 0x38032000, 0x38034000, 0x38036000, 0x38038000, 0x3803a000, 0x3803c000, 0x3803e000, 0x38040000, 0x38042000, 0x38044000, 0x38046000, 0x38048000, 0x3804a000, 0x3804c000, 0x3804e000, 0x38050000, 0x38052000, 0x38054000, 0x38056000, 0x38058000, 0x3805a000, 0x3805c000, 0x3805e000, 0x38060000, 0x38062000, 0x38064000, 0x38066000, 0x38068000, 0x3806a000, 0x3806c000, 0x3806e000, 0x38070000, 0x38072000, 0x38074000, 0x38076000, 0x38078000, 0x3807a000, 0x3807c000, 0x3807e000, 0x38080000, 0x38082000, 0x38084000, 0x38086000, 0x38088000, 0x3808a000, 0x3808c000, 0x3808e000, 0x38090000, 0x38092000, 0x38094000, 0x38096000, 0x38098000, 0x3809a000, 0x3809c000, 0x3809e000, 0x380a0000, 0x380a2000, 0x380a4000, 0x380a6000, 0x380a8000, 0x380aa000, 0x380ac000, 0x380ae000, 0x380b0000, 0x380b2000, 0x380b4000, 0x380b6000, 0x380b8000, 0x380ba000, 0x380bc000, 0x380be000, 0x380c0000, 0x380c2000, 0x380c4000, 0x380c6000, 0x380c8000, 0x380ca000, 0x380cc000, 0x380ce000, 0x380d0000, 0x380d2000, 0x380d4000, 0x380d6000, 0x380d8000, 0x380da000, 0x380dc000, 0x380de000, 0x380e0000, 0x380e2000, 0x380e4000, 0x380e6000, 0x380e8000, 0x380ea000, 0x380ec000, 0x380ee000, 0x380f0000, 0x380f2000, 0x380f4000, 0x380f6000, 0x380f8000, 0x380fa000, 0x380fc000, 0x380fe000, 0x38100000, 0x38102000, 0x38104000, 0x38106000, 0x38108000, 0x3810a000, 0x3810c000, 0x3810e000, 0x38110000, 0x38112000, 0x38114000, 0x38116000, 0x38118000, 0x3811a000, 0x3811c000, 0x3811e000, 0x38120000, 0x38122000, 0x38124000, 0x38126000, 0x38128000, 0x3812a000, 0x3812c000, 0x3812e000, 0x38130000, 0x38132000, 0x38134000, 0x38136000, 0x38138000, 0x3813a000, 0x3813c000, 0x3813e000, 0x38140000, 0x38142000, 0x38144000, 0x38146000, 0x38148000, 0x3814a000, 0x3814c000, 0x3814e000, 0x38150000, 0x38152000, 0x38154000, 0x38156000, 0x38158000, 0x3815a000, 0x3815c000, 0x3815e000, 0x38160000, 0x38162000, 0x38164000, 0x38166000, 0x38168000, 0x3816a000, 0x3816c000, 0x3816e000, 0x38170000, 0x38172000, 0x38174000, 0x38176000, 0x38178000, 0x3817a000, 0x3817c000, 0x3817e000, 0x38180000, 0x38182000, 0x38184000, 0x38186000, 0x38188000, 0x3818a000, 0x3818c000, 0x3818e000, 0x38190000, 0x38192000, 0x38194000, 0x38196000, 0x38198000, 0x3819a000, 0x3819c000, 0x3819e000, 0x381a0000, 0x381a2000, 0x381a4000, 0x381a6000, 0x381a8000, 0x381aa000, 0x381ac000, 0x381ae000, 0x381b0000, 0x381b2000, 0x381b4000, 0x381b6000, 0x381b8000, 0x381ba000, 0x381bc000, 0x381be000, 0x381c0000, 0x381c2000, 0x381c4000, 0x381c6000, 0x381c8000, 0x381ca000, 0x381cc000, 0x381ce000, 0x381d0000, 0x381d2000, 0x381d4000, 0x381d6000, 0x381d8000, 0x381da000, 0x381dc000, 0x381de000, 0x381e0000, 0x381e2000, 0x381e4000, 0x381e6000, 0x381e8000, 0x381ea000, 0x381ec000, 0x381ee000, 0x381f0000, 0x381f2000, 0x381f4000, 0x381f6000, 0x381f8000, 0x381fa000, 0x381fc000, 0x381fe000, 0x38200000, 0x38202000, 0x38204000, 0x38206000, 0x38208000, 0x3820a000, 0x3820c000, 0x3820e000, 0x38210000, 0x38212000, 0x38214000, 0x38216000, 0x38218000, 0x3821a000, 0x3821c000, 0x3821e000, 0x38220000, 0x38222000, 0x38224000, 0x38226000, 0x38228000, 0x3822a000, 0x3822c000, 0x3822e000, 0x38230000, 0x38232000, 0x38234000, 0x38236000, 0x38238000, 0x3823a000, 0x3823c000, 0x3823e000, 0x38240000, 0x38242000, 0x38244000, 0x38246000, 0x38248000, 0x3824a000, 0x3824c000, 0x3824e000, 0x38250000, 0x38252000, 0x38254000, 0x38256000, 0x38258000, 0x3825a000, 0x3825c000, 0x3825e000, 0x38260000, 0x38262000, 0x38264000, 0x38266000, 0x38268000, 0x3826a000, 0x3826c000, 0x3826e000, 0x38270000, 0x38272000, 0x38274000, 0x38276000, 0x38278000, 0x3827a000, 0x3827c000, 0x3827e000, 0x38280000, 0x38282000, 0x38284000, 0x38286000, 0x38288000, 0x3828a000, 0x3828c000, 0x3828e000, 0x38290000, 0x38292000, 0x38294000, 0x38296000, 0x38298000, 0x3829a000, 0x3829c000, 0x3829e000, 0x382a0000, 0x382a2000, 0x382a4000, 0x382a6000, 0x382a8000, 0x382aa000, 0x382ac000, 0x382ae000, 0x382b0000, 0x382b2000, 0x382b4000, 0x382b6000, 0x382b8000, 0x382ba000, 0x382bc000, 0x382be000, 0x382c0000, 0x382c2000, 0x382c4000, 0x382c6000, 0x382c8000, 0x382ca000, 0x382cc000, 0x382ce000, 0x382d0000, 0x382d2000, 0x382d4000, 0x382d6000, 0x382d8000, 0x382da000, 0x382dc000, 0x382de000, 0x382e0000, 0x382e2000, 0x382e4000, 0x382e6000, 0x382e8000, 0x382ea000, 0x382ec000, 0x382ee000, 0x382f0000, 0x382f2000, 0x382f4000, 0x382f6000, 0x382f8000, 0x382fa000, 0x382fc000, 0x382fe000, 0x38300000, 0x38302000, 0x38304000, 0x38306000, 0x38308000, 0x3830a000, 0x3830c000, 0x3830e000, 0x38310000, 0x38312000, 0x38314000, 0x38316000, 0x38318000, 0x3831a000, 0x3831c000, 0x3831e000, 0x38320000, 0x38322000, 0x38324000, 0x38326000, 0x38328000, 0x3832a000, 0x3832c000, 0x3832e000, 0x38330000, 0x38332000, 0x38334000, 0x38336000, 0x38338000, 0x3833a000, 0x3833c000, 0x3833e000, 0x38340000, 0x38342000, 0x38344000, 0x38346000, 0x38348000, 0x3834a000, 0x3834c000, 0x3834e000, 0x38350000, 0x38352000, 0x38354000, 0x38356000, 0x38358000, 0x3835a000, 0x3835c000, 0x3835e000, 0x38360000, 0x38362000, 0x38364000, 0x38366000, 0x38368000, 0x3836a000, 0x3836c000, 0x3836e000, 0x38370000, 0x38372000, 0x38374000, 0x38376000, 0x38378000, 0x3837a000, 0x3837c000, 0x3837e000, 0x38380000, 0x38382000, 0x38384000, 0x38386000, 0x38388000, 0x3838a000, 0x3838c000, 0x3838e000, 0x38390000, 0x38392000, 0x38394000, 0x38396000, 0x38398000, 0x3839a000, 0x3839c000, 0x3839e000, 0x383a0000, 0x383a2000, 0x383a4000, 0x383a6000, 0x383a8000, 0x383aa000, 0x383ac000, 0x383ae000, 0x383b0000, 0x383b2000, 0x383b4000, 0x383b6000, 0x383b8000, 0x383ba000, 0x383bc000, 0x383be000, 0x383c0000, 0x383c2000, 0x383c4000, 0x383c6000, 0x383c8000, 0x383ca000, 0x383cc000, 0x383ce000, 0x383d0000, 0x383d2000, 0x383d4000, 0x383d6000, 0x383d8000, 0x383da000, 0x383dc000, 0x383de000, 0x383e0000, 0x383e2000, 0x383e4000, 0x383e6000, 0x383e8000, 0x383ea000, 0x383ec000, 0x383ee000, 0x383f0000, 0x383f2000, 0x383f4000, 0x383f6000, 0x383f8000, 0x383fa000, 0x383fc000, 0x383fe000, 0x38400000, 0x38402000, 0x38404000, 0x38406000, 0x38408000, 0x3840a000, 0x3840c000, 0x3840e000, 0x38410000, 0x38412000, 0x38414000, 0x38416000, 0x38418000, 0x3841a000, 0x3841c000, 0x3841e000, 0x38420000, 0x38422000, 0x38424000, 0x38426000, 0x38428000, 0x3842a000, 0x3842c000, 0x3842e000, 0x38430000, 0x38432000, 0x38434000, 0x38436000, 0x38438000, 0x3843a000, 0x3843c000, 0x3843e000, 0x38440000, 0x38442000, 0x38444000, 0x38446000, 0x38448000, 0x3844a000, 0x3844c000, 0x3844e000, 0x38450000, 0x38452000, 0x38454000, 0x38456000, 0x38458000, 0x3845a000, 0x3845c000, 0x3845e000, 0x38460000, 0x38462000, 0x38464000, 0x38466000, 0x38468000, 0x3846a000, 0x3846c000, 0x3846e000, 0x38470000, 0x38472000, 0x38474000, 0x38476000, 0x38478000, 0x3847a000, 0x3847c000, 0x3847e000, 0x38480000, 0x38482000, 0x38484000, 0x38486000, 0x38488000, 0x3848a000, 0x3848c000, 0x3848e000, 0x38490000, 0x38492000, 0x38494000, 0x38496000, 0x38498000, 0x3849a000, 0x3849c000, 0x3849e000, 0x384a0000, 0x384a2000, 0x384a4000, 0x384a6000, 0x384a8000, 0x384aa000, 0x384ac000, 0x384ae000, 0x384b0000, 0x384b2000, 0x384b4000, 0x384b6000, 0x384b8000, 0x384ba000, 0x384bc000, 0x384be000, 0x384c0000, 0x384c2000, 0x384c4000, 0x384c6000, 0x384c8000, 0x384ca000, 0x384cc000, 0x384ce000, 0x384d0000, 0x384d2000, 0x384d4000, 0x384d6000, 0x384d8000, 0x384da000, 0x384dc000, 0x384de000, 0x384e0000, 0x384e2000, 0x384e4000, 0x384e6000, 0x384e8000, 0x384ea000, 0x384ec000, 0x384ee000, 0x384f0000, 0x384f2000, 0x384f4000, 0x384f6000, 0x384f8000, 0x384fa000, 0x384fc000, 0x384fe000, 0x38500000, 0x38502000, 0x38504000, 0x38506000, 0x38508000, 0x3850a000, 0x3850c000, 0x3850e000, 0x38510000, 0x38512000, 0x38514000, 0x38516000, 0x38518000, 0x3851a000, 0x3851c000, 0x3851e000, 0x38520000, 0x38522000, 0x38524000, 0x38526000, 0x38528000, 0x3852a000, 0x3852c000, 0x3852e000, 0x38530000, 0x38532000, 0x38534000, 0x38536000, 0x38538000, 0x3853a000, 0x3853c000, 0x3853e000, 0x38540000, 0x38542000, 0x38544000, 0x38546000, 0x38548000, 0x3854a000, 0x3854c000, 0x3854e000, 0x38550000, 0x38552000, 0x38554000, 0x38556000, 0x38558000, 0x3855a000, 0x3855c000, 0x3855e000, 0x38560000, 0x38562000, 0x38564000, 0x38566000, 0x38568000, 0x3856a000, 0x3856c000, 0x3856e000, 0x38570000, 0x38572000, 0x38574000, 0x38576000, 0x38578000, 0x3857a000, 0x3857c000, 0x3857e000, 0x38580000, 0x38582000, 0x38584000, 0x38586000, 0x38588000, 0x3858a000, 0x3858c000, 0x3858e000, 0x38590000, 0x38592000, 0x38594000, 0x38596000, 0x38598000, 0x3859a000, 0x3859c000, 0x3859e000, 0x385a0000, 0x385a2000, 0x385a4000, 0x385a6000, 0x385a8000, 0x385aa000, 0x385ac000, 0x385ae000, 0x385b0000, 0x385b2000, 0x385b4000, 0x385b6000, 0x385b8000, 0x385ba000, 0x385bc000, 0x385be000, 0x385c0000, 0x385c2000, 0x385c4000, 0x385c6000, 0x385c8000, 0x385ca000, 0x385cc000, 0x385ce000, 0x385d0000, 0x385d2000, 0x385d4000, 0x385d6000, 0x385d8000, 0x385da000, 0x385dc000, 0x385de000, 0x385e0000, 0x385e2000, 0x385e4000, 0x385e6000, 0x385e8000, 0x385ea000, 0x385ec000, 0x385ee000, 0x385f0000, 0x385f2000, 0x385f4000, 0x385f6000, 0x385f8000, 0x385fa000, 0x385fc000, 0x385fe000, 0x38600000, 0x38602000, 0x38604000, 0x38606000, 0x38608000, 0x3860a000, 0x3860c000, 0x3860e000, 0x38610000, 0x38612000, 0x38614000, 0x38616000, 0x38618000, 0x3861a000, 0x3861c000, 0x3861e000, 0x38620000, 0x38622000, 0x38624000, 0x38626000, 0x38628000, 0x3862a000, 0x3862c000, 0x3862e000, 0x38630000, 0x38632000, 0x38634000, 0x38636000, 0x38638000, 0x3863a000, 0x3863c000, 0x3863e000, 0x38640000, 0x38642000, 0x38644000, 0x38646000, 0x38648000, 0x3864a000, 0x3864c000, 0x3864e000, 0x38650000, 0x38652000, 0x38654000, 0x38656000, 0x38658000, 0x3865a000, 0x3865c000, 0x3865e000, 0x38660000, 0x38662000, 0x38664000, 0x38666000, 0x38668000, 0x3866a000, 0x3866c000, 0x3866e000, 0x38670000, 0x38672000, 0x38674000, 0x38676000, 0x38678000, 0x3867a000, 0x3867c000, 0x3867e000, 0x38680000, 0x38682000, 0x38684000, 0x38686000, 0x38688000, 0x3868a000, 0x3868c000, 0x3868e000, 0x38690000, 0x38692000, 0x38694000, 0x38696000, 0x38698000, 0x3869a000, 0x3869c000, 0x3869e000, 0x386a0000, 0x386a2000, 0x386a4000, 0x386a6000, 0x386a8000, 0x386aa000, 0x386ac000, 0x386ae000, 0x386b0000, 0x386b2000, 0x386b4000, 0x386b6000, 0x386b8000, 0x386ba000, 0x386bc000, 0x386be000, 0x386c0000, 0x386c2000, 0x386c4000, 0x386c6000, 0x386c8000, 0x386ca000, 0x386cc000, 0x386ce000, 0x386d0000, 0x386d2000, 0x386d4000, 0x386d6000, 0x386d8000, 0x386da000, 0x386dc000, 0x386de000, 0x386e0000, 0x386e2000, 0x386e4000, 0x386e6000, 0x386e8000, 0x386ea000, 0x386ec000, 0x386ee000, 0x386f0000, 0x386f2000, 0x386f4000, 0x386f6000, 0x386f8000, 0x386fa000, 0x386fc000, 0x386fe000, 0x38700000, 0x38702000, 0x38704000, 0x38706000, 0x38708000, 0x3870a000, 0x3870c000, 0x3870e000, 0x38710000, 0x38712000, 0x38714000, 0x38716000, 0x38718000, 0x3871a000, 0x3871c000, 0x3871e000, 0x38720000, 0x38722000, 0x38724000, 0x38726000, 0x38728000, 0x3872a000, 0x3872c000, 0x3872e000, 0x38730000, 0x38732000, 0x38734000, 0x38736000, 0x38738000, 0x3873a000, 0x3873c000, 0x3873e000, 0x38740000, 0x38742000, 0x38744000, 0x38746000, 0x38748000, 0x3874a000, 0x3874c000, 0x3874e000, 0x38750000, 0x38752000, 0x38754000, 0x38756000, 0x38758000, 0x3875a000, 0x3875c000, 0x3875e000, 0x38760000, 0x38762000, 0x38764000, 0x38766000, 0x38768000, 0x3876a000, 0x3876c000, 0x3876e000, 0x38770000, 0x38772000, 0x38774000, 0x38776000, 0x38778000, 0x3877a000, 0x3877c000, 0x3877e000, 0x38780000, 0x38782000, 0x38784000, 0x38786000, 0x38788000, 0x3878a000, 0x3878c000, 0x3878e000, 0x38790000, 0x38792000, 0x38794000, 0x38796000, 0x38798000, 0x3879a000, 0x3879c000, 0x3879e000, 0x387a0000, 0x387a2000, 0x387a4000, 0x387a6000, 0x387a8000, 0x387aa000, 0x387ac000, 0x387ae000, 0x387b0000, 0x387b2000, 0x387b4000, 0x387b6000, 0x387b8000, 0x387ba000, 0x387bc000, 0x387be000, 0x387c0000, 0x387c2000, 0x387c4000, 0x387c6000, 0x387c8000, 0x387ca000, 0x387cc000, 0x387ce000, 0x387d0000, 0x387d2000, 0x387d4000, 0x387d6000, 0x387d8000, 0x387da000, 0x387dc000, 0x387de000, 0x387e0000, 0x387e2000, 0x387e4000, 0x387e6000, 0x387e8000, 0x387ea000, 0x387ec000, 0x387ee000, 0x387f0000, 0x387f2000, 0x387f4000, 0x387f6000, 0x387f8000, 0x387fa000, 0x387fc000, 0x387fe000, }; const static unsigned g_exponent[64] = { 0x00000000, 0x00800000, 0x01000000, 0x01800000, 0x02000000, 0x02800000, 0x03000000, 0x03800000, 0x04000000, 0x04800000, 0x05000000, 0x05800000, 0x06000000, 0x06800000, 0x07000000, 0x07800000, 0x08000000, 0x08800000, 0x09000000, 0x09800000, 0x0a000000, 0x0a800000, 0x0b000000, 0x0b800000, 0x0c000000, 0x0c800000, 0x0d000000, 0x0d800000, 0x0e000000, 0x0e800000, 0x0f000000, 0x47800000, 0x80000000, 0x80800000, 0x81000000, 0x81800000, 0x82000000, 0x82800000, 0x83000000, 0x83800000, 0x84000000, 0x84800000, 0x85000000, 0x85800000, 0x86000000, 0x86800000, 0x87000000, 0x87800000, 0x88000000, 0x88800000, 0x89000000, 0x89800000, 0x8a000000, 0x8a800000, 0x8b000000, 0x8b800000, 0x8c000000, 0x8c800000, 0x8d000000, 0x8d800000, 0x8e000000, 0x8e800000, 0x8f000000, 0xc7800000, }; const static unsigned g_offset[64] = { 0x00000000, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000000, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, 0x00000400, }; float float16ToFloat32(unsigned short h) { unsigned i32 = g_mantissa[g_offset[h >> 10] + (h & 0x3ff)] + g_exponent[h >> 10]; return *(float*) &i32; } } freshplayerplugin-0.3.9/3rdparty/angle/src/common/Float16ToFloat32.py000066400000000000000000000035511321746453100254410ustar00rootroot00000000000000# Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # # This script generates a function that converts 16-bit precision floating # point numbers to 32-bit. # It is based on ftp://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf. def convertMantissa(i): if i == 0: return 0 elif i < 1024: m = i << 13 e = 0 while not (m & 0x00800000): e -= 0x00800000 m = m << 1 m &= ~0x00800000 e += 0x38800000 return m | e else: return 0x38000000 + ((i - 1024) << 13) def convertExponent(i): if i == 0: return 0 elif i in range(1, 31): return i << 23 elif i == 31: return 0x47800000 elif i == 32: return 0x80000000 elif i in range(33, 63): return 0x80000000 + ((i - 32) << 23) else: return 0xC7800000 def convertOffset(i): if i == 0 or i == 32: return 0 else: return 1024 print """// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // This file is automatically generated. namespace gl { """ print "const static unsigned g_mantissa[2048] = {" for i in range(0, 2048): print " %#010x," % convertMantissa(i) print "};\n" print "const static unsigned g_exponent[64] = {" for i in range(0, 64): print " %#010x," % convertExponent(i) print "};\n" print "const static unsigned g_offset[64] = {" for i in range(0, 64): print " %#010x," % convertOffset(i) print "};\n" print """float float16ToFloat32(unsigned short h) { unsigned i32 = g_mantissa[g_offset[h >> 10] + (h & 0x3ff)] + g_exponent[h >> 10]; return *(float*) &i32; } } """ freshplayerplugin-0.3.9/3rdparty/angle/src/common/angleutils.h000066400000000000000000000067441321746453100245440ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // angleutils.h: Common ANGLE utilities. #ifndef COMMON_ANGLEUTILS_H_ #define COMMON_ANGLEUTILS_H_ #include "common/platform.h" #include #include #include #include #include #include #include // A helper class to disallow copy and assignment operators namespace angle { class NonCopyable { public: NonCopyable() = default; ~NonCopyable() = default; protected: NonCopyable(const NonCopyable&) = delete; void operator=(const NonCopyable&) = delete; }; } template inline size_t ArraySize(T(&)[N]) { return N; } template void SafeRelease(T (&resourceBlock)[N]) { for (unsigned int i = 0; i < N; i++) { SafeRelease(resourceBlock[i]); } } template void SafeRelease(T& resource) { if (resource) { resource->Release(); resource = NULL; } } template void SafeDelete(T*& resource) { delete resource; resource = NULL; } template void SafeDeleteContainer(T& resource) { for (typename T::iterator i = resource.begin(); i != resource.end(); i++) { SafeDelete(*i); } resource.clear(); } template void SafeDeleteArray(T*& resource) { delete[] resource; resource = NULL; } // Provide a less-than function for comparing structs // Note: struct memory must be initialized to zero, because of packing gaps template inline bool StructLessThan(const T &a, const T &b) { return (memcmp(&a, &b, sizeof(T)) < 0); } // Provide a less-than function for comparing structs // Note: struct memory must be initialized to zero, because of packing gaps template inline bool StructEquals(const T &a, const T &b) { return (memcmp(&a, &b, sizeof(T)) == 0); } template inline void StructZero(T *obj) { memset(obj, 0, sizeof(T)); } template inline bool IsMaskFlagSet(T mask, T flag) { // Handles multibit flags as well return (mask & flag) == flag; } inline const char* MakeStaticString(const std::string &str) { static std::set strings; std::set::iterator it = strings.find(str); if (it != strings.end()) { return it->c_str(); } return strings.insert(str).first->c_str(); } inline std::string ArrayString(unsigned int i) { // We assume UINT_MAX and GL_INVALID_INDEX are equal // See DynamicHLSL.cpp if (i == UINT_MAX) { return ""; } std::stringstream strstr; strstr << "["; strstr << i; strstr << "]"; return strstr.str(); } inline std::string Str(int i) { std::stringstream strstr; strstr << i; return strstr.str(); } size_t FormatStringIntoVector(const char *fmt, va_list vararg, std::vector& buffer); std::string FormatString(const char *fmt, va_list vararg); std::string FormatString(const char *fmt, ...); // snprintf is not defined with MSVC prior to to msvc14 #if defined(_MSC_VER) && _MSC_VER < 1900 #define snprintf _snprintf #endif #define GL_BGRA4_ANGLEX 0x6ABC #define GL_BGR5_A1_ANGLEX 0x6ABD #define GL_INT_64_ANGLEX 0x6ABE #define GL_STRUCT_ANGLEX 0x6ABF // Hidden enum for the NULL D3D device type. #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x6AC0 #endif // COMMON_ANGLEUTILS_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/common/debug.h000066400000000000000000000110321321746453100234450ustar00rootroot00000000000000// // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // debug.h: Debugging utilities. #ifndef COMMON_DEBUG_H_ #define COMMON_DEBUG_H_ #include #include #include #include "common/angleutils.h" #if !defined(TRACE_OUTPUT_FILE) #define TRACE_OUTPUT_FILE "debug.txt" #endif namespace gl { enum MessageType { MESSAGE_TRACE, MESSAGE_FIXME, MESSAGE_ERR, MESSAGE_EVENT, }; // Outputs text to the debugging log, or the debugging window void trace(bool traceInDebugOnly, MessageType messageType, const char *format, ...); // Pairs a D3D begin event with an end event. class ScopedPerfEventHelper : angle::NonCopyable { public: ScopedPerfEventHelper(const char* format, ...); ~ScopedPerfEventHelper(); }; // Wraps the D3D9/D3D11 debug annotation functions. class DebugAnnotator : angle::NonCopyable { public: DebugAnnotator() { }; virtual ~DebugAnnotator() { }; virtual void beginEvent(const wchar_t *eventName) = 0; virtual void endEvent() = 0; virtual void setMarker(const wchar_t *markerName) = 0; virtual bool getStatus() = 0; }; void InitializeDebugAnnotations(DebugAnnotator *debugAnnotator); void UninitializeDebugAnnotations(); bool DebugAnnotationsActive(); } #if defined(ANGLE_ENABLE_DEBUG_TRACE) || defined(ANGLE_ENABLE_DEBUG_ANNOTATIONS) #define ANGLE_TRACE_ENABLED #endif #define ANGLE_EMPTY_STATEMENT for (;;) break // A macro to output a trace of a function call and its arguments to the debugging log #if defined(ANGLE_TRACE_ENABLED) #define TRACE(message, ...) gl::trace(true, gl::MESSAGE_TRACE, "trace: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__) #else #define TRACE(message, ...) (void(0)) #endif // A macro to output a function call and its arguments to the debugging log, to denote an item in need of fixing. #if defined(ANGLE_TRACE_ENABLED) #define FIXME(message, ...) gl::trace(false, gl::MESSAGE_FIXME, "fixme: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__) #else #define FIXME(message, ...) (void(0)) #endif // A macro to output a function call and its arguments to the debugging log, in case of error. #if defined(ANGLE_TRACE_ENABLED) #define ERR(message, ...) gl::trace(false, gl::MESSAGE_ERR, "err: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__) #else #define ERR(message, ...) (void(0)) #endif // A macro to log a performance event around a scope. #if defined(ANGLE_TRACE_ENABLED) #if defined(_MSC_VER) #define EVENT(message, ...) gl::ScopedPerfEventHelper scopedPerfEventHelper ## __LINE__("%s" message "\n", __FUNCTION__, __VA_ARGS__); #else #define EVENT(message, ...) gl::ScopedPerfEventHelper scopedPerfEventHelper(message "\n", ##__VA_ARGS__); #endif // _MSC_VER #else #define EVENT(message, ...) (void(0)) #endif #if defined(ANGLE_TRACE_ENABLED) #undef ANGLE_TRACE_ENABLED #endif // A macro asserting a condition and outputting failures to the debug log #if !defined(NDEBUG) #define ASSERT(expression) { \ if(!(expression)) \ ERR("\t! Assert failed in %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \ assert(expression); \ } ANGLE_EMPTY_STATEMENT #define UNUSED_ASSERTION_VARIABLE(variable) #else #define ASSERT(expression) (void(0)) #define UNUSED_ASSERTION_VARIABLE(variable) ((void)variable) #endif #ifndef ANGLE_ENABLE_DEBUG_TRACE #define UNUSED_TRACE_VARIABLE(variable) ((void)variable) #else #define UNUSED_TRACE_VARIABLE(variable) #endif // A macro to indicate unimplemented functionality #if defined (ANGLE_TEST_CONFIG) #define NOASSERT_UNIMPLEMENTED 1 #endif // Define NOASSERT_UNIMPLEMENTED to non zero to skip the assert fail in the unimplemented checks // This will allow us to test with some automated test suites (eg dEQP) without crashing #ifndef NOASSERT_UNIMPLEMENTED #define NOASSERT_UNIMPLEMENTED 0 #endif #if !defined(NDEBUG) #define UNIMPLEMENTED() { \ FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \ assert(NOASSERT_UNIMPLEMENTED); \ } ANGLE_EMPTY_STATEMENT #else #define UNIMPLEMENTED() FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__) #endif // A macro for code which is not expected to be reached under valid assumptions #if !defined(NDEBUG) #define UNREACHABLE() { \ ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__); \ assert(false); \ } ANGLE_EMPTY_STATEMENT #else #define UNREACHABLE() ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__) #endif #endif // COMMON_DEBUG_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/common/mathutil.h000066400000000000000000000516501321746453100242200ustar00rootroot00000000000000// // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // mathutil.h: Math and bit manipulation functions. #ifndef COMMON_MATHUTIL_H_ #define COMMON_MATHUTIL_H_ #include "common/debug.h" #include "common/platform.h" #include #include #include #include #include #include namespace gl { const unsigned int Float32One = 0x3F800000; const unsigned short Float16One = 0x3C00; struct Vector4 { Vector4() {} Vector4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {} float x; float y; float z; float w; }; inline bool isPow2(int x) { return (x & (x - 1)) == 0 && (x != 0); } inline int log2(int x) { int r = 0; while ((x >> r) > 1) r++; return r; } inline unsigned int ceilPow2(unsigned int x) { if (x != 0) x--; x |= x >> 1; x |= x >> 2; x |= x >> 4; x |= x >> 8; x |= x >> 16; x++; return x; } inline int clampToInt(unsigned int x) { return static_cast(std::min(x, static_cast(std::numeric_limits::max()))); } template inline DestT clampCast(SrcT value) { // This assumes SrcT can properly represent DestT::min/max // Unfortunately we can't use META_ASSERT without C++11 constexpr support ASSERT(static_cast(static_cast(std::numeric_limits::min())) == std::numeric_limits::min()); ASSERT(static_cast(static_cast(std::numeric_limits::max())) == std::numeric_limits::max()); SrcT lo = static_cast(std::numeric_limits::min()); SrcT hi = static_cast(std::numeric_limits::max()); return static_cast(value > lo ? (value > hi ? hi : value) : lo); } template inline T clamp(T x, MIN min, MAX max) { // Since NaNs fail all comparison tests, a NaN value will default to min return x > min ? (x > max ? max : x) : min; } inline float clamp01(float x) { return clamp(x, 0.0f, 1.0f); } template inline unsigned int unorm(float x) { const unsigned int max = 0xFFFFFFFF >> (32 - n); if (x > 1) { return max; } else if (x < 0) { return 0; } else { return (unsigned int)(max * x + 0.5f); } } inline bool supportsSSE2() { #if defined(ANGLE_PLATFORM_WINDOWS) && !defined(_M_ARM) static bool checked = false; static bool supports = false; if (checked) { return supports; } int info[4]; __cpuid(info, 0); if (info[0] >= 1) { __cpuid(info, 1); supports = (info[3] >> 26) & 1; } checked = true; return supports; #else UNIMPLEMENTED(); return false; #endif } template destType bitCast(const sourceType &source) { size_t copySize = std::min(sizeof(destType), sizeof(sourceType)); destType output; memcpy(&output, &source, copySize); return output; } inline unsigned short float32ToFloat16(float fp32) { unsigned int fp32i = (unsigned int&)fp32; unsigned int sign = (fp32i & 0x80000000) >> 16; unsigned int abs = fp32i & 0x7FFFFFFF; if(abs > 0x47FFEFFF) // Infinity { return static_cast(sign | 0x7FFF); } else if(abs < 0x38800000) // Denormal { unsigned int mantissa = (abs & 0x007FFFFF) | 0x00800000; int e = 113 - (abs >> 23); if(e < 24) { abs = mantissa >> e; } else { abs = 0; } return static_cast(sign | (abs + 0x00000FFF + ((abs >> 13) & 1)) >> 13); } else { return static_cast(sign | (abs + 0xC8000000 + 0x00000FFF + ((abs >> 13) & 1)) >> 13); } } float float16ToFloat32(unsigned short h); unsigned int convertRGBFloatsTo999E5(float red, float green, float blue); void convert999E5toRGBFloats(unsigned int input, float *red, float *green, float *blue); inline unsigned short float32ToFloat11(float fp32) { const unsigned int float32MantissaMask = 0x7FFFFF; const unsigned int float32ExponentMask = 0x7F800000; const unsigned int float32SignMask = 0x80000000; const unsigned int float32ValueMask = ~float32SignMask; const unsigned int float32ExponentFirstBit = 23; const unsigned int float32ExponentBias = 127; const unsigned short float11Max = 0x7BF; const unsigned short float11MantissaMask = 0x3F; const unsigned short float11ExponentMask = 0x7C0; const unsigned short float11BitMask = 0x7FF; const unsigned int float11ExponentBias = 14; const unsigned int float32Maxfloat11 = 0x477E0000; const unsigned int float32Minfloat11 = 0x38800000; const unsigned int float32Bits = bitCast(fp32); const bool float32Sign = (float32Bits & float32SignMask) == float32SignMask; unsigned int float32Val = float32Bits & float32ValueMask; if ((float32Val & float32ExponentMask) == float32ExponentMask) { // INF or NAN if ((float32Val & float32MantissaMask) != 0) { return float11ExponentMask | (((float32Val >> 17) | (float32Val >> 11) | (float32Val >> 6) | (float32Val)) & float11MantissaMask); } else if (float32Sign) { // -INF is clamped to 0 since float11 is positive only return 0; } else { return float11ExponentMask; } } else if (float32Sign) { // float11 is positive only, so clamp to zero return 0; } else if (float32Val > float32Maxfloat11) { // The number is too large to be represented as a float11, set to max return float11Max; } else { if (float32Val < float32Minfloat11) { // The number is too small to be represented as a normalized float11 // Convert it to a denormalized value. const unsigned int shift = (float32ExponentBias - float11ExponentBias) - (float32Val >> float32ExponentFirstBit); float32Val = ((1 << float32ExponentFirstBit) | (float32Val & float32MantissaMask)) >> shift; } else { // Rebias the exponent to represent the value as a normalized float11 float32Val += 0xC8000000; } return ((float32Val + 0xFFFF + ((float32Val >> 17) & 1)) >> 17) & float11BitMask; } } inline unsigned short float32ToFloat10(float fp32) { const unsigned int float32MantissaMask = 0x7FFFFF; const unsigned int float32ExponentMask = 0x7F800000; const unsigned int float32SignMask = 0x80000000; const unsigned int float32ValueMask = ~float32SignMask; const unsigned int float32ExponentFirstBit = 23; const unsigned int float32ExponentBias = 127; const unsigned short float10Max = 0x3DF; const unsigned short float10MantissaMask = 0x1F; const unsigned short float10ExponentMask = 0x3E0; const unsigned short float10BitMask = 0x3FF; const unsigned int float10ExponentBias = 14; const unsigned int float32Maxfloat10 = 0x477C0000; const unsigned int float32Minfloat10 = 0x38800000; const unsigned int float32Bits = bitCast(fp32); const bool float32Sign = (float32Bits & float32SignMask) == float32SignMask; unsigned int float32Val = float32Bits & float32ValueMask; if ((float32Val & float32ExponentMask) == float32ExponentMask) { // INF or NAN if ((float32Val & float32MantissaMask) != 0) { return float10ExponentMask | (((float32Val >> 18) | (float32Val >> 13) | (float32Val >> 3) | (float32Val)) & float10MantissaMask); } else if (float32Sign) { // -INF is clamped to 0 since float11 is positive only return 0; } else { return float10ExponentMask; } } else if (float32Sign) { // float10 is positive only, so clamp to zero return 0; } else if (float32Val > float32Maxfloat10) { // The number is too large to be represented as a float11, set to max return float10Max; } else { if (float32Val < float32Minfloat10) { // The number is too small to be represented as a normalized float11 // Convert it to a denormalized value. const unsigned int shift = (float32ExponentBias - float10ExponentBias) - (float32Val >> float32ExponentFirstBit); float32Val = ((1 << float32ExponentFirstBit) | (float32Val & float32MantissaMask)) >> shift; } else { // Rebias the exponent to represent the value as a normalized float11 float32Val += 0xC8000000; } return ((float32Val + 0x1FFFF + ((float32Val >> 18) & 1)) >> 18) & float10BitMask; } } inline float float11ToFloat32(unsigned short fp11) { unsigned short exponent = (fp11 >> 6) & 0x1F; unsigned short mantissa = fp11 & 0x3F; if (exponent == 0x1F) { // INF or NAN return bitCast(0x7f800000 | (mantissa << 17)); } else { if (exponent != 0) { // normalized } else if (mantissa != 0) { // The value is denormalized exponent = 1; do { exponent--; mantissa <<= 1; } while ((mantissa & 0x40) == 0); mantissa = mantissa & 0x3F; } else // The value is zero { exponent = static_cast(-112); } return bitCast(((exponent + 112) << 23) | (mantissa << 17)); } } inline float float10ToFloat32(unsigned short fp11) { unsigned short exponent = (fp11 >> 5) & 0x1F; unsigned short mantissa = fp11 & 0x1F; if (exponent == 0x1F) { // INF or NAN return bitCast(0x7f800000 | (mantissa << 17)); } else { if (exponent != 0) { // normalized } else if (mantissa != 0) { // The value is denormalized exponent = 1; do { exponent--; mantissa <<= 1; } while ((mantissa & 0x20) == 0); mantissa = mantissa & 0x1F; } else // The value is zero { exponent = static_cast(-112); } return bitCast(((exponent + 112) << 23) | (mantissa << 18)); } } template inline float normalizedToFloat(T input) { static_assert(std::numeric_limits::is_integer, "T must be an integer."); const float inverseMax = 1.0f / std::numeric_limits::max(); return input * inverseMax; } template inline float normalizedToFloat(T input) { static_assert(std::numeric_limits::is_integer, "T must be an integer."); static_assert(inputBitCount < (sizeof(T) * 8), "T must have more bits than inputBitCount."); const float inverseMax = 1.0f / ((1 << inputBitCount) - 1); return input * inverseMax; } template inline T floatToNormalized(float input) { return static_cast(std::numeric_limits::max() * input + 0.5f); } template inline T floatToNormalized(float input) { static_assert(outputBitCount < (sizeof(T) * 8), "T must have more bits than outputBitCount."); return static_cast(((1 << outputBitCount) - 1) * input + 0.5f); } template inline T getShiftedData(T input) { static_assert(inputBitCount + inputBitStart <= (sizeof(T) * 8), "T must have at least as many bits as inputBitCount + inputBitStart."); const T mask = (1 << inputBitCount) - 1; return (input >> inputBitStart) & mask; } template inline T shiftData(T input) { static_assert(inputBitCount + inputBitStart <= (sizeof(T) * 8), "T must have at least as many bits as inputBitCount + inputBitStart."); const T mask = (1 << inputBitCount) - 1; return (input & mask) << inputBitStart; } inline unsigned char average(unsigned char a, unsigned char b) { return ((a ^ b) >> 1) + (a & b); } inline signed char average(signed char a, signed char b) { return ((short)a + (short)b) / 2; } inline unsigned short average(unsigned short a, unsigned short b) { return ((a ^ b) >> 1) + (a & b); } inline signed short average(signed short a, signed short b) { return ((int)a + (int)b) / 2; } inline unsigned int average(unsigned int a, unsigned int b) { return ((a ^ b) >> 1) + (a & b); } inline signed int average(signed int a, signed int b) { return ((long long)a + (long long)b) / 2; } inline float average(float a, float b) { return (a + b) * 0.5f; } inline unsigned short averageHalfFloat(unsigned short a, unsigned short b) { return float32ToFloat16((float16ToFloat32(a) + float16ToFloat32(b)) * 0.5f); } inline unsigned int averageFloat11(unsigned int a, unsigned int b) { return float32ToFloat11((float11ToFloat32(static_cast(a)) + float11ToFloat32(static_cast(b))) * 0.5f); } inline unsigned int averageFloat10(unsigned int a, unsigned int b) { return float32ToFloat10((float10ToFloat32(static_cast(a)) + float10ToFloat32(static_cast(b))) * 0.5f); } // Represents intervals of the type [a, b) template struct Range { Range() {} Range(T lo, T hi) : start(lo), end(hi) { ASSERT(lo <= hi); } T start; T end; T length() const { return end - start; } bool intersects(Range other) { if (start <= other.start) { return other.start < end; } else { return start < other.end; } } void extend(T value) { start = value > start ? value : start; end = value < end ? value : end; } bool empty() const { return end <= start; } }; typedef Range RangeI; typedef Range RangeUI; // First, both normalized floating-point values are converted into 16-bit integer values. // Then, the results are packed into the returned 32-bit unsigned integer. // The first float value will be written to the least significant bits of the output; // the last float value will be written to the most significant bits. // The conversion of each value to fixed point is done as follows : // packSnorm2x16 : round(clamp(c, -1, +1) * 32767.0) inline uint32_t packSnorm2x16(float f1, float f2) { uint16_t leastSignificantBits = static_cast(roundf(clamp(f1, -1.0f, 1.0f) * 32767.0f)); uint16_t mostSignificantBits = static_cast(roundf(clamp(f2, -1.0f, 1.0f) * 32767.0f)); return static_cast(mostSignificantBits) << 16 | static_cast(leastSignificantBits); } // First, unpacks a single 32-bit unsigned integer u into a pair of 16-bit unsigned integers. Then, each // component is converted to a normalized floating-point value to generate the returned two float values. // The first float value will be extracted from the least significant bits of the input; // the last float value will be extracted from the most-significant bits. // The conversion for unpacked fixed-point value to floating point is done as follows: // unpackSnorm2x16 : clamp(f / 32767.0, -1, +1) inline void unpackSnorm2x16(uint32_t u, float *f1, float *f2) { int16_t leastSignificantBits = static_cast(u & 0xFFFF); int16_t mostSignificantBits = static_cast(u >> 16); *f1 = clamp(static_cast(leastSignificantBits) / 32767.0f, -1.0f, 1.0f); *f2 = clamp(static_cast(mostSignificantBits) / 32767.0f, -1.0f, 1.0f); } // First, both normalized floating-point values are converted into 16-bit integer values. // Then, the results are packed into the returned 32-bit unsigned integer. // The first float value will be written to the least significant bits of the output; // the last float value will be written to the most significant bits. // The conversion of each value to fixed point is done as follows: // packUnorm2x16 : round(clamp(c, 0, +1) * 65535.0) inline uint32_t packUnorm2x16(float f1, float f2) { uint16_t leastSignificantBits = static_cast(roundf(clamp(f1, 0.0f, 1.0f) * 65535.0f)); uint16_t mostSignificantBits = static_cast(roundf(clamp(f2, 0.0f, 1.0f) * 65535.0f)); return static_cast(mostSignificantBits) << 16 | static_cast(leastSignificantBits); } // First, unpacks a single 32-bit unsigned integer u into a pair of 16-bit unsigned integers. Then, each // component is converted to a normalized floating-point value to generate the returned two float values. // The first float value will be extracted from the least significant bits of the input; // the last float value will be extracted from the most-significant bits. // The conversion for unpacked fixed-point value to floating point is done as follows: // unpackUnorm2x16 : f / 65535.0 inline void unpackUnorm2x16(uint32_t u, float *f1, float *f2) { uint16_t leastSignificantBits = static_cast(u & 0xFFFF); uint16_t mostSignificantBits = static_cast(u >> 16); *f1 = static_cast(leastSignificantBits) / 65535.0f; *f2 = static_cast(mostSignificantBits) / 65535.0f; } // Returns an unsigned integer obtained by converting the two floating-point values to the 16-bit // floating-point representation found in the OpenGL ES Specification, and then packing these // two 16-bit integers into a 32-bit unsigned integer. // f1: The 16 least-significant bits of the result; // f2: The 16 most-significant bits. inline uint32_t packHalf2x16(float f1, float f2) { uint16_t leastSignificantBits = static_cast(float32ToFloat16(f1)); uint16_t mostSignificantBits = static_cast(float32ToFloat16(f2)); return static_cast(mostSignificantBits) << 16 | static_cast(leastSignificantBits); } // Returns two floating-point values obtained by unpacking a 32-bit unsigned integer into a pair of 16-bit values, // interpreting those values as 16-bit floating-point numbers according to the OpenGL ES Specification, // and converting them to 32-bit floating-point values. // The first float value is obtained from the 16 least-significant bits of u; // the second component is obtained from the 16 most-significant bits of u. inline void unpackHalf2x16(uint32_t u, float *f1, float *f2) { uint16_t leastSignificantBits = static_cast(u & 0xFFFF); uint16_t mostSignificantBits = static_cast(u >> 16); *f1 = float16ToFloat32(leastSignificantBits); *f2 = float16ToFloat32(mostSignificantBits); } // Returns whether the argument is Not a Number. // IEEE 754 single precision NaN representation: Exponent(8 bits) - 255, Mantissa(23 bits) - non-zero. inline bool isNaN(float f) { // Exponent mask: ((1u << 8) - 1u) << 23 = 0x7f800000u // Mantissa mask: ((1u << 23) - 1u) = 0x7fffffu return ((bitCast(f) & 0x7f800000u) == 0x7f800000u) && (bitCast(f) & 0x7fffffu); } // Returns whether the argument is infinity. // IEEE 754 single precision infinity representation: Exponent(8 bits) - 255, Mantissa(23 bits) - zero. inline bool isInf(float f) { // Exponent mask: ((1u << 8) - 1u) << 23 = 0x7f800000u // Mantissa mask: ((1u << 23) - 1u) = 0x7fffffu return ((bitCast(f) & 0x7f800000u) == 0x7f800000u) && !(bitCast(f) & 0x7fffffu); } } namespace rx { template T roundUp(const T value, const T alignment) { return value + alignment - 1 - (value - 1) % alignment; } inline unsigned int UnsignedCeilDivide(unsigned int value, unsigned int divisor) { unsigned int divided = value / divisor; return (divided + ((value % divisor == 0) ? 0 : 1)); } template inline bool IsUnsignedAdditionSafe(T lhs, T rhs) { static_assert(!std::numeric_limits::is_signed, "T must be unsigned."); return (rhs <= std::numeric_limits::max() - lhs); } template inline bool IsUnsignedMultiplicationSafe(T lhs, T rhs) { static_assert(!std::numeric_limits::is_signed, "T must be unsigned."); return (lhs == T(0) || rhs == T(0) || (rhs <= std::numeric_limits::max() / lhs)); } template inline bool IsIntegerCastSafe(BigIntT bigValue) { return (static_cast(static_cast(bigValue)) == bigValue); } #if defined(_MSC_VER) #define ANGLE_ROTL(x,y) _rotl(x,y) #define ANGLE_ROTR16(x,y) _rotr16(x,y) #else inline uint32_t RotL(uint32_t x, int8_t r) { return (x << r) | (x >> (32 - r)); } inline uint16_t RotR16(uint16_t x, int8_t r) { return (x >> r) | (x << (16 - r)); } #define ANGLE_ROTL(x,y) RotL(x,y) #define ANGLE_ROTR16(x,y) RotR16(x,y) #endif // namespace rx } #endif // COMMON_MATHUTIL_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/common/matrix_utils.h000066400000000000000000000303061321746453100251100ustar00rootroot00000000000000// // Copyright 2015 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // Matrix: // Utility class implementing various matrix operations. // Supports matrices with minimum 2 and maximum 4 number of rows/columns. // // TODO: Check if we can merge Matrix.h in sample_util with this and replace it with this implementation. // TODO: Rename this file to Matrix.h once we remove Matrix.h in sample_util. #ifndef COMMON_MATRIX_UTILS_H_ #define COMMON_MATRIX_UTILS_H_ #include #include "common/debug.h" namespace angle { template class Matrix { public: Matrix(const std::vector &elements, const unsigned int &numRows, const unsigned int &numCols) : mElements(elements), mRows(numRows), mCols(numCols) { ASSERT(rows() >= 1 && rows() <= 4); ASSERT(columns() >= 1 && columns() <= 4); } Matrix(const std::vector &elements, const unsigned int &size) : mElements(elements), mRows(size), mCols(size) { ASSERT(rows() >= 1 && rows() <= 4); ASSERT(columns() >= 1 && columns() <= 4); } Matrix(const T *elements, const unsigned int &size) : mRows(size), mCols(size) { ASSERT(rows() >= 1 && rows() <= 4); ASSERT(columns() >= 1 && columns() <= 4); for (size_t i = 0; i < size * size; i++) mElements.push_back(elements[i]); } const T &operator()(const unsigned int &rowIndex, const unsigned int &columnIndex) const { return mElements[rowIndex * columns() + columnIndex]; } T &operator()(const unsigned int &rowIndex, const unsigned int &columnIndex) { return mElements[rowIndex * columns() + columnIndex]; } const T &at(const unsigned int &rowIndex, const unsigned int &columnIndex) const { return operator()(rowIndex, columnIndex); } Matrix operator*(const Matrix &m) { ASSERT(columns() == m.rows()); unsigned int resultRows = rows(); unsigned int resultCols = m.columns(); Matrix result(std::vector(resultRows * resultCols), resultRows, resultCols); for (unsigned int i = 0; i < resultRows; i++) { for (unsigned int j = 0; j < resultCols; j++) { T tmp = 0.0f; for (unsigned int k = 0; k < columns(); k++) tmp += at(i, k) * m(k, j); result(i, j) = tmp; } } return result; } unsigned int size() const { ASSERT(rows() == columns()); return rows(); } unsigned int rows() const { return mRows; } unsigned int columns() const { return mCols; } std::vector elements() const { return mElements; } Matrix compMult(const Matrix &mat1) const { Matrix result(std::vector(mElements.size()), size()); for (unsigned int i = 0; i < columns(); i++) for (unsigned int j = 0; j < rows(); j++) result(i, j) = at(i, j) * mat1(i, j); return result; } Matrix outerProduct(const Matrix &mat1) const { unsigned int cols = mat1.columns(); Matrix result(std::vector(rows() * cols), rows(), cols); for (unsigned int i = 0; i < rows(); i++) for (unsigned int j = 0; j < cols; j++) result(i, j) = at(i, 0) * mat1(0, j); return result; } Matrix transpose() const { Matrix result(std::vector(mElements.size()), columns(), rows()); for (unsigned int i = 0; i < columns(); i++) for (unsigned int j = 0; j < rows(); j++) result(i, j) = at(j, i); return result; } T determinant() const { ASSERT(rows() == columns()); switch (size()) { case 2: return at(0, 0) * at(1, 1) - at(0, 1) * at(1, 0); case 3: return at(0, 0) * at(1, 1) * at(2, 2) + at(0, 1) * at(1, 2) * at(2, 0) + at(0, 2) * at(1, 0) * at(2, 1) - at(0, 2) * at(1, 1) * at(2, 0) - at(0, 1) * at(1, 0) * at(2, 2) - at(0, 0) * at(1, 2) * at(2, 1); case 4: { const float minorMatrices[4][3 * 3] = { { at(1, 1), at(2, 1), at(3, 1), at(1, 2), at(2, 2), at(3, 2), at(1, 3), at(2, 3), at(3, 3), }, { at(1, 0), at(2, 0), at(3, 0), at(1, 2), at(2, 2), at(3, 2), at(1, 3), at(2, 3), at(3, 3), }, { at(1, 0), at(2, 0), at(3, 0), at(1, 1), at(2, 1), at(3, 1), at(1, 3), at(2, 3), at(3, 3), }, { at(1, 0), at(2, 0), at(3, 0), at(1, 1), at(2, 1), at(3, 1), at(1, 2), at(2, 2), at(3, 2), } }; return at(0, 0) * Matrix(minorMatrices[0], 3).determinant() - at(0, 1) * Matrix(minorMatrices[1], 3).determinant() + at(0, 2) * Matrix(minorMatrices[2], 3).determinant() - at(0, 3) * Matrix(minorMatrices[3], 3).determinant(); } default: UNREACHABLE(); break; } return T(); } Matrix inverse() const { ASSERT(rows() == columns()); Matrix cof(std::vector(mElements.size()), rows(), columns()); switch (size()) { case 2: cof(0, 0) = at(1, 1); cof(0, 1) = -at(1, 0); cof(1, 0) = -at(0, 1); cof(1, 1) = at(0, 0); break; case 3: cof(0, 0) = at(1, 1) * at(2, 2) - at(2, 1) * at(1, 2); cof(0, 1) = -(at(1, 0) * at(2, 2) - at(2, 0) * at(1, 2)); cof(0, 2) = at(1, 0) * at(2, 1) - at(2, 0) * at(1, 1); cof(1, 0) = -(at(0, 1) * at(2, 2) - at(2, 1) * at(0, 2)); cof(1, 1) = at(0, 0) * at(2, 2) - at(2, 0) * at(0, 2); cof(1, 2) = -(at(0, 0) * at(2, 1) - at(2, 0) * at(0, 1)); cof(2, 0) = at(0, 1) * at(1, 2) - at(1, 1) * at(0, 2); cof(2, 1) = -(at(0, 0) * at(1, 2) - at(1, 0) * at(0, 2)); cof(2, 2) = at(0, 0) * at(1, 1) - at(1, 0) * at(0, 1); break; case 4: cof(0, 0) = at(1, 1) * at(2, 2) * at(3, 3) + at(2, 1) * at(3, 2) * at(1, 3) + at(3, 1) * at(1, 2) * at(2, 3) - at(1, 1) * at(3, 2) * at(2, 3) - at(2, 1) * at(1, 2) * at(3, 3) - at(3, 1) * at(2, 2) * at(1, 3); cof(0, 1) = -(at(1, 0) * at(2, 2) * at(3, 3) + at(2, 0) * at(3, 2) * at(1, 3) + at(3, 0) * at(1, 2) * at(2, 3) - at(1, 0) * at(3, 2) * at(2, 3) - at(2, 0) * at(1, 2) * at(3, 3) - at(3, 0) * at(2, 2) * at(1, 3)); cof(0, 2) = at(1, 0) * at(2, 1) * at(3, 3) + at(2, 0) * at(3, 1) * at(1, 3) + at(3, 0) * at(1, 1) * at(2, 3) - at(1, 0) * at(3, 1) * at(2, 3) - at(2, 0) * at(1, 1) * at(3, 3) - at(3, 0) * at(2, 1) * at(1, 3); cof(0, 3) = -(at(1, 0) * at(2, 1) * at(3, 2) + at(2, 0) * at(3, 1) * at(1, 2) + at(3, 0) * at(1, 1) * at(2, 2) - at(1, 0) * at(3, 1) * at(2, 2) - at(2, 0) * at(1, 1) * at(3, 2) - at(3, 0) * at(2, 1) * at(1, 2)); cof(1, 0) = -(at(0, 1) * at(2, 2) * at(3, 3) + at(2, 1) * at(3, 2) * at(0, 3) + at(3, 1) * at(0, 2) * at(2, 3) - at(0, 1) * at(3, 2) * at(2, 3) - at(2, 1) * at(0, 2) * at(3, 3) - at(3, 1) * at(2, 2) * at(0, 3)); cof(1, 1) = at(0, 0) * at(2, 2) * at(3, 3) + at(2, 0) * at(3, 2) * at(0, 3) + at(3, 0) * at(0, 2) * at(2, 3) - at(0, 0) * at(3, 2) * at(2, 3) - at(2, 0) * at(0, 2) * at(3, 3) - at(3, 0) * at(2, 2) * at(0, 3); cof(1, 2) = -(at(0, 0) * at(2, 1) * at(3, 3) + at(2, 0) * at(3, 1) * at(0, 3) + at(3, 0) * at(0, 1) * at(2, 3) - at(0, 0) * at(3, 1) * at(2, 3) - at(2, 0) * at(0, 1) * at(3, 3) - at(3, 0) * at(2, 1) * at(0, 3)); cof(1, 3) = at(0, 0) * at(2, 1) * at(3, 2) + at(2, 0) * at(3, 1) * at(0, 2) + at(3, 0) * at(0, 1) * at(2, 2) - at(0, 0) * at(3, 1) * at(2, 2) - at(2, 0) * at(0, 1) * at(3, 2) - at(3, 0) * at(2, 1) * at(0, 2); cof(2, 0) = at(0, 1) * at(1, 2) * at(3, 3) + at(1, 1) * at(3, 2) * at(0, 3) + at(3, 1) * at(0, 2) * at(1, 3) - at(0, 1) * at(3, 2) * at(1, 3) - at(1, 1) * at(0, 2) * at(3, 3) - at(3, 1) * at(1, 2) * at(0, 3); cof(2, 1) = -(at(0, 0) * at(1, 2) * at(3, 3) + at(1, 0) * at(3, 2) * at(0, 3) + at(3, 0) * at(0, 2) * at(1, 3) - at(0, 0) * at(3, 2) * at(1, 3) - at(1, 0) * at(0, 2) * at(3, 3) - at(3, 0) * at(1, 2) * at(0, 3)); cof(2, 2) = at(0, 0) * at(1, 1) * at(3, 3) + at(1, 0) * at(3, 1) * at(0, 3) + at(3, 0) * at(0, 1) * at(1, 3) - at(0, 0) * at(3, 1) * at(1, 3) - at(1, 0) * at(0, 1) * at(3, 3) - at(3, 0) * at(1, 1) * at(0, 3); cof(2, 3) = -(at(0, 0) * at(1, 1) * at(3, 2) + at(1, 0) * at(3, 1) * at(0, 2) + at(3, 0) * at(0, 1) * at(1, 2) - at(0, 0) * at(3, 1) * at(1, 2) - at(1, 0) * at(0, 1) * at(3, 2) - at(3, 0) * at(1, 1) * at(0, 2)); cof(3, 0) = -(at(0, 1) * at(1, 2) * at(2, 3) + at(1, 1) * at(2, 2) * at(0, 3) + at(2, 1) * at(0, 2) * at(1, 3) - at(0, 1) * at(2, 2) * at(1, 3) - at(1, 1) * at(0, 2) * at(2, 3) - at(2, 1) * at(1, 2) * at(0, 3)); cof(3, 1) = at(0, 0) * at(1, 2) * at(2, 3) + at(1, 0) * at(2, 2) * at(0, 3) + at(2, 0) * at(0, 2) * at(1, 3) - at(0, 0) * at(2, 2) * at(1, 3) - at(1, 0) * at(0, 2) * at(2, 3) - at(2, 0) * at(1, 2) * at(0, 3); cof(3, 2) = -(at(0, 0) * at(1, 1) * at(2, 3) + at(1, 0) * at(2, 1) * at(0, 3) + at(2, 0) * at(0, 1) * at(1, 3) - at(0, 0) * at(2, 1) * at(1, 3) - at(1, 0) * at(0, 1) * at(2, 3) - at(2, 0) * at(1, 1) * at(0, 3)); cof(3, 3) = at(0, 0) * at(1, 1) * at(2, 2) + at(1, 0) * at(2, 1) * at(0, 2) + at(2, 0) * at(0, 1) * at(1, 2) - at(0, 0) * at(2, 1) * at(1, 2) - at(1, 0) * at(0, 1) * at(2, 2) - at(2, 0) * at(1, 1) * at(0, 2); break; default: UNREACHABLE(); break; } // The inverse of A is the transpose of the cofactor matrix times the reciprocal of the determinant of A. Matrix adjugateMatrix(cof.transpose()); T det = determinant(); Matrix result(std::vector(mElements.size()), rows(), columns()); for (unsigned int i = 0; i < rows(); i++) for (unsigned int j = 0; j < columns(); j++) result(i, j) = det ? adjugateMatrix(i, j) / det : T(); return result; } private: std::vector mElements; unsigned int mRows; unsigned int mCols; }; } // namespace angle #endif // COMMON_MATRIX_UTILS_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/common/platform.h000066400000000000000000000040211321746453100242030ustar00rootroot00000000000000// // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // platform.h: Operating system specific includes and defines. #ifndef COMMON_PLATFORM_H_ #define COMMON_PLATFORM_H_ #if defined(_WIN32) || defined(_WIN64) # define ANGLE_PLATFORM_WINDOWS 1 #elif defined(__APPLE__) # define ANGLE_PLATFORM_APPLE 1 # define ANGLE_PLATFORM_POSIX 1 #elif defined(ANDROID) # define ANGLE_PLATFORM_ANDROID 1 # define ANGLE_PLATFORM_POSIX 1 #elif defined(__linux__) || defined(EMSCRIPTEN) # define ANGLE_PLATFORM_LINUX 1 # define ANGLE_PLATFORM_POSIX 1 #elif defined(__FreeBSD__) || \ defined(__OpenBSD__) || \ defined(__NetBSD__) || \ defined(__DragonFly__) || \ defined(__sun) || \ defined(__GLIBC__) || \ defined(__GNU__) || \ defined(__QNX__) # define ANGLE_PLATFORM_POSIX 1 #else # error Unsupported platform. #endif #ifdef ANGLE_PLATFORM_WINDOWS # ifndef STRICT # define STRICT 1 # endif # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN 1 # endif # ifndef NOMINMAX # define NOMINMAX 1 # endif # include # include # if defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) # define ANGLE_ENABLE_WINDOWS_STORE 1 # endif # if defined(ANGLE_ENABLE_D3D9) # include # include # endif # if defined(ANGLE_ENABLE_D3D11) # include # include # include # include # include # include # endif # if defined(ANGLE_ENABLE_WINDOWS_STORE) # include # if defined(_DEBUG) # include # include # endif # endif # undef near # undef far #endif #if !defined(_M_ARM) && !defined(ANGLE_PLATFORM_ANDROID) # define ANGLE_USE_SSE #endif #endif // COMMON_PLATFORM_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/common/tls.cpp000066400000000000000000000070731321746453100235260ustar00rootroot00000000000000// // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // tls.cpp: Simple cross-platform interface for thread local storage. #include "common/tls.h" #include #ifdef ANGLE_ENABLE_WINDOWS_STORE #include #include #include #include #include #include #include using namespace std; using namespace Windows::Foundation; using namespace ABI::Windows::System::Threading; // Thread local storage for Windows Store support typedef vector ThreadLocalData; static __declspec(thread) ThreadLocalData* currentThreadData = nullptr; static set allThreadData; static DWORD nextTlsIndex = 0; static vector freeTlsIndices; #endif TLSIndex CreateTLSIndex() { TLSIndex index; #ifdef ANGLE_PLATFORM_WINDOWS #ifdef ANGLE_ENABLE_WINDOWS_STORE if (!freeTlsIndices.empty()) { DWORD result = freeTlsIndices.back(); freeTlsIndices.pop_back(); index = result; } else { index = nextTlsIndex++; } #else index = TlsAlloc(); #endif #elif defined(ANGLE_PLATFORM_POSIX) // Create global pool key if ((pthread_key_create(&index, NULL)) != 0) { index = TLS_INVALID_INDEX; } #endif assert(index != TLS_INVALID_INDEX && "CreateTLSIndex(): Unable to allocate Thread Local Storage"); return index; } bool DestroyTLSIndex(TLSIndex index) { assert(index != TLS_INVALID_INDEX && "DestroyTLSIndex(): Invalid TLS Index"); if (index == TLS_INVALID_INDEX) { return false; } #ifdef ANGLE_PLATFORM_WINDOWS #ifdef ANGLE_ENABLE_WINDOWS_STORE assert(index < nextTlsIndex); assert(find(freeTlsIndices.begin(), freeTlsIndices.end(), index) == freeTlsIndices.end()); freeTlsIndices.push_back(index); for (auto threadData : allThreadData) { if (threadData->size() > index) { threadData->at(index) = nullptr; } } return true; #else return (TlsFree(index) == TRUE); #endif #elif defined(ANGLE_PLATFORM_POSIX) return (pthread_key_delete(index) == 0); #endif } bool SetTLSValue(TLSIndex index, void *value) { assert(index != TLS_INVALID_INDEX && "SetTLSValue(): Invalid TLS Index"); if (index == TLS_INVALID_INDEX) { return false; } #ifdef ANGLE_PLATFORM_WINDOWS #ifdef ANGLE_ENABLE_WINDOWS_STORE ThreadLocalData* threadData = currentThreadData; if (!threadData) { threadData = new ThreadLocalData(index + 1, nullptr); allThreadData.insert(threadData); currentThreadData = threadData; } else if (threadData->size() <= index) { threadData->resize(index + 1, nullptr); } threadData->at(index) = value; return true; #else return (TlsSetValue(index, value) == TRUE); #endif #elif defined(ANGLE_PLATFORM_POSIX) return (pthread_setspecific(index, value) == 0); #endif } void *GetTLSValue(TLSIndex index) { assert(index != TLS_INVALID_INDEX && "GetTLSValue(): Invalid TLS Index"); if (index == TLS_INVALID_INDEX) { return NULL; } #ifdef ANGLE_PLATFORM_WINDOWS #ifdef ANGLE_ENABLE_WINDOWS_STORE ThreadLocalData* threadData = currentThreadData; if (threadData && threadData->size() > index) { return threadData->at(index); } else { return nullptr; } #else return TlsGetValue(index); #endif #elif defined(ANGLE_PLATFORM_POSIX) return pthread_getspecific(index); #endif } freshplayerplugin-0.3.9/3rdparty/angle/src/common/tls.h000066400000000000000000000025261321746453100231710ustar00rootroot00000000000000// // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // tls.h: Simple cross-platform interface for thread local storage. #ifndef COMMON_TLS_H_ #define COMMON_TLS_H_ #include "common/platform.h" #ifdef ANGLE_PLATFORM_WINDOWS // TLS does not exist for Windows Store and needs to be emulated # ifdef ANGLE_ENABLE_WINDOWS_STORE # ifndef TLS_OUT_OF_INDEXES # define TLS_OUT_OF_INDEXES static_cast(0xFFFFFFFF) # endif # ifndef CREATE_SUSPENDED # define CREATE_SUSPENDED 0x00000004 # endif # endif typedef DWORD TLSIndex; # define TLS_INVALID_INDEX (TLS_OUT_OF_INDEXES) #elif defined(ANGLE_PLATFORM_POSIX) # include # include # include typedef pthread_key_t TLSIndex; # define TLS_INVALID_INDEX (static_cast(-1)) #else # error Unsupported platform. #endif // TODO(kbr): for POSIX platforms this will have to be changed to take // in a destructor function pointer, to allow the thread-local storage // to be properly deallocated upon thread exit. TLSIndex CreateTLSIndex(); bool DestroyTLSIndex(TLSIndex index); bool SetTLSValue(TLSIndex index, void *value); void *GetTLSValue(TLSIndex index); #endif // COMMON_TLS_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/common/utilities.cpp000066400000000000000000000461051321746453100247360ustar00rootroot00000000000000// // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // utilities.cpp: Conversion functions and other utility routines. #include "common/utilities.h" #include "common/mathutil.h" #include "common/platform.h" #include #if defined(ANGLE_ENABLE_WINDOWS_STORE) # include # include # include # include #endif namespace gl { int VariableComponentCount(GLenum type) { return VariableRowCount(type) * VariableColumnCount(type); } GLenum VariableComponentType(GLenum type) { switch(type) { case GL_BOOL: case GL_BOOL_VEC2: case GL_BOOL_VEC3: case GL_BOOL_VEC4: return GL_BOOL; case GL_FLOAT: case GL_FLOAT_VEC2: case GL_FLOAT_VEC3: case GL_FLOAT_VEC4: case GL_FLOAT_MAT2: case GL_FLOAT_MAT3: case GL_FLOAT_MAT4: case GL_FLOAT_MAT2x3: case GL_FLOAT_MAT3x2: case GL_FLOAT_MAT2x4: case GL_FLOAT_MAT4x2: case GL_FLOAT_MAT3x4: case GL_FLOAT_MAT4x3: return GL_FLOAT; case GL_INT: case GL_SAMPLER_2D: case GL_SAMPLER_3D: case GL_SAMPLER_CUBE: case GL_SAMPLER_2D_ARRAY: case GL_INT_SAMPLER_2D: case GL_INT_SAMPLER_3D: case GL_INT_SAMPLER_CUBE: case GL_INT_SAMPLER_2D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D: case GL_UNSIGNED_INT_SAMPLER_3D: case GL_UNSIGNED_INT_SAMPLER_CUBE: case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_CUBE_SHADOW: case GL_SAMPLER_2D_ARRAY_SHADOW: case GL_INT_VEC2: case GL_INT_VEC3: case GL_INT_VEC4: return GL_INT; case GL_UNSIGNED_INT: case GL_UNSIGNED_INT_VEC2: case GL_UNSIGNED_INT_VEC3: case GL_UNSIGNED_INT_VEC4: return GL_UNSIGNED_INT; default: UNREACHABLE(); } return GL_NONE; } size_t VariableComponentSize(GLenum type) { switch(type) { case GL_BOOL: return sizeof(GLint); case GL_FLOAT: return sizeof(GLfloat); case GL_INT: return sizeof(GLint); case GL_UNSIGNED_INT: return sizeof(GLuint); default: UNREACHABLE(); } return 0; } size_t VariableInternalSize(GLenum type) { // Expanded to 4-element vectors return VariableComponentSize(VariableComponentType(type)) * VariableRowCount(type) * 4; } size_t VariableExternalSize(GLenum type) { return VariableComponentSize(VariableComponentType(type)) * VariableComponentCount(type); } GLenum VariableBoolVectorType(GLenum type) { switch (type) { case GL_FLOAT: case GL_INT: case GL_UNSIGNED_INT: return GL_BOOL; case GL_FLOAT_VEC2: case GL_INT_VEC2: case GL_UNSIGNED_INT_VEC2: return GL_BOOL_VEC2; case GL_FLOAT_VEC3: case GL_INT_VEC3: case GL_UNSIGNED_INT_VEC3: return GL_BOOL_VEC3; case GL_FLOAT_VEC4: case GL_INT_VEC4: case GL_UNSIGNED_INT_VEC4: return GL_BOOL_VEC4; default: UNREACHABLE(); return GL_NONE; } } int VariableRowCount(GLenum type) { switch (type) { case GL_NONE: case GL_STRUCT_ANGLEX: return 0; case GL_BOOL: case GL_FLOAT: case GL_INT: case GL_UNSIGNED_INT: case GL_BOOL_VEC2: case GL_FLOAT_VEC2: case GL_INT_VEC2: case GL_UNSIGNED_INT_VEC2: case GL_BOOL_VEC3: case GL_FLOAT_VEC3: case GL_INT_VEC3: case GL_UNSIGNED_INT_VEC3: case GL_BOOL_VEC4: case GL_FLOAT_VEC4: case GL_INT_VEC4: case GL_UNSIGNED_INT_VEC4: case GL_SAMPLER_2D: case GL_SAMPLER_3D: case GL_SAMPLER_CUBE: case GL_SAMPLER_2D_ARRAY: case GL_SAMPLER_EXTERNAL_OES: case GL_SAMPLER_2D_RECT_ARB: case GL_INT_SAMPLER_2D: case GL_INT_SAMPLER_3D: case GL_INT_SAMPLER_CUBE: case GL_INT_SAMPLER_2D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D: case GL_UNSIGNED_INT_SAMPLER_3D: case GL_UNSIGNED_INT_SAMPLER_CUBE: case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_CUBE_SHADOW: case GL_SAMPLER_2D_ARRAY_SHADOW: return 1; case GL_FLOAT_MAT2: case GL_FLOAT_MAT3x2: case GL_FLOAT_MAT4x2: return 2; case GL_FLOAT_MAT3: case GL_FLOAT_MAT2x3: case GL_FLOAT_MAT4x3: return 3; case GL_FLOAT_MAT4: case GL_FLOAT_MAT2x4: case GL_FLOAT_MAT3x4: return 4; default: UNREACHABLE(); } return 0; } int VariableColumnCount(GLenum type) { switch (type) { case GL_NONE: case GL_STRUCT_ANGLEX: return 0; case GL_BOOL: case GL_FLOAT: case GL_INT: case GL_UNSIGNED_INT: case GL_SAMPLER_2D: case GL_SAMPLER_3D: case GL_SAMPLER_CUBE: case GL_SAMPLER_2D_ARRAY: case GL_INT_SAMPLER_2D: case GL_INT_SAMPLER_3D: case GL_INT_SAMPLER_CUBE: case GL_INT_SAMPLER_2D_ARRAY: case GL_SAMPLER_EXTERNAL_OES: case GL_SAMPLER_2D_RECT_ARB: case GL_UNSIGNED_INT_SAMPLER_2D: case GL_UNSIGNED_INT_SAMPLER_3D: case GL_UNSIGNED_INT_SAMPLER_CUBE: case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_CUBE_SHADOW: case GL_SAMPLER_2D_ARRAY_SHADOW: return 1; case GL_BOOL_VEC2: case GL_FLOAT_VEC2: case GL_INT_VEC2: case GL_UNSIGNED_INT_VEC2: case GL_FLOAT_MAT2: case GL_FLOAT_MAT2x3: case GL_FLOAT_MAT2x4: return 2; case GL_BOOL_VEC3: case GL_FLOAT_VEC3: case GL_INT_VEC3: case GL_UNSIGNED_INT_VEC3: case GL_FLOAT_MAT3: case GL_FLOAT_MAT3x2: case GL_FLOAT_MAT3x4: return 3; case GL_BOOL_VEC4: case GL_FLOAT_VEC4: case GL_INT_VEC4: case GL_UNSIGNED_INT_VEC4: case GL_FLOAT_MAT4: case GL_FLOAT_MAT4x2: case GL_FLOAT_MAT4x3: return 4; default: UNREACHABLE(); } return 0; } bool IsSamplerType(GLenum type) { switch (type) { case GL_SAMPLER_2D: case GL_SAMPLER_3D: case GL_SAMPLER_CUBE: case GL_SAMPLER_2D_ARRAY: case GL_INT_SAMPLER_2D: case GL_INT_SAMPLER_3D: case GL_INT_SAMPLER_CUBE: case GL_INT_SAMPLER_2D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D: case GL_UNSIGNED_INT_SAMPLER_3D: case GL_UNSIGNED_INT_SAMPLER_CUBE: case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_CUBE_SHADOW: case GL_SAMPLER_2D_ARRAY_SHADOW: return true; } return false; } GLenum SamplerTypeToTextureType(GLenum samplerType) { switch (samplerType) { case GL_SAMPLER_2D: case GL_INT_SAMPLER_2D: case GL_UNSIGNED_INT_SAMPLER_2D: case GL_SAMPLER_2D_SHADOW: return GL_TEXTURE_2D; case GL_SAMPLER_CUBE: case GL_INT_SAMPLER_CUBE: case GL_UNSIGNED_INT_SAMPLER_CUBE: case GL_SAMPLER_CUBE_SHADOW: return GL_TEXTURE_CUBE_MAP; case GL_SAMPLER_2D_ARRAY: case GL_INT_SAMPLER_2D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: case GL_SAMPLER_2D_ARRAY_SHADOW: return GL_TEXTURE_2D_ARRAY; case GL_SAMPLER_3D: case GL_INT_SAMPLER_3D: case GL_UNSIGNED_INT_SAMPLER_3D: return GL_TEXTURE_3D; default: UNREACHABLE(); return 0; } } bool IsMatrixType(GLenum type) { return VariableRowCount(type) > 1; } GLenum TransposeMatrixType(GLenum type) { if (!IsMatrixType(type)) { return type; } switch (type) { case GL_FLOAT_MAT2: return GL_FLOAT_MAT2; case GL_FLOAT_MAT3: return GL_FLOAT_MAT3; case GL_FLOAT_MAT4: return GL_FLOAT_MAT4; case GL_FLOAT_MAT2x3: return GL_FLOAT_MAT3x2; case GL_FLOAT_MAT3x2: return GL_FLOAT_MAT2x3; case GL_FLOAT_MAT2x4: return GL_FLOAT_MAT4x2; case GL_FLOAT_MAT4x2: return GL_FLOAT_MAT2x4; case GL_FLOAT_MAT3x4: return GL_FLOAT_MAT4x3; case GL_FLOAT_MAT4x3: return GL_FLOAT_MAT3x4; default: UNREACHABLE(); return GL_NONE; } } int MatrixRegisterCount(GLenum type, bool isRowMajorMatrix) { ASSERT(IsMatrixType(type)); return isRowMajorMatrix ? VariableRowCount(type) : VariableColumnCount(type); } int MatrixComponentCount(GLenum type, bool isRowMajorMatrix) { ASSERT(IsMatrixType(type)); return isRowMajorMatrix ? VariableColumnCount(type) : VariableRowCount(type); } int VariableRegisterCount(GLenum type) { return IsMatrixType(type) ? VariableColumnCount(type) : 1; } int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize) { ASSERT(allocationSize <= bitsSize); unsigned int mask = std::numeric_limits::max() >> (std::numeric_limits::digits - allocationSize); for (unsigned int i = 0; i < bitsSize - allocationSize + 1; i++) { if ((*bits & mask) == 0) { *bits |= mask; return i; } mask <<= 1; } return -1; } static_assert(GL_TEXTURE_CUBE_MAP_NEGATIVE_X - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 1, "Unexpected GL cube map enum value."); static_assert(GL_TEXTURE_CUBE_MAP_POSITIVE_Y - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 2, "Unexpected GL cube map enum value."); static_assert(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 3, "Unexpected GL cube map enum value."); static_assert(GL_TEXTURE_CUBE_MAP_POSITIVE_Z - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 4, "Unexpected GL cube map enum value."); static_assert(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 5, "Unexpected GL cube map enum value."); bool IsCubeMapTextureTarget(GLenum target) { return (target >= FirstCubeMapTextureTarget && target <= LastCubeMapTextureTarget); } size_t CubeMapTextureTargetToLayerIndex(GLenum target) { ASSERT(IsCubeMapTextureTarget(target)); return target - static_cast(FirstCubeMapTextureTarget); } GLenum LayerIndexToCubeMapTextureTarget(size_t index) { ASSERT(index <= (LastCubeMapTextureTarget - FirstCubeMapTextureTarget)); return FirstCubeMapTextureTarget + static_cast(index); } template static RangeUI ComputeTypedIndexRange(const IndexType *indices, GLsizei count) { ASSERT(count > 0); IndexType minIndex = indices[0]; IndexType maxIndex = indices[0]; for (GLsizei i = 1; i < count; i++) { if (minIndex > indices[i]) minIndex = indices[i]; if (maxIndex < indices[i]) maxIndex = indices[i]; } return RangeUI(static_cast(minIndex), static_cast(maxIndex)); } RangeUI ComputeIndexRange(GLenum indexType, const GLvoid *indices, GLsizei count) { switch (indexType) { case GL_UNSIGNED_BYTE: return ComputeTypedIndexRange(static_cast(indices), count); case GL_UNSIGNED_SHORT: return ComputeTypedIndexRange(static_cast(indices), count); case GL_UNSIGNED_INT: return ComputeTypedIndexRange(static_cast(indices), count); default: UNREACHABLE(); return RangeUI(0, 0); } } bool IsTriangleMode(GLenum drawMode) { switch (drawMode) { case GL_TRIANGLES: case GL_TRIANGLE_FAN: case GL_TRIANGLE_STRIP: return true; case GL_POINTS: case GL_LINES: case GL_LINE_LOOP: case GL_LINE_STRIP: return false; default: UNREACHABLE(); } return false; } // [OpenGL ES SL 3.00.4] Section 11 p. 120 // Vertex Outs/Fragment Ins packing priorities int VariableSortOrder(GLenum type) { switch (type) { // 1. Arrays of mat4 and mat4 // Non-square matrices of type matCxR consume the same space as a square // matrix of type matN where N is the greater of C and R case GL_FLOAT_MAT4: case GL_FLOAT_MAT2x4: case GL_FLOAT_MAT3x4: case GL_FLOAT_MAT4x2: case GL_FLOAT_MAT4x3: return 0; // 2. Arrays of mat2 and mat2 (since they occupy full rows) case GL_FLOAT_MAT2: return 1; // 3. Arrays of vec4 and vec4 case GL_FLOAT_VEC4: case GL_INT_VEC4: case GL_BOOL_VEC4: case GL_UNSIGNED_INT_VEC4: return 2; // 4. Arrays of mat3 and mat3 case GL_FLOAT_MAT3: case GL_FLOAT_MAT2x3: case GL_FLOAT_MAT3x2: return 3; // 5. Arrays of vec3 and vec3 case GL_FLOAT_VEC3: case GL_INT_VEC3: case GL_BOOL_VEC3: case GL_UNSIGNED_INT_VEC3: return 4; // 6. Arrays of vec2 and vec2 case GL_FLOAT_VEC2: case GL_INT_VEC2: case GL_BOOL_VEC2: case GL_UNSIGNED_INT_VEC2: return 5; // 7. Single component types case GL_FLOAT: case GL_INT: case GL_BOOL: case GL_UNSIGNED_INT: case GL_SAMPLER_2D: case GL_SAMPLER_CUBE: case GL_SAMPLER_EXTERNAL_OES: case GL_SAMPLER_2D_RECT_ARB: case GL_SAMPLER_2D_ARRAY: case GL_SAMPLER_3D: case GL_INT_SAMPLER_2D: case GL_INT_SAMPLER_3D: case GL_INT_SAMPLER_CUBE: case GL_INT_SAMPLER_2D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D: case GL_UNSIGNED_INT_SAMPLER_3D: case GL_UNSIGNED_INT_SAMPLER_CUBE: case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_2D_ARRAY_SHADOW: case GL_SAMPLER_CUBE_SHADOW: return 6; default: UNREACHABLE(); return 0; } } std::string ParseUniformName(const std::string &name, size_t *outSubscript) { // Strip any trailing array operator and retrieve the subscript size_t open = name.find_last_of('['); size_t close = name.find_last_of(']'); bool hasIndex = (open != std::string::npos) && (close == name.length() - 1); if (!hasIndex) { if (outSubscript) { *outSubscript = GL_INVALID_INDEX; } return name; } if (outSubscript) { int index = atoi(name.substr(open + 1).c_str()); if (index >= 0) { *outSubscript = index; } else { *outSubscript = GL_INVALID_INDEX; } } return name.substr(0, open); } } namespace egl { static_assert(EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR - EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR == 1, "Unexpected EGL cube map enum value."); static_assert(EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR - EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR == 2, "Unexpected EGL cube map enum value."); static_assert(EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR - EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR == 3, "Unexpected EGL cube map enum value."); static_assert(EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR - EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR == 4, "Unexpected EGL cube map enum value."); static_assert(EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR - EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR == 5, "Unexpected EGL cube map enum value."); bool IsCubeMapTextureTarget(EGLenum target) { return (target >= FirstCubeMapTextureTarget && target <= LastCubeMapTextureTarget); } size_t CubeMapTextureTargetToLayerIndex(EGLenum target) { ASSERT(IsCubeMapTextureTarget(target)); return target - static_cast(FirstCubeMapTextureTarget); } EGLenum LayerIndexToCubeMapTextureTarget(size_t index) { ASSERT(index <= (LastCubeMapTextureTarget - FirstCubeMapTextureTarget)); return FirstCubeMapTextureTarget + static_cast(index); } bool IsTextureTarget(EGLenum target) { switch (target) { case EGL_GL_TEXTURE_2D_KHR: case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR: case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR: case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR: case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR: case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR: case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR: case EGL_GL_TEXTURE_3D_KHR: return true; default: return false; } } bool IsRenderbufferTarget(EGLenum target) { return target == EGL_GL_RENDERBUFFER_KHR; } } namespace egl_gl { GLenum EGLCubeMapTargetToGLCubeMapTarget(EGLenum eglTarget) { ASSERT(egl::IsCubeMapTextureTarget(eglTarget)); return gl::LayerIndexToCubeMapTextureTarget(egl::CubeMapTextureTargetToLayerIndex(eglTarget)); } GLenum EGLImageTargetToGLTextureTarget(EGLenum eglTarget) { switch (eglTarget) { case EGL_GL_TEXTURE_2D_KHR: return GL_TEXTURE_2D; case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR: case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR: case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR: case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR: case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR: case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR: return EGLCubeMapTargetToGLCubeMapTarget(eglTarget); case EGL_GL_TEXTURE_3D_KHR: return GL_TEXTURE_3D; default: UNREACHABLE(); return GL_NONE; } } GLuint EGLClientBufferToGLObjectHandle(EGLClientBuffer buffer) { return static_cast(reinterpret_cast(buffer)); } } #if !defined(ANGLE_ENABLE_WINDOWS_STORE) std::string getTempPath() { #ifdef ANGLE_PLATFORM_WINDOWS char path[MAX_PATH]; DWORD pathLen = GetTempPathA(sizeof(path) / sizeof(path[0]), path); if (pathLen == 0) { UNREACHABLE(); return std::string(); } UINT unique = GetTempFileNameA(path, "sh", 0, path); if (unique == 0) { UNREACHABLE(); return std::string(); } return path; #else UNIMPLEMENTED(); return ""; #endif } void writeFile(const char* path, const void* content, size_t size) { FILE* file = fopen(path, "w"); if (!file) { UNREACHABLE(); return; } fwrite(content, sizeof(char), size, file); fclose(file); } #endif // !ANGLE_ENABLE_WINDOWS_STORE #if defined (ANGLE_PLATFORM_WINDOWS) // Causes the thread to relinquish the remainder of its time slice to any // other thread that is ready to run.If there are no other threads ready // to run, the function returns immediately, and the thread continues execution. void ScheduleYield() { #if defined(ANGLE_ENABLE_WINDOWS_STORE) // This implementation of Sleep exists because it is not available prior to Update 4. static HANDLE singletonEvent = nullptr; HANDLE sleepEvent = singletonEvent; if (!sleepEvent) { sleepEvent = CreateEventEx(nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS); if (!sleepEvent) return; HANDLE previousEvent = InterlockedCompareExchangePointerRelease(&singletonEvent, sleepEvent, nullptr); if (previousEvent) { // Back out if multiple threads try to demand create at the same time. CloseHandle(sleepEvent); sleepEvent = previousEvent; } } // Emulate sleep by waiting with timeout on an event that is never signalled. WaitForSingleObjectEx(sleepEvent, 0, false); #else Sleep(0); #endif } #endif freshplayerplugin-0.3.9/3rdparty/angle/src/common/utilities.h000066400000000000000000000063151321746453100244020ustar00rootroot00000000000000// // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // utilities.h: Conversion functions and other utility routines. #ifndef COMMON_UTILITIES_H_ #define COMMON_UTILITIES_H_ #include #include #include "angle_gl.h" #include #include #include "common/mathutil.h" namespace gl { int VariableComponentCount(GLenum type); GLenum VariableComponentType(GLenum type); size_t VariableComponentSize(GLenum type); size_t VariableInternalSize(GLenum type); size_t VariableExternalSize(GLenum type); GLenum VariableBoolVectorType(GLenum type); int VariableRowCount(GLenum type); int VariableColumnCount(GLenum type); bool IsSamplerType(GLenum type); GLenum SamplerTypeToTextureType(GLenum samplerType); bool IsMatrixType(GLenum type); GLenum TransposeMatrixType(GLenum type); int VariableRegisterCount(GLenum type); int MatrixRegisterCount(GLenum type, bool isRowMajorMatrix); int MatrixComponentCount(GLenum type, bool isRowMajorMatrix); int VariableSortOrder(GLenum type); int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize); static const GLenum FirstCubeMapTextureTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X; static const GLenum LastCubeMapTextureTarget = GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; bool IsCubeMapTextureTarget(GLenum target); size_t CubeMapTextureTargetToLayerIndex(GLenum target); GLenum LayerIndexToCubeMapTextureTarget(size_t index); // Parse the base uniform name and array index. Returns the base name of the uniform. outSubscript is // set to GL_INVALID_INDEX if the provided name is not an array or the array index is invalid. std::string ParseUniformName(const std::string &name, size_t *outSubscript); RangeUI ComputeIndexRange(GLenum indexType, const GLvoid *indices, GLsizei count); bool IsTriangleMode(GLenum drawMode); // [OpenGL ES 3.0.2] Section 2.3.1 page 14 // Data Conversion For State-Setting Commands // Floating-point values are rounded to the nearest integer, instead of truncated, as done by static_cast. template outT iround(GLfloat value) { return static_cast(value > 0.0f ? floor(value + 0.5f) : ceil(value - 0.5f)); } template outT uiround(GLfloat value) { return static_cast(value + 0.5f); } } namespace egl { static const EGLenum FirstCubeMapTextureTarget = EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR; static const EGLenum LastCubeMapTextureTarget = EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR; bool IsCubeMapTextureTarget(EGLenum target); size_t CubeMapTextureTargetToLayerIndex(EGLenum target); EGLenum LayerIndexToCubeMapTextureTarget(size_t index); bool IsTextureTarget(EGLenum target); bool IsRenderbufferTarget(EGLenum target); } namespace egl_gl { GLenum EGLCubeMapTargetToGLCubeMapTarget(EGLenum eglTarget); GLenum EGLImageTargetToGLTextureTarget(EGLenum eglTarget); GLuint EGLClientBufferToGLObjectHandle(EGLClientBuffer buffer); } #if !defined(ANGLE_ENABLE_WINDOWS_STORE) std::string getTempPath(); void writeFile(const char* path, const void* data, size_t size); #endif #if defined (ANGLE_PLATFORM_WINDOWS) void ScheduleYield(); #endif #endif // COMMON_UTILITIES_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/000077500000000000000000000000001321746453100225335ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/000077500000000000000000000000001321746453100252615ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/64bit-tokenizer-safety.patch000066400000000000000000000016711321746453100325400ustar00rootroot00000000000000--- a/src/compiler/preprocessor/Tokenizer.cpp +++ b/src/compiler/preprocessor/Tokenizer.cpp @@ -56,6 +56,7 @@ typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; @@ -179,6 +180,11 @@ typedef void* yyscan_t; typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 @@ -353,7 +354,7 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); */ #define YY_DO_BEFORE_ACTION \ yyg->yytext_ptr = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.cpp000066400000000000000000000110071321746453100310260ustar00rootroot00000000000000// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "DiagnosticsBase.h" #include namespace pp { Diagnostics::~Diagnostics() { } void Diagnostics::report(ID id, const SourceLocation &loc, const std::string &text) { // TODO(alokp): Keep a count of errors and warnings. print(id, loc, text); } Diagnostics::Severity Diagnostics::severity(ID id) { if ((id > PP_ERROR_BEGIN) && (id < PP_ERROR_END)) return PP_ERROR; if ((id > PP_WARNING_BEGIN) && (id < PP_WARNING_END)) return PP_WARNING; assert(false); return PP_ERROR; } std::string Diagnostics::message(ID id) { switch (id) { // Errors begin. case PP_INTERNAL_ERROR: return "internal error"; case PP_OUT_OF_MEMORY: return "out of memory"; case PP_INVALID_CHARACTER: return "invalid character"; case PP_INVALID_NUMBER: return "invalid number"; case PP_INTEGER_OVERFLOW: return "integer overflow"; case PP_FLOAT_OVERFLOW: return "float overflow"; case PP_TOKEN_TOO_LONG: return "token too long"; case PP_INVALID_EXPRESSION: return "invalid expression"; case PP_DIVISION_BY_ZERO: return "division by zero"; case PP_EOF_IN_COMMENT: return "unexpected end of file found in comment"; case PP_UNEXPECTED_TOKEN: return "unexpected token"; case PP_DIRECTIVE_INVALID_NAME: return "invalid directive name"; case PP_MACRO_NAME_RESERVED: return "macro name is reserved"; case PP_MACRO_REDEFINED: return "macro redefined"; case PP_MACRO_PREDEFINED_REDEFINED: return "predefined macro redefined"; case PP_MACRO_PREDEFINED_UNDEFINED: return "predefined macro undefined"; case PP_MACRO_UNTERMINATED_INVOCATION: return "unterminated macro invocation"; case PP_MACRO_TOO_FEW_ARGS: return "Not enough arguments for macro"; case PP_MACRO_TOO_MANY_ARGS: return "Too many arguments for macro"; case PP_MACRO_DUPLICATE_PARAMETER_NAMES: return "duplicate macro parameter name"; case PP_CONDITIONAL_ENDIF_WITHOUT_IF: return "unexpected #endif found without a matching #if"; case PP_CONDITIONAL_ELSE_WITHOUT_IF: return "unexpected #else found without a matching #if"; case PP_CONDITIONAL_ELSE_AFTER_ELSE: return "unexpected #else found after another #else"; case PP_CONDITIONAL_ELIF_WITHOUT_IF: return "unexpected #elif found without a matching #if"; case PP_CONDITIONAL_ELIF_AFTER_ELSE: return "unexpected #elif found after #else"; case PP_CONDITIONAL_UNTERMINATED: return "unexpected end of file found in conditional block"; case PP_INVALID_EXTENSION_NAME: return "invalid extension name"; case PP_INVALID_EXTENSION_BEHAVIOR: return "invalid extension behavior"; case PP_INVALID_EXTENSION_DIRECTIVE: return "invalid extension directive"; case PP_INVALID_VERSION_NUMBER: return "invalid version number"; case PP_INVALID_VERSION_DIRECTIVE: return "invalid version directive"; case PP_VERSION_NOT_FIRST_STATEMENT: return "#version directive must occur before anything else, " "except for comments and white space"; case PP_VERSION_NOT_FIRST_LINE_ESSL3: return "#version directive must occur on the first line of the shader"; case PP_INVALID_LINE_NUMBER: return "invalid line number"; case PP_INVALID_FILE_NUMBER: return "invalid file number"; case PP_INVALID_LINE_DIRECTIVE: return "invalid line directive"; case PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3: return "extension directive must occur before any non-preprocessor tokens in ESSL3"; // Errors end. // Warnings begin. case PP_EOF_IN_DIRECTIVE: return "unexpected end of file found in directive"; case PP_CONDITIONAL_UNEXPECTED_TOKEN: return "unexpected token after conditional expression"; case PP_UNRECOGNIZED_PRAGMA: return "unrecognized pragma"; case PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1: return "extension directive should occur before any non-preprocessor tokens"; // Warnings end. default: assert(false); return ""; } } } // namespace pp freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.h000066400000000000000000000047161321746453100305040ustar00rootroot00000000000000// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_PREPROCESSOR_DIAGNOSTICSBASE_H_ #define COMPILER_PREPROCESSOR_DIAGNOSTICSBASE_H_ #include namespace pp { struct SourceLocation; // Base class for reporting diagnostic messages. // Derived classes are responsible for formatting and printing the messages. class Diagnostics { public: enum Severity { PP_ERROR, PP_WARNING }; enum ID { PP_ERROR_BEGIN, PP_INTERNAL_ERROR, PP_OUT_OF_MEMORY, PP_INVALID_CHARACTER, PP_INVALID_NUMBER, PP_INTEGER_OVERFLOW, PP_FLOAT_OVERFLOW, PP_TOKEN_TOO_LONG, PP_INVALID_EXPRESSION, PP_DIVISION_BY_ZERO, PP_EOF_IN_COMMENT, PP_UNEXPECTED_TOKEN, PP_DIRECTIVE_INVALID_NAME, PP_MACRO_NAME_RESERVED, PP_MACRO_REDEFINED, PP_MACRO_PREDEFINED_REDEFINED, PP_MACRO_PREDEFINED_UNDEFINED, PP_MACRO_UNTERMINATED_INVOCATION, PP_MACRO_TOO_FEW_ARGS, PP_MACRO_TOO_MANY_ARGS, PP_MACRO_DUPLICATE_PARAMETER_NAMES, PP_CONDITIONAL_ENDIF_WITHOUT_IF, PP_CONDITIONAL_ELSE_WITHOUT_IF, PP_CONDITIONAL_ELSE_AFTER_ELSE, PP_CONDITIONAL_ELIF_WITHOUT_IF, PP_CONDITIONAL_ELIF_AFTER_ELSE, PP_CONDITIONAL_UNTERMINATED, PP_CONDITIONAL_UNEXPECTED_TOKEN, PP_INVALID_EXTENSION_NAME, PP_INVALID_EXTENSION_BEHAVIOR, PP_INVALID_EXTENSION_DIRECTIVE, PP_INVALID_VERSION_NUMBER, PP_INVALID_VERSION_DIRECTIVE, PP_VERSION_NOT_FIRST_STATEMENT, PP_VERSION_NOT_FIRST_LINE_ESSL3, PP_INVALID_LINE_NUMBER, PP_INVALID_FILE_NUMBER, PP_INVALID_LINE_DIRECTIVE, PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3, PP_ERROR_END, PP_WARNING_BEGIN, PP_EOF_IN_DIRECTIVE, PP_UNRECOGNIZED_PRAGMA, PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1, PP_WARNING_END }; virtual ~Diagnostics(); void report(ID id, const SourceLocation &loc, const std::string &text); protected: Severity severity(ID id); std::string message(ID id); virtual void print(ID id, const SourceLocation &loc, const std::string &text) = 0; }; } // namespace pp #endif // COMPILER_PREPROCESSOR_DIAGNOSTICSBASE_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/DirectiveHandlerBase.cpp000066400000000000000000000004461321746453100320000ustar00rootroot00000000000000// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "DirectiveHandlerBase.h" namespace pp { DirectiveHandler::~DirectiveHandler() { } } // namespace pp freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/DirectiveHandlerBase.h000066400000000000000000000025551321746453100314500ustar00rootroot00000000000000// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_PREPROCESSOR_DIRECTIVEHANDLERBASE_H_ #define COMPILER_PREPROCESSOR_DIRECTIVEHANDLERBASE_H_ #include namespace pp { struct SourceLocation; // Base class for handling directives. // Preprocessor uses this class to notify the clients about certain // preprocessor directives. Derived classes are responsible for // handling them in an appropriate manner. class DirectiveHandler { public: virtual ~DirectiveHandler(); virtual void handleError(const SourceLocation &loc, const std::string &msg) = 0; // Handle pragma of form: #pragma name[(value)] virtual void handlePragma(const SourceLocation &loc, const std::string &name, const std::string &value, bool stdgl) = 0; virtual void handleExtension(const SourceLocation &loc, const std::string &name, const std::string &behavior) = 0; virtual void handleVersion(const SourceLocation &loc, int version) = 0; }; } // namespace pp #endif // COMPILER_PREPROCESSOR_DIRECTIVEHANDLERBASE_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/DirectiveParser.cpp000066400000000000000000000671561321746453100310770ustar00rootroot00000000000000// // Copyright (c) 2011-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "DirectiveParser.h" #include #include #include #include #include "DiagnosticsBase.h" #include "DirectiveHandlerBase.h" #include "ExpressionParser.h" #include "MacroExpander.h" #include "Token.h" #include "Tokenizer.h" namespace { enum DirectiveType { DIRECTIVE_NONE, DIRECTIVE_DEFINE, DIRECTIVE_UNDEF, DIRECTIVE_IF, DIRECTIVE_IFDEF, DIRECTIVE_IFNDEF, DIRECTIVE_ELSE, DIRECTIVE_ELIF, DIRECTIVE_ENDIF, DIRECTIVE_ERROR, DIRECTIVE_PRAGMA, DIRECTIVE_EXTENSION, DIRECTIVE_VERSION, DIRECTIVE_LINE }; DirectiveType getDirective(const pp::Token *token) { const char kDirectiveDefine[] = "define"; const char kDirectiveUndef[] = "undef"; const char kDirectiveIf[] = "if"; const char kDirectiveIfdef[] = "ifdef"; const char kDirectiveIfndef[] = "ifndef"; const char kDirectiveElse[] = "else"; const char kDirectiveElif[] = "elif"; const char kDirectiveEndif[] = "endif"; const char kDirectiveError[] = "error"; const char kDirectivePragma[] = "pragma"; const char kDirectiveExtension[] = "extension"; const char kDirectiveVersion[] = "version"; const char kDirectiveLine[] = "line"; if (token->type != pp::Token::IDENTIFIER) return DIRECTIVE_NONE; if (token->text == kDirectiveDefine) return DIRECTIVE_DEFINE; if (token->text == kDirectiveUndef) return DIRECTIVE_UNDEF; if (token->text == kDirectiveIf) return DIRECTIVE_IF; if (token->text == kDirectiveIfdef) return DIRECTIVE_IFDEF; if (token->text == kDirectiveIfndef) return DIRECTIVE_IFNDEF; if (token->text == kDirectiveElse) return DIRECTIVE_ELSE; if (token->text == kDirectiveElif) return DIRECTIVE_ELIF; if (token->text == kDirectiveEndif) return DIRECTIVE_ENDIF; if (token->text == kDirectiveError) return DIRECTIVE_ERROR; if (token->text == kDirectivePragma) return DIRECTIVE_PRAGMA; if (token->text == kDirectiveExtension) return DIRECTIVE_EXTENSION; if (token->text == kDirectiveVersion) return DIRECTIVE_VERSION; if (token->text == kDirectiveLine) return DIRECTIVE_LINE; return DIRECTIVE_NONE; } bool isConditionalDirective(DirectiveType directive) { switch (directive) { case DIRECTIVE_IF: case DIRECTIVE_IFDEF: case DIRECTIVE_IFNDEF: case DIRECTIVE_ELSE: case DIRECTIVE_ELIF: case DIRECTIVE_ENDIF: return true; default: return false; } } // Returns true if the token represents End Of Directive. bool isEOD(const pp::Token *token) { return (token->type == '\n') || (token->type == pp::Token::LAST); } void skipUntilEOD(pp::Lexer *lexer, pp::Token *token) { while(!isEOD(token)) { lexer->lex(token); } } bool isMacroNameReserved(const std::string &name) { // Names prefixed with "GL_" are reserved. if (name.substr(0, 3) == "GL_") return true; // Names containing two consecutive underscores are reserved. if (name.find("__") != std::string::npos) return true; return false; } bool isMacroPredefined(const std::string &name, const pp::MacroSet ¯oSet) { pp::MacroSet::const_iterator iter = macroSet.find(name); return iter != macroSet.end() ? iter->second.predefined : false; } } // namespace anonymous namespace pp { class DefinedParser : public Lexer { public: DefinedParser(Lexer *lexer, const MacroSet *macroSet, Diagnostics *diagnostics) : mLexer(lexer), mMacroSet(macroSet), mDiagnostics(diagnostics) { } protected: virtual void lex(Token *token) { const char kDefined[] = "defined"; mLexer->lex(token); if (token->type != Token::IDENTIFIER) return; if (token->text != kDefined) return; bool paren = false; mLexer->lex(token); if (token->type == '(') { paren = true; mLexer->lex(token); } if (token->type != Token::IDENTIFIER) { mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); skipUntilEOD(mLexer, token); return; } MacroSet::const_iterator iter = mMacroSet->find(token->text); std::string expression = iter != mMacroSet->end() ? "1" : "0"; if (paren) { mLexer->lex(token); if (token->type != ')') { mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); skipUntilEOD(mLexer, token); return; } } // We have a valid defined operator. // Convert the current token into a CONST_INT token. token->type = Token::CONST_INT; token->text = expression; } private: Lexer *mLexer; const MacroSet *mMacroSet; Diagnostics *mDiagnostics; }; DirectiveParser::DirectiveParser(Tokenizer *tokenizer, MacroSet *macroSet, Diagnostics *diagnostics, DirectiveHandler *directiveHandler) : mPastFirstStatement(false), mSeenNonPreprocessorToken(false), mTokenizer(tokenizer), mMacroSet(macroSet), mDiagnostics(diagnostics), mDirectiveHandler(directiveHandler), mShaderVersion(100) { } void DirectiveParser::lex(Token *token) { do { mTokenizer->lex(token); if (token->type == Token::PP_HASH) { parseDirective(token); mPastFirstStatement = true; } else if (!isEOD(token)) { mSeenNonPreprocessorToken = true; } if (token->type == Token::LAST) { if (!mConditionalStack.empty()) { const ConditionalBlock &block = mConditionalStack.back(); mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNTERMINATED, block.location, block.type); } break; } } while (skipping() || (token->type == '\n')); mPastFirstStatement = true; } void DirectiveParser::parseDirective(Token *token) { assert(token->type == Token::PP_HASH); mTokenizer->lex(token); if (isEOD(token)) { // Empty Directive. return; } DirectiveType directive = getDirective(token); // While in an excluded conditional block/group, // we only parse conditional directives. if (skipping() && !isConditionalDirective(directive)) { skipUntilEOD(mTokenizer, token); return; } switch(directive) { case DIRECTIVE_NONE: mDiagnostics->report(Diagnostics::PP_DIRECTIVE_INVALID_NAME, token->location, token->text); skipUntilEOD(mTokenizer, token); break; case DIRECTIVE_DEFINE: parseDefine(token); break; case DIRECTIVE_UNDEF: parseUndef(token); break; case DIRECTIVE_IF: parseIf(token); break; case DIRECTIVE_IFDEF: parseIfdef(token); break; case DIRECTIVE_IFNDEF: parseIfndef(token); break; case DIRECTIVE_ELSE: parseElse(token); break; case DIRECTIVE_ELIF: parseElif(token); break; case DIRECTIVE_ENDIF: parseEndif(token); break; case DIRECTIVE_ERROR: parseError(token); break; case DIRECTIVE_PRAGMA: parsePragma(token); break; case DIRECTIVE_EXTENSION: parseExtension(token); break; case DIRECTIVE_VERSION: parseVersion(token); break; case DIRECTIVE_LINE: parseLine(token); break; default: assert(false); break; } skipUntilEOD(mTokenizer, token); if (token->type == Token::LAST) { mDiagnostics->report(Diagnostics::PP_EOF_IN_DIRECTIVE, token->location, token->text); } } void DirectiveParser::parseDefine(Token *token) { assert(getDirective(token) == DIRECTIVE_DEFINE); mTokenizer->lex(token); if (token->type != Token::IDENTIFIER) { mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); return; } if (isMacroPredefined(token->text, *mMacroSet)) { mDiagnostics->report(Diagnostics::PP_MACRO_PREDEFINED_REDEFINED, token->location, token->text); return; } if (isMacroNameReserved(token->text)) { mDiagnostics->report(Diagnostics::PP_MACRO_NAME_RESERVED, token->location, token->text); return; } Macro macro; macro.type = Macro::kTypeObj; macro.name = token->text; mTokenizer->lex(token); if (token->type == '(' && !token->hasLeadingSpace()) { // Function-like macro. Collect arguments. macro.type = Macro::kTypeFunc; do { mTokenizer->lex(token); if (token->type != Token::IDENTIFIER) break; if (std::find(macro.parameters.begin(), macro.parameters.end(), token->text) != macro.parameters.end()) { mDiagnostics->report(Diagnostics::PP_MACRO_DUPLICATE_PARAMETER_NAMES, token->location, token->text); return; } macro.parameters.push_back(token->text); mTokenizer->lex(token); // Get ','. } while (token->type == ','); if (token->type != ')') { mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); return; } mTokenizer->lex(token); // Get ')'. } while ((token->type != '\n') && (token->type != Token::LAST)) { // Reset the token location because it is unnecessary in replacement // list. Resetting it also allows us to reuse Token::equals() to // compare macros. token->location = SourceLocation(); macro.replacements.push_back(*token); mTokenizer->lex(token); } if (!macro.replacements.empty()) { // Whitespace preceding the replacement list is not considered part of // the replacement list for either form of macro. macro.replacements.front().setHasLeadingSpace(false); } // Check for macro redefinition. MacroSet::const_iterator iter = mMacroSet->find(macro.name); if (iter != mMacroSet->end() && !macro.equals(iter->second)) { mDiagnostics->report(Diagnostics::PP_MACRO_REDEFINED, token->location, macro.name); return; } mMacroSet->insert(std::make_pair(macro.name, macro)); } void DirectiveParser::parseUndef(Token *token) { assert(getDirective(token) == DIRECTIVE_UNDEF); mTokenizer->lex(token); if (token->type != Token::IDENTIFIER) { mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); return; } MacroSet::iterator iter = mMacroSet->find(token->text); if (iter != mMacroSet->end()) { if (iter->second.predefined) { mDiagnostics->report(Diagnostics::PP_MACRO_PREDEFINED_UNDEFINED, token->location, token->text); } else { mMacroSet->erase(iter); } } mTokenizer->lex(token); if (!isEOD(token)) { mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); skipUntilEOD(mTokenizer, token); } } void DirectiveParser::parseIf(Token *token) { assert(getDirective(token) == DIRECTIVE_IF); parseConditionalIf(token); } void DirectiveParser::parseIfdef(Token *token) { assert(getDirective(token) == DIRECTIVE_IFDEF); parseConditionalIf(token); } void DirectiveParser::parseIfndef(Token *token) { assert(getDirective(token) == DIRECTIVE_IFNDEF); parseConditionalIf(token); } void DirectiveParser::parseElse(Token *token) { assert(getDirective(token) == DIRECTIVE_ELSE); if (mConditionalStack.empty()) { mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELSE_WITHOUT_IF, token->location, token->text); skipUntilEOD(mTokenizer, token); return; } ConditionalBlock &block = mConditionalStack.back(); if (block.skipBlock) { // No diagnostics. Just skip the whole line. skipUntilEOD(mTokenizer, token); return; } if (block.foundElseGroup) { mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELSE_AFTER_ELSE, token->location, token->text); skipUntilEOD(mTokenizer, token); return; } block.foundElseGroup = true; block.skipGroup = block.foundValidGroup; block.foundValidGroup = true; // Check if there are extra tokens after #else. mTokenizer->lex(token); if (!isEOD(token)) { mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, token->location, token->text); skipUntilEOD(mTokenizer, token); } } void DirectiveParser::parseElif(Token *token) { assert(getDirective(token) == DIRECTIVE_ELIF); if (mConditionalStack.empty()) { mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELIF_WITHOUT_IF, token->location, token->text); skipUntilEOD(mTokenizer, token); return; } ConditionalBlock &block = mConditionalStack.back(); if (block.skipBlock) { // No diagnostics. Just skip the whole line. skipUntilEOD(mTokenizer, token); return; } if (block.foundElseGroup) { mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELIF_AFTER_ELSE, token->location, token->text); skipUntilEOD(mTokenizer, token); return; } if (block.foundValidGroup) { // Do not parse the expression. // Also be careful not to emit a diagnostic. block.skipGroup = true; skipUntilEOD(mTokenizer, token); return; } int expression = parseExpressionIf(token); block.skipGroup = expression == 0; block.foundValidGroup = expression != 0; } void DirectiveParser::parseEndif(Token *token) { assert(getDirective(token) == DIRECTIVE_ENDIF); if (mConditionalStack.empty()) { mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ENDIF_WITHOUT_IF, token->location, token->text); skipUntilEOD(mTokenizer, token); return; } mConditionalStack.pop_back(); // Check if there are tokens after #endif. mTokenizer->lex(token); if (!isEOD(token)) { mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, token->location, token->text); skipUntilEOD(mTokenizer, token); } } void DirectiveParser::parseError(Token *token) { assert(getDirective(token) == DIRECTIVE_ERROR); std::ostringstream stream; mTokenizer->lex(token); while ((token->type != '\n') && (token->type != Token::LAST)) { stream << *token; mTokenizer->lex(token); } mDirectiveHandler->handleError(token->location, stream.str()); } // Parses pragma of form: #pragma name[(value)]. void DirectiveParser::parsePragma(Token *token) { assert(getDirective(token) == DIRECTIVE_PRAGMA); enum State { PRAGMA_NAME, LEFT_PAREN, PRAGMA_VALUE, RIGHT_PAREN }; bool valid = true; std::string name, value; int state = PRAGMA_NAME; mTokenizer->lex(token); bool stdgl = token->text == "STDGL"; if (stdgl) { mTokenizer->lex(token); } while ((token->type != '\n') && (token->type != Token::LAST)) { switch(state++) { case PRAGMA_NAME: name = token->text; valid = valid && (token->type == Token::IDENTIFIER); break; case LEFT_PAREN: valid = valid && (token->type == '('); break; case PRAGMA_VALUE: value = token->text; valid = valid && (token->type == Token::IDENTIFIER); break; case RIGHT_PAREN: valid = valid && (token->type == ')'); break; default: valid = false; break; } mTokenizer->lex(token); } valid = valid && ((state == PRAGMA_NAME) || // Empty pragma. (state == LEFT_PAREN) || // Without value. (state == RIGHT_PAREN + 1)); // With value. if (!valid) { mDiagnostics->report(Diagnostics::PP_UNRECOGNIZED_PRAGMA, token->location, name); } else if (state > PRAGMA_NAME) // Do not notify for empty pragma. { mDirectiveHandler->handlePragma(token->location, name, value, stdgl); } } void DirectiveParser::parseExtension(Token *token) { assert(getDirective(token) == DIRECTIVE_EXTENSION); enum State { EXT_NAME, COLON, EXT_BEHAVIOR }; bool valid = true; std::string name, behavior; int state = EXT_NAME; mTokenizer->lex(token); while ((token->type != '\n') && (token->type != Token::LAST)) { switch (state++) { case EXT_NAME: if (valid && (token->type != Token::IDENTIFIER)) { mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_NAME, token->location, token->text); valid = false; } if (valid) name = token->text; break; case COLON: if (valid && (token->type != ':')) { mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); valid = false; } break; case EXT_BEHAVIOR: if (valid && (token->type != Token::IDENTIFIER)) { mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_BEHAVIOR, token->location, token->text); valid = false; } if (valid) behavior = token->text; break; default: if (valid) { mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); valid = false; } break; } mTokenizer->lex(token); } if (valid && (state != EXT_BEHAVIOR + 1)) { mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_DIRECTIVE, token->location, token->text); valid = false; } if (valid && mSeenNonPreprocessorToken) { if (mShaderVersion >= 300) { mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3, token->location, token->text); valid = false; } else { mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1, token->location, token->text); } } if (valid) mDirectiveHandler->handleExtension(token->location, name, behavior); } void DirectiveParser::parseVersion(Token *token) { assert(getDirective(token) == DIRECTIVE_VERSION); if (mPastFirstStatement) { mDiagnostics->report(Diagnostics::PP_VERSION_NOT_FIRST_STATEMENT, token->location, token->text); skipUntilEOD(mTokenizer, token); return; } enum State { VERSION_NUMBER, VERSION_PROFILE, VERSION_ENDLINE }; bool valid = true; int version = 0; int state = VERSION_NUMBER; mTokenizer->lex(token); while (valid && (token->type != '\n') && (token->type != Token::LAST)) { switch (state) { case VERSION_NUMBER: if (token->type != Token::CONST_INT) { mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_NUMBER, token->location, token->text); valid = false; } if (valid && !token->iValue(&version)) { mDiagnostics->report(Diagnostics::PP_INTEGER_OVERFLOW, token->location, token->text); valid = false; } if (valid) { state = (version < 300) ? VERSION_ENDLINE : VERSION_PROFILE; } break; case VERSION_PROFILE: if (token->type != Token::IDENTIFIER || token->text != "es") { mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_DIRECTIVE, token->location, token->text); valid = false; } state = VERSION_ENDLINE; break; default: mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); valid = false; break; } mTokenizer->lex(token); } if (valid && (state != VERSION_ENDLINE)) { mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_DIRECTIVE, token->location, token->text); valid = false; } if (valid && version >= 300 && token->location.line > 1) { mDiagnostics->report(Diagnostics::PP_VERSION_NOT_FIRST_LINE_ESSL3, token->location, token->text); valid = false; } if (valid) { mDirectiveHandler->handleVersion(token->location, version); mShaderVersion = version; PredefineMacro(mMacroSet, "__VERSION__", version); } } void DirectiveParser::parseLine(Token *token) { assert(getDirective(token) == DIRECTIVE_LINE); enum State { LINE_NUMBER, FILE_NUMBER }; bool valid = true; int line = 0, file = 0; int state = LINE_NUMBER; MacroExpander macroExpander(mTokenizer, mMacroSet, mDiagnostics); macroExpander.lex(token); while ((token->type != '\n') && (token->type != Token::LAST)) { switch (state++) { case LINE_NUMBER: if (valid && (token->type != Token::CONST_INT)) { mDiagnostics->report(Diagnostics::PP_INVALID_LINE_NUMBER, token->location, token->text); valid = false; } if (valid && !token->iValue(&line)) { mDiagnostics->report(Diagnostics::PP_INTEGER_OVERFLOW, token->location, token->text); valid = false; } break; case FILE_NUMBER: if (valid && (token->type != Token::CONST_INT)) { mDiagnostics->report(Diagnostics::PP_INVALID_FILE_NUMBER, token->location, token->text); valid = false; } if (valid && !token->iValue(&file)) { mDiagnostics->report(Diagnostics::PP_INTEGER_OVERFLOW, token->location, token->text); valid = false; } break; default: if (valid) { mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); valid = false; } break; } macroExpander.lex(token); } if (valid && (state != FILE_NUMBER) && (state != FILE_NUMBER + 1)) { mDiagnostics->report(Diagnostics::PP_INVALID_LINE_DIRECTIVE, token->location, token->text); valid = false; } if (valid) { mTokenizer->setLineNumber(line); if (state == FILE_NUMBER + 1) mTokenizer->setFileNumber(file); } } bool DirectiveParser::skipping() const { if (mConditionalStack.empty()) return false; const ConditionalBlock& block = mConditionalStack.back(); return block.skipBlock || block.skipGroup; } void DirectiveParser::parseConditionalIf(Token *token) { ConditionalBlock block; block.type = token->text; block.location = token->location; if (skipping()) { // This conditional block is inside another conditional group // which is skipped. As a consequence this whole block is skipped. // Be careful not to parse the conditional expression that might // emit a diagnostic. skipUntilEOD(mTokenizer, token); block.skipBlock = true; } else { DirectiveType directive = getDirective(token); int expression = 0; switch (directive) { case DIRECTIVE_IF: expression = parseExpressionIf(token); break; case DIRECTIVE_IFDEF: expression = parseExpressionIfdef(token); break; case DIRECTIVE_IFNDEF: expression = parseExpressionIfdef(token) == 0 ? 1 : 0; break; default: assert(false); break; } block.skipGroup = expression == 0; block.foundValidGroup = expression != 0; } mConditionalStack.push_back(block); } int DirectiveParser::parseExpressionIf(Token *token) { assert((getDirective(token) == DIRECTIVE_IF) || (getDirective(token) == DIRECTIVE_ELIF)); DefinedParser definedParser(mTokenizer, mMacroSet, mDiagnostics); MacroExpander macroExpander(&definedParser, mMacroSet, mDiagnostics); ExpressionParser expressionParser(¯oExpander, mDiagnostics); int expression = 0; macroExpander.lex(token); expressionParser.parse(token, &expression); // Check if there are tokens after #if expression. if (!isEOD(token)) { mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, token->location, token->text); skipUntilEOD(mTokenizer, token); } return expression; } int DirectiveParser::parseExpressionIfdef(Token *token) { assert((getDirective(token) == DIRECTIVE_IFDEF) || (getDirective(token) == DIRECTIVE_IFNDEF)); mTokenizer->lex(token); if (token->type != Token::IDENTIFIER) { mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); skipUntilEOD(mTokenizer, token); return 0; } MacroSet::const_iterator iter = mMacroSet->find(token->text); int expression = iter != mMacroSet->end() ? 1 : 0; // Check if there are tokens after #ifdef expression. mTokenizer->lex(token); if (!isEOD(token)) { mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, token->location, token->text); skipUntilEOD(mTokenizer, token); } return expression; } } // namespace pp freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/DirectiveParser.h000066400000000000000000000044441321746453100305330ustar00rootroot00000000000000// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_PREPROCESSOR_DIRECTIVEPARSER_H_ #define COMPILER_PREPROCESSOR_DIRECTIVEPARSER_H_ #include "Lexer.h" #include "Macro.h" #include "pp_utils.h" #include "SourceLocation.h" namespace pp { class Diagnostics; class DirectiveHandler; class Tokenizer; class DirectiveParser : public Lexer { public: DirectiveParser(Tokenizer *tokenizer, MacroSet *macroSet, Diagnostics *diagnostics, DirectiveHandler *directiveHandler); virtual void lex(Token *token); private: PP_DISALLOW_COPY_AND_ASSIGN(DirectiveParser); void parseDirective(Token *token); void parseDefine(Token *token); void parseUndef(Token *token); void parseIf(Token *token); void parseIfdef(Token *token); void parseIfndef(Token *token); void parseElse(Token *token); void parseElif(Token *token); void parseEndif(Token *token); void parseError(Token *token); void parsePragma(Token *token); void parseExtension(Token *token); void parseVersion(Token *token); void parseLine(Token *token); bool skipping() const; void parseConditionalIf(Token *token); int parseExpressionIf(Token *token); int parseExpressionIfdef(Token *token); struct ConditionalBlock { std::string type; SourceLocation location; bool skipBlock; bool skipGroup; bool foundValidGroup; bool foundElseGroup; ConditionalBlock() : skipBlock(false), skipGroup(false), foundValidGroup(false), foundElseGroup(false) { } }; bool mPastFirstStatement; bool mSeenNonPreprocessorToken; // Tracks if a non-preprocessor token has been seen yet. Some macros, such as // #extension must be declared before all shader code. std::vector mConditionalStack; Tokenizer *mTokenizer; MacroSet *mMacroSet; Diagnostics *mDiagnostics; DirectiveHandler *mDirectiveHandler; int mShaderVersion; }; } // namespace pp #endif // COMPILER_PREPROCESSOR_DIRECTIVEPARSER_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/ExpressionParser.cpp000066400000000000000000001512671321746453100313150ustar00rootroot00000000000000/* A Bison parser, made by GNU Bison 3.0.4. */ /* Bison implementation for Yacc-like parsers in C Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. 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 . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ #define YYBISON_VERSION "3.0.4" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 1 /* Push parsers. */ #define YYPUSH 0 /* Pull parsers. */ #define YYPULL 1 /* Substitute the variable and function names. */ #define yyparse ppparse #define yylex pplex #define yyerror pperror #define yydebug ppdebug #define yynerrs ppnerrs /* Copy the first part of user declarations. */ // // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // This file is auto-generated by generate_parser.sh. DO NOT EDIT! #if defined(__GNUC__) // Triggered by the auto-generated pplval variable. #if !defined(__clang__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #else #pragma GCC diagnostic ignored "-Wuninitialized" #endif #elif defined(_MSC_VER) #pragma warning(disable: 4065 4244 4701 4702) #endif #include "ExpressionParser.h" #if defined(_MSC_VER) #include #else #include #endif #include #include #include "DiagnosticsBase.h" #include "Lexer.h" #include "Token.h" #if defined(_MSC_VER) typedef __int64 YYSTYPE; #else #include typedef intmax_t YYSTYPE; #endif // _MSC_VER #define YYENABLE_NLS 0 #define YYLTYPE_IS_TRIVIAL 1 #define YYSTYPE_IS_TRIVIAL 1 #define YYSTYPE_IS_DECLARED 1 namespace { struct Context { pp::Diagnostics* diagnostics; pp::Lexer* lexer; pp::Token* token; int* result; }; } // namespace static int yylex(YYSTYPE* lvalp, Context* context); static void yyerror(Context* context, const char* reason); # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus # define YY_NULLPTR nullptr # else # define YY_NULLPTR 0 # endif # endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif #if YYDEBUG extern int ppdebug; #endif /* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { TOK_CONST_INT = 258, TOK_OP_OR = 259, TOK_OP_AND = 260, TOK_OP_EQ = 261, TOK_OP_NE = 262, TOK_OP_LE = 263, TOK_OP_GE = 264, TOK_OP_LEFT = 265, TOK_OP_RIGHT = 266, TOK_UNARY = 267 }; #endif /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 #endif int ppparse (Context *context); /* Copy the second part of user declarations. */ #ifdef short # undef short #endif #ifdef YYTYPE_UINT8 typedef YYTYPE_UINT8 yytype_uint8; #else typedef unsigned char yytype_uint8; #endif #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; #else typedef signed char yytype_int8; #endif #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else typedef unsigned short int yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else typedef short int yytype_int16; #endif #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t # elif ! defined YYSIZE_T # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else # define YYSIZE_T unsigned int # endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ # define YY_(Msgid) Msgid # endif #endif #ifndef YY_ATTRIBUTE # if (defined __GNUC__ \ && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C # define YY_ATTRIBUTE(Spec) __attribute__(Spec) # else # define YY_ATTRIBUTE(Spec) /* empty */ # endif #endif #ifndef YY_ATTRIBUTE_PURE # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) #endif #ifndef YY_ATTRIBUTE_UNUSED # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) #endif #if !defined _Noreturn \ && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) # if defined _MSC_VER && 1200 <= _MSC_VER # define _Noreturn __declspec (noreturn) # else # define _Noreturn YY_ATTRIBUTE ((__noreturn__)) # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) #else # define YYUSE(E) /* empty */ #endif #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value #endif #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_END #endif #ifndef YY_INITIAL_VALUE # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # elif defined __BUILTIN_VA_ARG_INCR # include /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS # include /* INFRINGES ON USER NAME SPACE */ /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's 'empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined EXIT_SUCCESS void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free # if ! defined free && ! defined EXIT_SUCCESS void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { yytype_int16 yyss_alloc; YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) #endif #if defined YYCOPY_NEEDED && YYCOPY_NEEDED /* Copy COUNT objects from SRC to DST. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ while (0) # endif # endif #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ #define YYFINAL 14 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 175 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 27 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 3 /* YYNRULES -- Number of rules. */ #define YYNRULES 26 /* YYNSTATES -- Number of states. */ #define YYNSTATES 52 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 267 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM as returned by yylex, without out-of-bounds checking. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 23, 2, 2, 2, 21, 8, 2, 25, 26, 19, 17, 2, 18, 2, 20, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 11, 2, 12, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 6, 2, 24, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 9, 10, 13, 14, 15, 16, 22 }; #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { 0, 97, 97, 104, 105, 108, 111, 114, 117, 120, 123, 126, 129, 132, 135, 138, 141, 144, 147, 150, 163, 176, 179, 182, 185, 188, 191 }; #endif #if YYDEBUG || YYERROR_VERBOSE || 0 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "TOK_CONST_INT", "TOK_OP_OR", "TOK_OP_AND", "'|'", "'^'", "'&'", "TOK_OP_EQ", "TOK_OP_NE", "'<'", "'>'", "TOK_OP_LE", "TOK_OP_GE", "TOK_OP_LEFT", "TOK_OP_RIGHT", "'+'", "'-'", "'*'", "'/'", "'%'", "TOK_UNARY", "'!'", "'~'", "'('", "')'", "$accept", "input", "expression", YY_NULLPTR }; #endif # ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 124, 94, 38, 261, 262, 60, 62, 263, 264, 265, 266, 43, 45, 42, 47, 37, 267, 33, 126, 40, 41 }; # endif #define YYPACT_NINF -11 #define yypact_value_is_default(Yystate) \ (!!((Yystate) == (-11))) #define YYTABLE_NINF -1 #define yytable_value_is_error(Yytable_value) \ 0 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ static const yytype_int16 yypact[] = { 46, -11, 46, 46, 46, 46, 46, 12, 68, -11, -11, -11, -11, 27, -11, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, -11, 85, 101, 116, 130, 143, 154, 154, -10, -10, -10, -10, 37, 37, 31, 31, -11, -11, -11 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. Performed when YYTABLE does not specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { 0, 3, 0, 0, 0, 0, 0, 0, 2, 25, 24, 22, 23, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 4, 5, 6, 7, 8, 10, 9, 14, 13, 12, 11, 16, 15, 18, 17, 21, 20, 19 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { -11, -11, -2 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { -1, 7, 8 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule whose number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_uint8 yytable[] = { 9, 10, 11, 12, 13, 26, 27, 28, 29, 30, 31, 32, 14, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 1, 30, 31, 32, 33, 28, 29, 30, 31, 32, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 4, 5, 6, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 }; static const yytype_int8 yycheck[] = { 2, 3, 4, 5, 6, 15, 16, 17, 18, 19, 20, 21, 0, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 3, 19, 20, 21, 26, 17, 18, 19, 20, 21, -1, -1, -1, -1, 17, 18, -1, -1, -1, -1, 23, 24, 25, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 3, 17, 18, 23, 24, 25, 28, 29, 29, 29, 29, 29, 29, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 26, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { 0, 27, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 3 }; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY) \ { \ yychar = (Token); \ yylval = (Value); \ YYPOPSTACK (yylen); \ yystate = *yyssp; \ goto yybackup; \ } \ else \ { \ yyerror (context, YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (0) /* Error token number */ #define YYTERROR 1 #define YYERRCODE 256 /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) /* This macro is provided for backward compatibility. */ #ifndef YY_LOCATION_PRINT # define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ Type, Value, context); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) /*----------------------------------------. | Print this symbol's value on YYOUTPUT. | `----------------------------------------*/ static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Context *context) { FILE *yyo = yyoutput; YYUSE (yyo); YYUSE (context); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # endif YYUSE (yytype); } /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Context *context) { YYFPRINTF (yyoutput, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); yy_symbol_value_print (yyoutput, yytype, yyvaluep, context); YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) { int yybot = *yybottom; YYFPRINTF (stderr, " %d", yybot); } YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ static void yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, Context *context) { unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], &(yyvsp[(yyi + 1) - (yynrhs)]) , context); YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyssp, yyvsp, Rule, context); \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ static YYSIZE_T yystrlen (const char *yystr) { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } # endif # endif # ifndef yystpcpy # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ static char * yystpcpy (char *yydest, const char *yysrc) { char *yyd = yydest; const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif # ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ static YYSIZE_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) switch (*++yyp) { case '\'': case ',': goto do_not_strip_quotes; case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; yyn++; break; case '"': if (yyres) yyres[yyn] = '\0'; return yyn; } do_not_strip_quotes: ; } if (! yyres) return yystrlen (yystr); return yystpcpy (yyres, yystr) - yyres; } # endif /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message about the unexpected token YYTOKEN for the state stack whose top is YYSSP. Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is not large enough to hold the message. In that case, also set *YYMSG_ALLOC to the required number of bytes. Return 2 if the required number of bytes is too large to store. */ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = YY_NULLPTR; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per "expected"). */ int yycount = 0; /* There are many possibilities here to consider: - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action is an error action. In that case, don't check for expected tokens because there are none. - The only way there can be no lookahead present (in yychar) is if this state is a consistent state with a default action. Thus, detecting the absence of a lookahead is sufficient to determine that there is no unexpected or expected token to report. In that case, just report a simple "syntax error". - Don't assume there isn't a lookahead just because this state is a consistent state with a default action. There might have been a previous inconsistent state, consistent state with a non-default action, or user semantic action that manipulated yychar. - Of course, the expected token list depends on states to have correct lookahead information, and it depends on the parser not to perform extra reductions after fetching a lookahead from the scanner and before detecting a syntax error. Thus, state merging (from LALR or IELR) and default reductions corrupt the expected token list. However, the list is correct for canonical LR with one exception: it will still contain any token that will not be accepted due to an error action in a later state. */ if (yytoken != YYEMPTY) { int yyn = yypact[*yyssp]; yyarg[yycount++] = yytname[yytoken]; if (!yypact_value_is_default (yyn)) { /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. In other words, skip the first -YYN actions for this state because they are default actions. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yyx; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR && !yytable_value_is_error (yytable[yyx + yyn])) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; break; } yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; } } } } switch (yycount) { # define YYCASE_(N, S) \ case N: \ yyformat = S; \ break YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); # undef YYCASE_ } { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; } if (*yymsg_alloc < yysize) { *yymsg_alloc = 2 * yysize; if (! (yysize <= *yymsg_alloc && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; return 1; } /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ { char *yyp = *yymsg; int yyi = 0; while ((*yyp = *yyformat) != '\0') if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyformat += 2; } else { yyp++; yyformat++; } } return 0; } #endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Context *context) { YYUSE (yyvaluep); YYUSE (context); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YYUSE (yytype); YY_IGNORE_MAYBE_UNINITIALIZED_END } /*----------. | yyparse. | `----------*/ int yyparse (Context *context) { /* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ /* Default value used for initialization, for pacifying older GCCs or non-GCC compilers. */ YY_INITIAL_VALUE (static YYSTYPE yyval_default;) YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); /* Number of syntax errors so far. */ int yynerrs; int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: 'yyss': related to states. 'yyvs': related to semantic values. Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ yytype_int16 yyssa[YYINITDEPTH]; yytype_int16 *yyss; yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; YYSIZE_T yystacksize; int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ int yytoken = 0; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; yyssp = yyss = yyssa; yyvsp = yyvs = yyvsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = yylex (&yylval, context); } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yytable_value_is_error (yyn)) goto yyerrlab; yyn = -yyn; goto yyreduce; } /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token. */ yychar = YYEMPTY; yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: '$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; YY_REDUCE_PRINT (yyn); switch (yyn) { case 2: { *(context->result) = static_cast((yyvsp[0])); YYACCEPT; } break; case 4: { (yyval) = (yyvsp[-2]) || (yyvsp[0]); } break; case 5: { (yyval) = (yyvsp[-2]) && (yyvsp[0]); } break; case 6: { (yyval) = (yyvsp[-2]) | (yyvsp[0]); } break; case 7: { (yyval) = (yyvsp[-2]) ^ (yyvsp[0]); } break; case 8: { (yyval) = (yyvsp[-2]) & (yyvsp[0]); } break; case 9: { (yyval) = (yyvsp[-2]) != (yyvsp[0]); } break; case 10: { (yyval) = (yyvsp[-2]) == (yyvsp[0]); } break; case 11: { (yyval) = (yyvsp[-2]) >= (yyvsp[0]); } break; case 12: { (yyval) = (yyvsp[-2]) <= (yyvsp[0]); } break; case 13: { (yyval) = (yyvsp[-2]) > (yyvsp[0]); } break; case 14: { (yyval) = (yyvsp[-2]) < (yyvsp[0]); } break; case 15: { (yyval) = (yyvsp[-2]) >> (yyvsp[0]); } break; case 16: { (yyval) = (yyvsp[-2]) << (yyvsp[0]); } break; case 17: { (yyval) = (yyvsp[-2]) - (yyvsp[0]); } break; case 18: { (yyval) = (yyvsp[-2]) + (yyvsp[0]); } break; case 19: { if ((yyvsp[0]) == 0) { std::ostringstream stream; stream << (yyvsp[-2]) << " % " << (yyvsp[0]); std::string text = stream.str(); context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO, context->token->location, text.c_str()); YYABORT; } else { (yyval) = (yyvsp[-2]) % (yyvsp[0]); } } break; case 20: { if ((yyvsp[0]) == 0) { std::ostringstream stream; stream << (yyvsp[-2]) << " / " << (yyvsp[0]); std::string text = stream.str(); context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO, context->token->location, text.c_str()); YYABORT; } else { (yyval) = (yyvsp[-2]) / (yyvsp[0]); } } break; case 21: { (yyval) = (yyvsp[-2]) * (yyvsp[0]); } break; case 22: { (yyval) = ! (yyvsp[0]); } break; case 23: { (yyval) = ~ (yyvsp[0]); } break; case 24: { (yyval) = - (yyvsp[0]); } break; case 25: { (yyval) = + (yyvsp[0]); } break; case 26: { (yyval) = (yyvsp[-1]); } break; default: break; } /* User semantic actions sometimes alter yychar, and that requires that yytoken be updated with the new translation. We take the approach of translating immediately before every use of yytoken. One alternative is translating here after every semantic action, but that translation would be missed if the semantic action invokes YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an incorrect destructor might then be invoked immediately. In the case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*--------------------------------------. | yyerrlab -- here on detecting error. | `--------------------------------------*/ yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (context, YY_("syntax error")); #else # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ yyssp, yytoken) { char const *yymsgp = YY_("syntax error"); int yysyntax_error_status; yysyntax_error_status = YYSYNTAX_ERROR; if (yysyntax_error_status == 0) yymsgp = yymsg; else if (yysyntax_error_status == 1) { if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); if (!yymsg) { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; yysyntax_error_status = 2; } else { yysyntax_error_status = YYSYNTAX_ERROR; yymsgp = yymsg; } } yyerror (context, yymsgp); if (yysyntax_error_status == 2) goto yyexhaustedlab; } # undef YYSYNTAX_ERROR #endif } if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval, context); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) goto yyerrorlab; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yydestruct ("Error: popping", yystos[yystate], yyvsp, context); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (context, YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEMPTY) { /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = YYTRANSLATE (yychar); yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, context); } /* Do not reclaim the symbols of the rule whose action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp, context); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif return yyresult; } int yylex(YYSTYPE *lvalp, Context *context) { int type = 0; pp::Token *token = context->token; switch (token->type) { case pp::Token::CONST_INT: { unsigned int val = 0; if (!token->uValue(&val)) { context->diagnostics->report(pp::Diagnostics::PP_INTEGER_OVERFLOW, token->location, token->text); } *lvalp = static_cast(val); type = TOK_CONST_INT; break; } case pp::Token::OP_OR: type = TOK_OP_OR; break; case pp::Token::OP_AND: type = TOK_OP_AND; break; case pp::Token::OP_NE: type = TOK_OP_NE; break; case pp::Token::OP_EQ: type = TOK_OP_EQ; break; case pp::Token::OP_GE: type = TOK_OP_GE; break; case pp::Token::OP_LE: type = TOK_OP_LE; break; case pp::Token::OP_RIGHT: type = TOK_OP_RIGHT; break; case pp::Token::OP_LEFT: type = TOK_OP_LEFT; break; case '|': case '^': case '&': case '>': case '<': case '-': case '+': case '%': case '/': case '*': case '!': case '~': case '(': case ')': type = token->type; break; default: break; } // Advance to the next token if the current one is valid. if (type != 0) context->lexer->lex(token); return type; } void yyerror(Context *context, const char *reason) { context->diagnostics->report(pp::Diagnostics::PP_INVALID_EXPRESSION, context->token->location, reason); } namespace pp { ExpressionParser::ExpressionParser(Lexer *lexer, Diagnostics *diagnostics) : mLexer(lexer), mDiagnostics(diagnostics) { } bool ExpressionParser::parse(Token *token, int *result) { Context context; context.diagnostics = mDiagnostics; context.lexer = mLexer; context.token = token; context.result = result; int ret = yyparse(&context); switch (ret) { case 0: case 1: break; case 2: mDiagnostics->report(Diagnostics::PP_OUT_OF_MEMORY, token->location, ""); break; default: assert(false); mDiagnostics->report(Diagnostics::PP_INTERNAL_ERROR, token->location, ""); break; } return ret == 0; } } // namespace pp freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/ExpressionParser.h000066400000000000000000000012741321746453100307520ustar00rootroot00000000000000// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_PREPROCESSOR_EXPRESSIONPARSER_H_ #define COMPILER_PREPROCESSOR_EXPRESSIONPARSER_H_ #include "pp_utils.h" namespace pp { class Diagnostics; class Lexer; struct Token; class ExpressionParser { public: ExpressionParser(Lexer *lexer, Diagnostics *diagnostics); bool parse(Token *token, int *result); private: PP_DISALLOW_COPY_AND_ASSIGN(ExpressionParser); Lexer *mLexer; Diagnostics *mDiagnostics; }; } // namespace pp #endif // COMPILER_PREPROCESSOR_EXPRESSIONPARSER_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/ExpressionParser.y000066400000000000000000000154511321746453100307750ustar00rootroot00000000000000/* // // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file contains the Yacc grammar for GLSL ES preprocessor expression. IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh, WHICH GENERATES THE GLSL ES preprocessor expression parser. */ %{ // // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // This file is auto-generated by generate_parser.sh. DO NOT EDIT! #if defined(__GNUC__) // Triggered by the auto-generated pplval variable. #if !defined(__clang__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #else #pragma GCC diagnostic ignored "-Wuninitialized" #endif #elif defined(_MSC_VER) #pragma warning(disable: 4065 4244 4701 4702) #endif #include "ExpressionParser.h" #if defined(_MSC_VER) #include #else #include #endif #include #include #include "DiagnosticsBase.h" #include "Lexer.h" #include "Token.h" #if defined(_MSC_VER) typedef __int64 YYSTYPE; #else #include typedef intmax_t YYSTYPE; #endif // _MSC_VER #define YYENABLE_NLS 0 #define YYLTYPE_IS_TRIVIAL 1 #define YYSTYPE_IS_TRIVIAL 1 #define YYSTYPE_IS_DECLARED 1 namespace { struct Context { pp::Diagnostics* diagnostics; pp::Lexer* lexer; pp::Token* token; int* result; }; } // namespace %} %pure-parser %name-prefix "pp" %parse-param {Context *context} %lex-param {Context *context} %{ static int yylex(YYSTYPE* lvalp, Context* context); static void yyerror(Context* context, const char* reason); %} %token TOK_CONST_INT %left TOK_OP_OR %left TOK_OP_AND %left '|' %left '^' %left '&' %left TOK_OP_EQ TOK_OP_NE %left '<' '>' TOK_OP_LE TOK_OP_GE %left TOK_OP_LEFT TOK_OP_RIGHT %left '+' '-' %left '*' '/' '%' %right TOK_UNARY %% input : expression { *(context->result) = static_cast($1); YYACCEPT; } ; expression : TOK_CONST_INT | expression TOK_OP_OR expression { $$ = $1 || $3; } | expression TOK_OP_AND expression { $$ = $1 && $3; } | expression '|' expression { $$ = $1 | $3; } | expression '^' expression { $$ = $1 ^ $3; } | expression '&' expression { $$ = $1 & $3; } | expression TOK_OP_NE expression { $$ = $1 != $3; } | expression TOK_OP_EQ expression { $$ = $1 == $3; } | expression TOK_OP_GE expression { $$ = $1 >= $3; } | expression TOK_OP_LE expression { $$ = $1 <= $3; } | expression '>' expression { $$ = $1 > $3; } | expression '<' expression { $$ = $1 < $3; } | expression TOK_OP_RIGHT expression { $$ = $1 >> $3; } | expression TOK_OP_LEFT expression { $$ = $1 << $3; } | expression '-' expression { $$ = $1 - $3; } | expression '+' expression { $$ = $1 + $3; } | expression '%' expression { if ($3 == 0) { std::ostringstream stream; stream << $1 << " % " << $3; std::string text = stream.str(); context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO, context->token->location, text.c_str()); YYABORT; } else { $$ = $1 % $3; } } | expression '/' expression { if ($3 == 0) { std::ostringstream stream; stream << $1 << " / " << $3; std::string text = stream.str(); context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO, context->token->location, text.c_str()); YYABORT; } else { $$ = $1 / $3; } } | expression '*' expression { $$ = $1 * $3; } | '!' expression %prec TOK_UNARY { $$ = ! $2; } | '~' expression %prec TOK_UNARY { $$ = ~ $2; } | '-' expression %prec TOK_UNARY { $$ = - $2; } | '+' expression %prec TOK_UNARY { $$ = + $2; } | '(' expression ')' { $$ = $2; } ; %% int yylex(YYSTYPE *lvalp, Context *context) { int type = 0; pp::Token *token = context->token; switch (token->type) { case pp::Token::CONST_INT: { unsigned int val = 0; if (!token->uValue(&val)) { context->diagnostics->report(pp::Diagnostics::PP_INTEGER_OVERFLOW, token->location, token->text); } *lvalp = static_cast(val); type = TOK_CONST_INT; break; } case pp::Token::OP_OR: type = TOK_OP_OR; break; case pp::Token::OP_AND: type = TOK_OP_AND; break; case pp::Token::OP_NE: type = TOK_OP_NE; break; case pp::Token::OP_EQ: type = TOK_OP_EQ; break; case pp::Token::OP_GE: type = TOK_OP_GE; break; case pp::Token::OP_LE: type = TOK_OP_LE; break; case pp::Token::OP_RIGHT: type = TOK_OP_RIGHT; break; case pp::Token::OP_LEFT: type = TOK_OP_LEFT; break; case '|': case '^': case '&': case '>': case '<': case '-': case '+': case '%': case '/': case '*': case '!': case '~': case '(': case ')': type = token->type; break; default: break; } // Advance to the next token if the current one is valid. if (type != 0) context->lexer->lex(token); return type; } void yyerror(Context *context, const char *reason) { context->diagnostics->report(pp::Diagnostics::PP_INVALID_EXPRESSION, context->token->location, reason); } namespace pp { ExpressionParser::ExpressionParser(Lexer *lexer, Diagnostics *diagnostics) : mLexer(lexer), mDiagnostics(diagnostics) { } bool ExpressionParser::parse(Token *token, int *result) { Context context; context.diagnostics = mDiagnostics; context.lexer = mLexer; context.token = token; context.result = result; int ret = yyparse(&context); switch (ret) { case 0: case 1: break; case 2: mDiagnostics->report(Diagnostics::PP_OUT_OF_MEMORY, token->location, ""); break; default: assert(false); mDiagnostics->report(Diagnostics::PP_INTERNAL_ERROR, token->location, ""); break; } return ret == 0; } } // namespace pp freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/Input.cpp000066400000000000000000000023701321746453100270660ustar00rootroot00000000000000// // Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "Input.h" #include #include #include namespace pp { Input::Input() : mCount(0), mString(0) { } Input::Input(size_t count, const char *const string[], const int length[]) : mCount(count), mString(string) { mLength.reserve(mCount); for (size_t i = 0; i < mCount; ++i) { int len = length ? length[i] : -1; mLength.push_back(len < 0 ? std::strlen(mString[i]) : len); } } size_t Input::read(char *buf, size_t maxSize) { size_t nRead = 0; while ((nRead < maxSize) && (mReadLoc.sIndex < mCount)) { size_t size = mLength[mReadLoc.sIndex] - mReadLoc.cIndex; size = std::min(size, maxSize); std::memcpy(buf + nRead, mString[mReadLoc.sIndex] + mReadLoc.cIndex, size); nRead += size; mReadLoc.cIndex += size; // Advance string if we reached the end of current string. if (mReadLoc.cIndex == mLength[mReadLoc.sIndex]) { ++mReadLoc.sIndex; mReadLoc.cIndex = 0; } } return nRead; } } // namespace pp freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/Input.h000066400000000000000000000022531321746453100265330ustar00rootroot00000000000000// // Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_PREPROCESSOR_INPUT_H_ #define COMPILER_PREPROCESSOR_INPUT_H_ #include #include namespace pp { // Holds and reads input for Lexer. class Input { public: Input(); Input(size_t count, const char *const string[], const int length[]); size_t count() const { return mCount; } const char *string(size_t index) const { return mString[index]; } size_t length(size_t index) const { return mLength[index]; } size_t read(char *buf, size_t maxSize); struct Location { size_t sIndex; // String index; size_t cIndex; // Char index. Location() : sIndex(0), cIndex(0) { } }; const Location &readLoc() const { return mReadLoc; } private: // Input. size_t mCount; const char * const *mString; std::vector mLength; Location mReadLoc; }; } // namespace pp #endif // COMPILER_PREPROCESSOR_INPUT_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/Lexer.cpp000066400000000000000000000004011321746453100270370ustar00rootroot00000000000000// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "Lexer.h" namespace pp { Lexer::~Lexer() { } } // namespace pp freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/Lexer.h000066400000000000000000000006741321746453100265200ustar00rootroot00000000000000// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_PREPROCESSOR_LEXER_H_ #define COMPILER_PREPROCESSOR_LEXER_H_ namespace pp { struct Token; class Lexer { public: virtual ~Lexer(); virtual void lex(Token *token) = 0; }; } // namespace pp #endif // COMPILER_PREPROCESSOR_LEXER_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/Macro.cpp000066400000000000000000000015661321746453100270360ustar00rootroot00000000000000// // Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "Macro.h" #include #include "Token.h" namespace pp { bool Macro::equals(const Macro &other) const { return (type == other.type) && (name == other.name) && (parameters == other.parameters) && (replacements == other.replacements); } void PredefineMacro(MacroSet *macroSet, const char *name, int value) { std::ostringstream stream; stream << value; Token token; token.type = Token::CONST_INT; token.text = stream.str(); Macro macro; macro.predefined = true; macro.type = Macro::kTypeObj; macro.name = name; macro.replacements.push_back(token); (*macroSet)[name] = macro; } } // namespace pp freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/Macro.h000066400000000000000000000017421321746453100264770ustar00rootroot00000000000000// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_PREPROCESSOR_MACRO_H_ #define COMPILER_PREPROCESSOR_MACRO_H_ #include #include #include namespace pp { struct Token; struct Macro { enum Type { kTypeObj, kTypeFunc }; typedef std::vector Parameters; typedef std::vector Replacements; Macro() : predefined(false), disabled(false), type(kTypeObj) { } bool equals(const Macro &other) const; bool predefined; mutable bool disabled; Type type; std::string name; Parameters parameters; Replacements replacements; }; typedef std::map MacroSet; void PredefineMacro(MacroSet *macroSet, const char *name, int value); } // namespace pp #endif // COMPILER_PREPROCESSOR_MACRO_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/MacroExpander.cpp000066400000000000000000000234301321746453100305170ustar00rootroot00000000000000// // Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "MacroExpander.h" #include #include #include "DiagnosticsBase.h" #include "Token.h" namespace pp { class TokenLexer : public Lexer { public: typedef std::vector TokenVector; TokenLexer(TokenVector *tokens) { tokens->swap(mTokens); mIter = mTokens.begin(); } virtual void lex(Token *token) { if (mIter == mTokens.end()) { token->reset(); token->type = Token::LAST; } else { *token = *mIter++; } } private: PP_DISALLOW_COPY_AND_ASSIGN(TokenLexer); TokenVector mTokens; TokenVector::const_iterator mIter; }; MacroExpander::MacroExpander(Lexer *lexer, MacroSet *macroSet, Diagnostics *diagnostics) : mLexer(lexer), mMacroSet(macroSet), mDiagnostics(diagnostics) { } MacroExpander::~MacroExpander() { for (std::size_t i = 0; i < mContextStack.size(); ++i) { delete mContextStack[i]; } } void MacroExpander::lex(Token *token) { while (true) { getToken(token); if (token->type != Token::IDENTIFIER) break; if (token->expansionDisabled()) break; MacroSet::const_iterator iter = mMacroSet->find(token->text); if (iter == mMacroSet->end()) break; const Macro& macro = iter->second; if (macro.disabled) { // If a particular token is not expanded, it is never expanded. token->setExpansionDisabled(true); break; } if ((macro.type == Macro::kTypeFunc) && !isNextTokenLeftParen()) { // If the token immediately after the macro name is not a '(', // this macro should not be expanded. break; } pushMacro(macro, *token); } } void MacroExpander::getToken(Token *token) { if (mReserveToken.get()) { *token = *mReserveToken; mReserveToken.reset(); return; } // First pop all empty macro contexts. while (!mContextStack.empty() && mContextStack.back()->empty()) { popMacro(); } if (!mContextStack.empty()) { *token = mContextStack.back()->get(); } else { mLexer->lex(token); } } void MacroExpander::ungetToken(const Token &token) { if (!mContextStack.empty()) { MacroContext *context = mContextStack.back(); context->unget(); assert(context->replacements[context->index] == token); } else { assert(!mReserveToken.get()); mReserveToken.reset(new Token(token)); } } bool MacroExpander::isNextTokenLeftParen() { Token token; getToken(&token); bool lparen = token.type == '('; ungetToken(token); return lparen; } bool MacroExpander::pushMacro(const Macro ¯o, const Token &identifier) { assert(!macro.disabled); assert(!identifier.expansionDisabled()); assert(identifier.type == Token::IDENTIFIER); assert(identifier.text == macro.name); std::vector replacements; if (!expandMacro(macro, identifier, &replacements)) return false; // Macro is disabled for expansion until it is popped off the stack. macro.disabled = true; MacroContext *context = new MacroContext; context->macro = ¯o; context->replacements.swap(replacements); mContextStack.push_back(context); return true; } void MacroExpander::popMacro() { assert(!mContextStack.empty()); MacroContext *context = mContextStack.back(); mContextStack.pop_back(); assert(context->empty()); assert(context->macro->disabled); context->macro->disabled = false; delete context; } bool MacroExpander::expandMacro(const Macro ¯o, const Token &identifier, std::vector *replacements) { replacements->clear(); if (macro.type == Macro::kTypeObj) { replacements->assign(macro.replacements.begin(), macro.replacements.end()); if (macro.predefined) { const char kLine[] = "__LINE__"; const char kFile[] = "__FILE__"; assert(replacements->size() == 1); Token& repl = replacements->front(); if (macro.name == kLine) { std::ostringstream stream; stream << identifier.location.line; repl.text = stream.str(); } else if (macro.name == kFile) { std::ostringstream stream; stream << identifier.location.file; repl.text = stream.str(); } } } else { assert(macro.type == Macro::kTypeFunc); std::vector args; args.reserve(macro.parameters.size()); if (!collectMacroArgs(macro, identifier, &args)) return false; replaceMacroParams(macro, args, replacements); } for (std::size_t i = 0; i < replacements->size(); ++i) { Token& repl = replacements->at(i); if (i == 0) { // The first token in the replacement list inherits the padding // properties of the identifier token. repl.setAtStartOfLine(identifier.atStartOfLine()); repl.setHasLeadingSpace(identifier.hasLeadingSpace()); } repl.location = identifier.location; } return true; } bool MacroExpander::collectMacroArgs(const Macro ¯o, const Token &identifier, std::vector *args) { Token token; getToken(&token); assert(token.type == '('); args->push_back(MacroArg()); for (int openParens = 1; openParens != 0; ) { getToken(&token); if (token.type == Token::LAST) { mDiagnostics->report(Diagnostics::PP_MACRO_UNTERMINATED_INVOCATION, identifier.location, identifier.text); // Do not lose EOF token. ungetToken(token); return false; } bool isArg = false; // True if token is part of the current argument. switch (token.type) { case '(': ++openParens; isArg = true; break; case ')': --openParens; isArg = openParens != 0; break; case ',': // The individual arguments are separated by comma tokens, but // the comma tokens between matching inner parentheses do not // separate arguments. if (openParens == 1) args->push_back(MacroArg()); isArg = openParens != 1; break; default: isArg = true; break; } if (isArg) { MacroArg &arg = args->back(); // Initial whitespace is not part of the argument. if (arg.empty()) token.setHasLeadingSpace(false); arg.push_back(token); } } const Macro::Parameters ¶ms = macro.parameters; // If there is only one empty argument, it is equivalent to no argument. if (params.empty() && (args->size() == 1) && args->front().empty()) { args->clear(); } // Validate the number of arguments. if (args->size() != params.size()) { Diagnostics::ID id = args->size() < macro.parameters.size() ? Diagnostics::PP_MACRO_TOO_FEW_ARGS : Diagnostics::PP_MACRO_TOO_MANY_ARGS; mDiagnostics->report(id, identifier.location, identifier.text); return false; } // Pre-expand each argument before substitution. // This step expands each argument individually before they are // inserted into the macro body. for (std::size_t i = 0; i < args->size(); ++i) { MacroArg &arg = args->at(i); TokenLexer lexer(&arg); MacroExpander expander(&lexer, mMacroSet, mDiagnostics); arg.clear(); expander.lex(&token); while (token.type != Token::LAST) { arg.push_back(token); expander.lex(&token); } } return true; } void MacroExpander::replaceMacroParams(const Macro ¯o, const std::vector &args, std::vector *replacements) { for (std::size_t i = 0; i < macro.replacements.size(); ++i) { const Token &repl = macro.replacements[i]; if (repl.type != Token::IDENTIFIER) { replacements->push_back(repl); continue; } // TODO(alokp): Optimize this. // There is no need to search for macro params every time. // The param index can be cached with the replacement token. Macro::Parameters::const_iterator iter = std::find( macro.parameters.begin(), macro.parameters.end(), repl.text); if (iter == macro.parameters.end()) { replacements->push_back(repl); continue; } std::size_t iArg = std::distance(macro.parameters.begin(), iter); const MacroArg &arg = args[iArg]; if (arg.empty()) { continue; } std::size_t iRepl = replacements->size(); replacements->insert(replacements->end(), arg.begin(), arg.end()); // The replacement token inherits padding properties from // macro replacement token. replacements->at(iRepl).setHasLeadingSpace(repl.hasLeadingSpace()); } } } // namespace pp freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/MacroExpander.h000066400000000000000000000041251321746453100301640ustar00rootroot00000000000000// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_PREPROCESSOR_MACROEXPANDER_H_ #define COMPILER_PREPROCESSOR_MACROEXPANDER_H_ #include #include #include #include "Lexer.h" #include "Macro.h" #include "pp_utils.h" namespace pp { class Diagnostics; class MacroExpander : public Lexer { public: MacroExpander(Lexer *lexer, MacroSet *macroSet, Diagnostics *diagnostics); virtual ~MacroExpander(); virtual void lex(Token *token); private: PP_DISALLOW_COPY_AND_ASSIGN(MacroExpander); void getToken(Token *token); void ungetToken(const Token &token); bool isNextTokenLeftParen(); bool pushMacro(const Macro ¯o, const Token &identifier); void popMacro(); bool expandMacro(const Macro ¯o, const Token &identifier, std::vector *replacements); typedef std::vector MacroArg; bool collectMacroArgs(const Macro ¯o, const Token &identifier, std::vector *args); void replaceMacroParams(const Macro ¯o, const std::vector &args, std::vector *replacements); struct MacroContext { const Macro *macro; std::size_t index; std::vector replacements; MacroContext() : macro(0), index(0) { } bool empty() const { return index == replacements.size(); } const Token &get() { return replacements[index++]; } void unget() { assert(index > 0); --index; } }; Lexer *mLexer; MacroSet *mMacroSet; Diagnostics *mDiagnostics; std::unique_ptr mReserveToken; std::vector mContextStack; }; } // namespace pp #endif // COMPILER_PREPROCESSOR_MACROEXPANDER_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/Preprocessor.cpp000066400000000000000000000052161321746453100304570ustar00rootroot00000000000000// // Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "Preprocessor.h" #include #include "DiagnosticsBase.h" #include "DirectiveParser.h" #include "Macro.h" #include "MacroExpander.h" #include "Token.h" #include "Tokenizer.h" namespace pp { struct PreprocessorImpl { Diagnostics *diagnostics; MacroSet macroSet; Tokenizer tokenizer; DirectiveParser directiveParser; MacroExpander macroExpander; PreprocessorImpl(Diagnostics *diag, DirectiveHandler *directiveHandler) : diagnostics(diag), tokenizer(diag), directiveParser(&tokenizer, ¯oSet, diag, directiveHandler), macroExpander(&directiveParser, ¯oSet, diag) { } }; Preprocessor::Preprocessor(Diagnostics *diagnostics, DirectiveHandler *directiveHandler) { mImpl = new PreprocessorImpl(diagnostics, directiveHandler); } Preprocessor::~Preprocessor() { delete mImpl; } bool Preprocessor::init(size_t count, const char * const string[], const int length[]) { static const int kDefaultGLSLVersion = 100; // Add standard pre-defined macros. predefineMacro("__LINE__", 0); predefineMacro("__FILE__", 0); predefineMacro("__VERSION__", kDefaultGLSLVersion); predefineMacro("GL_ES", 1); return mImpl->tokenizer.init(count, string, length); } void Preprocessor::predefineMacro(const char *name, int value) { PredefineMacro(&mImpl->macroSet, name, value); } void Preprocessor::lex(Token *token) { bool validToken = false; while (!validToken) { mImpl->macroExpander.lex(token); switch (token->type) { // We should not be returning internal preprocessing tokens. // Convert preprocessing tokens to compiler tokens or report // diagnostics. case Token::PP_HASH: assert(false); break; case Token::PP_NUMBER: mImpl->diagnostics->report(Diagnostics::PP_INVALID_NUMBER, token->location, token->text); break; case Token::PP_OTHER: mImpl->diagnostics->report(Diagnostics::PP_INVALID_CHARACTER, token->location, token->text); break; default: validToken = true; break; } } } void Preprocessor::setMaxTokenSize(size_t maxTokenSize) { mImpl->tokenizer.setMaxTokenSize(maxTokenSize); } } // namespace pp freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/Preprocessor.h000066400000000000000000000030631321746453100301220ustar00rootroot00000000000000// // Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_PREPROCESSOR_PREPROCESSOR_H_ #define COMPILER_PREPROCESSOR_PREPROCESSOR_H_ #include #include "pp_utils.h" namespace pp { class Diagnostics; class DirectiveHandler; struct PreprocessorImpl; struct Token; class Preprocessor { public: Preprocessor(Diagnostics *diagnostics, DirectiveHandler *directiveHandler); ~Preprocessor(); // count: specifies the number of elements in the string and length arrays. // string: specifies an array of pointers to strings. // length: specifies an array of string lengths. // If length is NULL, each string is assumed to be null terminated. // If length is a value other than NULL, it points to an array containing // a string length for each of the corresponding elements of string. // Each element in the length array may contain the length of the // corresponding string or a value less than 0 to indicate that the string // is null terminated. bool init(size_t count, const char * const string[], const int length[]); // Adds a pre-defined macro. void predefineMacro(const char *name, int value); void lex(Token *token); // Set maximum preprocessor token size void setMaxTokenSize(size_t maxTokenSize); private: PP_DISALLOW_COPY_AND_ASSIGN(Preprocessor); PreprocessorImpl *mImpl; }; } // namespace pp #endif // COMPILER_PREPROCESSOR_PREPROCESSOR_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/SourceLocation.h000066400000000000000000000016301321746453100303630ustar00rootroot00000000000000// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_PREPROCESSOR_SOURCELOCATION_H_ #define COMPILER_PREPROCESSOR_SOURCELOCATION_H_ namespace pp { struct SourceLocation { SourceLocation() : file(0), line(0) { } SourceLocation(int f, int l) : file(f), line(l) { } bool equals(const SourceLocation &other) const { return (file == other.file) && (line == other.line); } int file; int line; }; inline bool operator==(const SourceLocation &lhs, const SourceLocation &rhs) { return lhs.equals(rhs); } inline bool operator!=(const SourceLocation &lhs, const SourceLocation &rhs) { return !lhs.equals(rhs); } } // namespace pp #endif // COMPILER_PREPROCESSOR_SOURCELOCATION_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/Token.cpp000066400000000000000000000030071321746453100270450ustar00rootroot00000000000000// // Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "Token.h" #include #include "numeric_lex.h" namespace pp { void Token::reset() { type = 0; flags = 0; location = SourceLocation(); text.clear(); } bool Token::equals(const Token &other) const { return (type == other.type) && (flags == other.flags) && (location == other.location) && (text == other.text); } void Token::setAtStartOfLine(bool start) { if (start) flags |= AT_START_OF_LINE; else flags &= ~AT_START_OF_LINE; } void Token::setHasLeadingSpace(bool space) { if (space) flags |= HAS_LEADING_SPACE; else flags &= ~HAS_LEADING_SPACE; } void Token::setExpansionDisabled(bool disable) { if (disable) flags |= EXPANSION_DISABLED; else flags &= ~EXPANSION_DISABLED; } bool Token::iValue(int *value) const { assert(type == CONST_INT); return numeric_lex_int(text, value); } bool Token::uValue(unsigned int *value) const { assert(type == CONST_INT); return numeric_lex_int(text, value); } bool Token::fValue(float *value) const { assert(type == CONST_FLOAT); return numeric_lex_float(text, value); } std::ostream &operator<<(std::ostream &out, const Token &token) { if (token.hasLeadingSpace()) out << " "; out << token.text; return out; } } // namespace pp freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/Token.h000066400000000000000000000050061321746453100265130ustar00rootroot00000000000000// // Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_PREPROCESSOR_TOKEN_H_ #define COMPILER_PREPROCESSOR_TOKEN_H_ #include #include #include "SourceLocation.h" namespace pp { struct Token { enum Type { LAST = 0, // EOF. IDENTIFIER = 258, CONST_INT, CONST_FLOAT, OP_INC, OP_DEC, OP_LEFT, OP_RIGHT, OP_LE, OP_GE, OP_EQ, OP_NE, OP_AND, OP_XOR, OP_OR, OP_ADD_ASSIGN, OP_SUB_ASSIGN, OP_MUL_ASSIGN, OP_DIV_ASSIGN, OP_MOD_ASSIGN, OP_LEFT_ASSIGN, OP_RIGHT_ASSIGN, OP_AND_ASSIGN, OP_XOR_ASSIGN, OP_OR_ASSIGN, // Preprocessing token types. // These types are used by the preprocessor internally. // Preprocessor clients must not depend or check for them. PP_HASH, PP_NUMBER, PP_OTHER }; enum Flags { AT_START_OF_LINE = 1 << 0, HAS_LEADING_SPACE = 1 << 1, EXPANSION_DISABLED = 1 << 2 }; Token() : type(0), flags(0) { } void reset(); bool equals(const Token &other) const; // Returns true if this is the first token on line. // It disregards any leading whitespace. bool atStartOfLine() const { return (flags & AT_START_OF_LINE) != 0; } void setAtStartOfLine(bool start); bool hasLeadingSpace() const { return (flags & HAS_LEADING_SPACE) != 0; } void setHasLeadingSpace(bool space); bool expansionDisabled() const { return (flags & EXPANSION_DISABLED) != 0; } void setExpansionDisabled(bool disable); // Converts text into numeric value for CONST_INT and CONST_FLOAT token. // Returns false if the parsed value cannot fit into an int or float. bool iValue(int *value) const; bool uValue(unsigned int *value) const; bool fValue(float *value) const; int type; unsigned int flags; SourceLocation location; std::string text; }; inline bool operator==(const Token &lhs, const Token &rhs) { return lhs.equals(rhs); } inline bool operator!=(const Token &lhs, const Token &rhs) { return !lhs.equals(rhs); } extern std::ostream &operator<<(std::ostream &out, const Token &token); } // namepsace pp #endif // COMPILER_PREPROCESSOR_TOKEN_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/Tokenizer.cpp000066400000000000000000002010701321746453100277370ustar00rootroot00000000000000#line 16 "./Tokenizer.l" // // Copyright (c) 2011-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // This file is auto-generated by generate_parser.sh. DO NOT EDIT! #line 13 "./Tokenizer.cpp" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_SUBMINOR_VERSION 39 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ #include #include #include #include /* end standard C headers. */ /* flex integer type definitions */ #ifndef FLEXINT_H #define FLEXINT_H /* C99 systems have . Non-C99 systems may or may not. */ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 #endif #include typedef int8_t flex_int8_t; typedef uint8_t flex_uint8_t; typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; /* Limits of integral types. */ #ifndef INT8_MIN #define INT8_MIN (-128) #endif #ifndef INT16_MIN #define INT16_MIN (-32767-1) #endif #ifndef INT32_MIN #define INT32_MIN (-2147483647-1) #endif #ifndef INT8_MAX #define INT8_MAX (127) #endif #ifndef INT16_MAX #define INT16_MAX (32767) #endif #ifndef INT32_MAX #define INT32_MAX (2147483647) #endif #ifndef UINT8_MAX #define UINT8_MAX (255U) #endif #ifndef UINT16_MAX #define UINT16_MAX (65535U) #endif #ifndef UINT32_MAX #define UINT32_MAX (4294967295U) #endif #endif /* ! C99 */ #endif /* ! FLEXINT_H */ #ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ /* C99 requires __STDC__ to be defined as 1. */ #if defined (__STDC__) #define YY_USE_CONST #endif /* defined (__STDC__) */ #endif /* ! __cplusplus */ #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif /* Returned upon end-of-file. */ #define YY_NULL 0 /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* An opaque pointer. */ #ifndef YY_TYPEDEF_YY_SCANNER_T #define YY_TYPEDEF_YY_SCANNER_T typedef void* yyscan_t; #endif /* For convenience, these vars (plus the bison vars far below) are macros in the reentrant scanner. */ #define yyin yyg->yyin_r #define yyout yyg->yyout_r #define yyextra yyg->yyextra_r #define yyleng yyg->yyleng_r #define yytext yyg->yytext_r #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) #define yy_flex_debug yyg->yy_flex_debug_r /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN yyg->yy_start = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START ((yyg->yy_start - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ #define YY_NEW_FILE pprestart(yyin ,yyscanner ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #ifndef YY_BUF_SIZE #define YY_BUF_SIZE 16384 #endif /* The state buf must be large enough to hold one state per character in the main buffer. */ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; #endif #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; #endif #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 #define YY_LESS_LINENO(n) #define YY_LINENO_REWIND_TO(ptr) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = yyg->yy_hold_char; \ YY_RESTORE_YY_MORE_OFFSET \ yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { FILE *yy_input_file; char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ yy_size_t yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to * delete it. */ int yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after * each newline. */ int yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might * still have a bunch of tokens to match, though, because of * possible backing-up. * * When we actually see the EOF, we change the status to "new" * (via pprestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". * * Returns the top of the stack, or NULL. */ #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ : NULL) /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] void pprestart (FILE *input_file ,yyscan_t yyscanner ); void pp_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); YY_BUFFER_STATE pp_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); void pp_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); void pp_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); void pppush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); void pppop_buffer_state (yyscan_t yyscanner ); static void ppensure_buffer_stack (yyscan_t yyscanner ); static void pp_load_buffer_state (yyscan_t yyscanner ); static void pp_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); #define YY_FLUSH_BUFFER pp_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) YY_BUFFER_STATE pp_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); YY_BUFFER_STATE pp_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); YY_BUFFER_STATE pp_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner ); void *ppalloc (yy_size_t ,yyscan_t yyscanner ); void *pprealloc (void *,yy_size_t ,yyscan_t yyscanner ); void ppfree (void * ,yyscan_t yyscanner ); #define yy_new_buffer pp_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ ppensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ ppensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ #define ppwrap(yyscanner) 1 #define YY_SKIP_YYWRAP typedef unsigned char YY_CHAR; typedef int yy_state_type; #define yytext_ptr yytext_r static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); static int yy_get_next_buffer (yyscan_t yyscanner ); static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ yyg->yytext_ptr = yy_bp; \ yyleng = (yy_size_t) (yy_cp - yy_bp); \ yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; #define YY_NUM_RULES 38 #define YY_END_OF_BUFFER 39 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info { flex_int32_t yy_verify; flex_int32_t yy_nxt; }; static yyconst flex_int16_t yy_accept[98] = { 0, 0, 0, 0, 0, 39, 37, 34, 35, 35, 33, 7, 33, 33, 33, 33, 33, 33, 33, 33, 9, 9, 33, 33, 33, 8, 37, 33, 33, 3, 5, 5, 4, 34, 35, 19, 27, 20, 30, 25, 12, 23, 13, 24, 10, 2, 1, 26, 10, 9, 11, 11, 11, 9, 11, 9, 9, 14, 16, 18, 17, 15, 8, 36, 36, 31, 21, 32, 22, 3, 5, 6, 11, 10, 11, 10, 1, 10, 11, 10, 0, 10, 9, 9, 9, 28, 29, 0, 10, 10, 10, 10, 9, 10, 10, 9, 10, 0 } ; static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, 9, 10, 11, 9, 12, 13, 14, 15, 16, 16, 16, 16, 16, 16, 16, 17, 17, 9, 9, 18, 19, 20, 9, 1, 21, 21, 21, 21, 22, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 24, 24, 26, 24, 24, 9, 27, 9, 28, 24, 1, 21, 21, 21, 21, 22, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 24, 24, 26, 24, 24, 9, 29, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; static yyconst flex_int32_t yy_meta[30] = { 0, 1, 1, 2, 2, 1, 1, 1, 1, 1, 3, 1, 1, 4, 1, 5, 5, 5, 1, 1, 1, 5, 5, 5, 5, 5, 5, 1, 1, 1 } ; static yyconst flex_int16_t yy_base[103] = { 0, 0, 0, 27, 29, 137, 194, 133, 194, 117, 100, 194, 98, 26, 194, 94, 24, 28, 33, 32, 39, 51, 39, 80, 50, 0, 68, 25, 54, 0, 194, 88, 71, 80, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 71, 194, 0, 194, 85, 55, 64, 99, 111, 53, 105, 0, 50, 55, 194, 194, 194, 40, 0, 194, 38, 194, 194, 194, 194, 0, 194, 194, 117, 0, 130, 0, 0, 0, 137, 0, 88, 113, 0, 131, 0, 194, 194, 143, 139, 152, 150, 0, 13, 153, 194, 0, 194, 194, 176, 31, 181, 186, 188 } ; static yyconst flex_int16_t yy_def[103] = { 0, 97, 1, 98, 98, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 20, 97, 97, 97, 99, 97, 97, 97, 100, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 101, 97, 97, 20, 20, 50, 51, 51, 102, 21, 51, 97, 97, 97, 97, 97, 99, 97, 97, 97, 97, 97, 97, 100, 97, 97, 44, 44, 72, 72, 101, 48, 51, 51, 97, 52, 51, 102, 51, 97, 97, 97, 74, 78, 97, 51, 51, 97, 97, 51, 97, 0, 97, 97, 97, 97, 97 } ; static yyconst flex_int16_t yy_nxt[224] = { 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 21, 22, 23, 24, 25, 25, 25, 25, 25, 25, 26, 27, 28, 30, 31, 30, 31, 37, 40, 62, 32, 95, 32, 42, 63, 45, 41, 65, 38, 46, 43, 44, 44, 44, 47, 48, 66, 49, 49, 50, 57, 58, 86, 51, 52, 51, 51, 53, 54, 55, 55, 55, 60, 61, 63, 64, 67, 85, 84, 56, 51, 82, 50, 50, 51, 33, 68, 72, 71, 73, 73, 73, 51, 51, 70, 72, 74, 75, 72, 72, 72, 51, 59, 77, 77, 77, 90, 90, 90, 51, 78, 79, 51, 51, 51, 51, 39, 51, 51, 51, 36, 51, 35, 34, 51, 80, 80, 97, 97, 81, 81, 81, 51, 51, 51, 72, 72, 72, 33, 91, 97, 97, 72, 72, 87, 87, 97, 51, 88, 88, 88, 87, 87, 97, 97, 89, 89, 89, 51, 92, 51, 93, 93, 93, 97, 75, 97, 97, 90, 90, 90, 93, 93, 93, 97, 97, 94, 97, 79, 96, 29, 29, 29, 29, 29, 69, 97, 97, 69, 69, 76, 97, 76, 76, 76, 83, 83, 5, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97 } ; static yyconst flex_int16_t yy_chk[224] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 4, 4, 13, 16, 99, 3, 92, 4, 17, 64, 19, 16, 27, 13, 19, 17, 18, 18, 18, 19, 20, 27, 20, 20, 20, 22, 22, 61, 20, 20, 20, 20, 20, 20, 21, 21, 21, 24, 24, 26, 26, 28, 57, 56, 21, 21, 53, 50, 50, 49, 33, 28, 44, 32, 44, 44, 44, 50, 50, 31, 44, 44, 44, 44, 44, 44, 48, 23, 48, 48, 48, 80, 80, 80, 48, 48, 48, 48, 48, 48, 51, 15, 51, 51, 51, 12, 54, 10, 9, 51, 52, 52, 81, 81, 52, 52, 52, 54, 54, 54, 72, 72, 72, 7, 81, 5, 0, 72, 72, 74, 74, 0, 83, 74, 74, 74, 78, 78, 88, 88, 78, 78, 78, 83, 83, 83, 87, 87, 87, 0, 88, 89, 89, 90, 90, 90, 93, 93, 93, 0, 0, 90, 0, 89, 93, 98, 98, 98, 98, 98, 100, 0, 0, 100, 100, 101, 0, 101, 101, 101, 102, 102, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97 } ; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ #define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET /* // // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file contains the Lex specification for GLSL ES preprocessor. Based on Microsoft Visual Studio 2010 Preprocessor Grammar: http://msdn.microsoft.com/en-us/library/2scxys89.aspx IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh. */ #if defined(_MSC_VER) #pragma warning(disable: 4005) #endif #include "Tokenizer.h" #include "DiagnosticsBase.h" #include "Token.h" #if defined(__GNUC__) // Triggered by the auto-generated yy_fatal_error function. #pragma GCC diagnostic ignored "-Wmissing-noreturn" #elif defined(_MSC_VER) #pragma warning(disable: 4244) #endif // Workaround for flex using the register keyword, deprecated in C++11. #ifdef __cplusplus #if __cplusplus > 199711L #define register #endif #endif typedef std::string YYSTYPE; typedef pp::SourceLocation YYLTYPE; // Use the unused yycolumn variable to track file (string) number. #define yyfileno yycolumn #define YY_USER_INIT \ do { \ yyfileno = 0; \ yylineno = 1; \ yyextra->leadingSpace = false; \ yyextra->lineStart = true; \ } while(0); #define YY_USER_ACTION \ do \ { \ pp::Input* input = &yyextra->input; \ pp::Input::Location* scanLoc = &yyextra->scanLoc; \ while ((scanLoc->sIndex < input->count()) && \ (scanLoc->cIndex >= input->length(scanLoc->sIndex))) \ { \ scanLoc->cIndex -= input->length(scanLoc->sIndex++); \ ++yyfileno; yylineno = 1; \ } \ yylloc->file = yyfileno; \ yylloc->line = yylineno; \ scanLoc->cIndex += yyleng; \ } while(0); #define YY_INPUT(buf, result, maxSize) \ result = yyextra->input.read(buf, maxSize); #define INITIAL 0 #define COMMENT 1 #define YY_EXTRA_TYPE pp::Tokenizer::Context* /* Holds the entire state of the reentrant scanner. */ struct yyguts_t { /* User-defined. Not touched by flex. */ YY_EXTRA_TYPE yyextra_r; /* The rest are the same as the globals declared in the non-reentrant scanner. */ FILE *yyin_r, *yyout_r; size_t yy_buffer_stack_top; /**< index of top of stack. */ size_t yy_buffer_stack_max; /**< capacity of stack. */ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ char yy_hold_char; yy_size_t yy_n_chars; yy_size_t yyleng_r; char *yy_c_buf_p; int yy_init; int yy_start; int yy_did_buffer_switch_on_eof; int yy_start_stack_ptr; int yy_start_stack_depth; int *yy_start_stack; yy_state_type yy_last_accepting_state; char* yy_last_accepting_cpos; int yylineno_r; int yy_flex_debug_r; char *yytext_r; int yy_more_flag; int yy_more_len; YYSTYPE * yylval_r; YYLTYPE * yylloc_r; }; /* end struct yyguts_t */ static int yy_init_globals (yyscan_t yyscanner ); /* This must go here because YYSTYPE and YYLTYPE are included * from bison output in section 1.*/ # define yylval yyg->yylval_r # define yylloc yyg->yylloc_r int pplex_init (yyscan_t* scanner); int pplex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ int pplex_destroy (yyscan_t yyscanner ); int ppget_debug (yyscan_t yyscanner ); void ppset_debug (int debug_flag ,yyscan_t yyscanner ); YY_EXTRA_TYPE ppget_extra (yyscan_t yyscanner ); void ppset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); FILE *ppget_in (yyscan_t yyscanner ); void ppset_in (FILE * in_str ,yyscan_t yyscanner ); FILE *ppget_out (yyscan_t yyscanner ); void ppset_out (FILE * out_str ,yyscan_t yyscanner ); yy_size_t ppget_leng (yyscan_t yyscanner ); char *ppget_text (yyscan_t yyscanner ); int ppget_lineno (yyscan_t yyscanner ); void ppset_lineno (int line_number ,yyscan_t yyscanner ); int ppget_column (yyscan_t yyscanner ); void ppset_column (int column_no ,yyscan_t yyscanner ); YYSTYPE * ppget_lval (yyscan_t yyscanner ); void ppset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); YYLTYPE *ppget_lloc (yyscan_t yyscanner ); void ppset_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner ); /* Macros after this point can all be overridden by user definitions in * section 1. */ #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus extern "C" int ppwrap (yyscan_t yyscanner ); #else extern int ppwrap (yyscan_t yyscanner ); #endif #endif #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (yyscan_t yyscanner ); #else static int input (yyscan_t yyscanner ); #endif #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #define YY_READ_BUF_SIZE 8192 #endif /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else \ { \ errno=0; \ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ break; \ } \ errno=0; \ clearerr(yyin); \ } \ }\ \ #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */ #ifndef yyterminate #define yyterminate() return YY_NULL #endif /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif /* Report a fatal error. */ #ifndef YY_FATAL_ERROR #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) #endif /* end tables serialization structures and prototypes */ /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 extern int pplex \ (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner); #define YY_DECL int pplex \ (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner) #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif /* Code executed at the end of each rule. */ #ifndef YY_BREAK #define YY_BREAK break; #endif #define YY_RULE_SETUP \ YY_USER_ACTION /** The main scanner function which does all the work. */ YY_DECL { register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylval = yylval_param; yylloc = yylloc_param; if ( !yyg->yy_init ) { yyg->yy_init = 1; #ifdef YY_USER_INIT YY_USER_INIT; #endif if ( ! yyg->yy_start ) yyg->yy_start = 1; /* first start state */ if ( ! yyin ) yyin = stdin; if ( ! yyout ) yyout = stdout; if ( ! YY_CURRENT_BUFFER ) { ppensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); } pp_load_buffer_state(yyscanner ); } { /* Line comment */ while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = yyg->yy_c_buf_p; /* Support of yytext. */ *yy_cp = yyg->yy_hold_char; /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; yy_current_state = yyg->yy_start; yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 98 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } while ( yy_current_state != 97 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; yy_find_action: yy_act = yy_accept[yy_current_state]; YY_DO_BEFORE_ACTION; do_action: /* This label is used only to access EOF actions. */ switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = yyg->yy_hold_char; yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; goto yy_find_action; case 1: YY_RULE_SETUP YY_BREAK /* Block comment */ /* Line breaks are just counted - not returned. */ /* The comment is replaced by a single space. */ case 2: YY_RULE_SETUP { BEGIN(COMMENT); } YY_BREAK case 3: YY_RULE_SETUP YY_BREAK case 4: YY_RULE_SETUP YY_BREAK case 5: /* rule 5 can match eol */ YY_RULE_SETUP { ++yylineno; } YY_BREAK case 6: YY_RULE_SETUP { yyextra->leadingSpace = true; BEGIN(INITIAL); } YY_BREAK case 7: YY_RULE_SETUP { // # is only valid at start of line for preprocessor directives. yylval->assign(1, yytext[0]); return yyextra->lineStart ? pp::Token::PP_HASH : pp::Token::PP_OTHER; } YY_BREAK case 8: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::IDENTIFIER; } YY_BREAK case 9: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::CONST_INT; } YY_BREAK case 10: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::CONST_FLOAT; } YY_BREAK /* Anything that starts with a {DIGIT} or .{DIGIT} must be a number. */ /* Rule to catch all invalid integers and floats. */ case 11: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::PP_NUMBER; } YY_BREAK case 12: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_INC; } YY_BREAK case 13: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_DEC; } YY_BREAK case 14: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_LEFT; } YY_BREAK case 15: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_RIGHT; } YY_BREAK case 16: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_LE; } YY_BREAK case 17: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_GE; } YY_BREAK case 18: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_EQ; } YY_BREAK case 19: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_NE; } YY_BREAK case 20: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_AND; } YY_BREAK case 21: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_XOR; } YY_BREAK case 22: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_OR; } YY_BREAK case 23: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_ADD_ASSIGN; } YY_BREAK case 24: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_SUB_ASSIGN; } YY_BREAK case 25: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_MUL_ASSIGN; } YY_BREAK case 26: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_DIV_ASSIGN; } YY_BREAK case 27: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_MOD_ASSIGN; } YY_BREAK case 28: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_LEFT_ASSIGN; } YY_BREAK case 29: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_RIGHT_ASSIGN; } YY_BREAK case 30: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_AND_ASSIGN; } YY_BREAK case 31: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_XOR_ASSIGN; } YY_BREAK case 32: YY_RULE_SETUP { yylval->assign(yytext, yyleng); return pp::Token::OP_OR_ASSIGN; } YY_BREAK case 33: YY_RULE_SETUP { yylval->assign(1, yytext[0]); return yytext[0]; } YY_BREAK case 34: YY_RULE_SETUP { yyextra->leadingSpace = true; } YY_BREAK case 35: /* rule 35 can match eol */ YY_RULE_SETUP { ++yylineno; yylval->assign(1, '\n'); return '\n'; } YY_BREAK case 36: /* rule 36 can match eol */ YY_RULE_SETUP { ++yylineno; } YY_BREAK case 37: YY_RULE_SETUP { yylval->assign(1, yytext[0]); return pp::Token::PP_OTHER; } YY_BREAK case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(COMMENT): { // YY_USER_ACTION is not invoked for handling EOF. // Set the location for EOF token manually. pp::Input* input = &yyextra->input; pp::Input::Location* scanLoc = &yyextra->scanLoc; yy_size_t sIndexMax = input->count() ? input->count() - 1 : 0; if (scanLoc->sIndex != sIndexMax) { // We can only reach here if there are empty strings at the // end of the input. scanLoc->sIndex = sIndexMax; scanLoc->cIndex = 0; // FIXME: this is not 64-bit clean. yyfileno = static_cast(sIndexMax); yylineno = 1; } yylloc->file = yyfileno; yylloc->line = yylineno; yylval->clear(); if (YY_START == COMMENT) { yyextra->diagnostics->report(pp::Diagnostics::PP_EOF_IN_COMMENT, pp::SourceLocation(yyfileno, yylineno), ""); } yyterminate(); } YY_BREAK case 38: YY_RULE_SETUP ECHO; YY_BREAK case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ *yy_cp = yyg->yy_hold_char; YY_RESTORE_YY_MORE_OFFSET if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called * pplex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position * of the first EOB in the buffer, since yy_c_buf_p will * already have been incremented past the NUL character * (since all states make transitions on EOB to the * end-of-buffer state). Contrast this with the test * in input(). */ if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) { /* This was really a NUL. */ yy_state_type yy_next_state; yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( yyscanner ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have * yy_get_previous_state() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we don't * want to build jamming into it because then it * will run more slowly). */ yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ yy_cp = ++yyg->yy_c_buf_p; yy_current_state = yy_next_state; goto yy_match; } else { yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; goto yy_find_action; } } else switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_END_OF_FILE: { yyg->yy_did_buffer_switch_on_eof = 0; if ( ppwrap(yyscanner ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; } else { if ( ! yyg->yy_did_buffer_switch_on_eof ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( yyscanner ); yy_cp = yyg->yy_c_buf_p; yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: yyg->yy_c_buf_p = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; yy_current_state = yy_get_previous_state( yyscanner ); yy_cp = yyg->yy_c_buf_p; yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; goto yy_find_action; } break; } default: YY_FATAL_ERROR( "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ } /* end of user's declarations */ } /* end of pplex */ /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ static int yy_get_next_buffer (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; register char *source = yyg->yytext_ptr; register int number_to_move, i; int ret_val; if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; } else { /* We matched some text prior to the EOB, first * process it. */ return EOB_ACT_LAST_MATCH; } } /* Try to read more data. */ /* First move last chars to start of buffer. */ number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; else { yy_size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; int yy_c_buf_p_offset = (int) (yyg->yy_c_buf_p - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { yy_size_t new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; else b->yy_buf_size *= 2; b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ pprealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); } else /* Can't grow it, we don't own it. */ b->yy_ch_buf = 0; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), yyg->yy_n_chars, num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } if ( yyg->yy_n_chars == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; pprestart(yyin ,yyscanner); } else { ret_val = EOB_ACT_LAST_MATCH; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) pprealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); } yyg->yy_n_chars += number_to_move; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { register yy_state_type yy_current_state; register char *yy_cp; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_current_state = yyg->yy_start; for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 98 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; } return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) { register int yy_is_jam; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ register char *yy_cp = yyg->yy_c_buf_p; register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 98 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 97); (void)yyg; return yy_is_jam ? 0 : yy_current_state; } #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (yyscan_t yyscanner) #else static int input (yyscan_t yyscanner) #endif { int c; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; *yyg->yy_c_buf_p = yyg->yy_hold_char; if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) /* This was really a NUL. */ *yyg->yy_c_buf_p = '\0'; else { /* need more input */ yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; ++yyg->yy_c_buf_p; switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a * token and flags that we need to * try matching the token before * proceeding. But for input(), * there's no matching to consider. * So convert the EOB_ACT_LAST_MATCH * to EOB_ACT_END_OF_FILE. */ /* Reset buffer status. */ pprestart(yyin ,yyscanner); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { if ( ppwrap(yyscanner ) ) return EOF; if ( ! yyg->yy_did_buffer_switch_on_eof ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(yyscanner); #else return input(yyscanner); #endif } case EOB_ACT_CONTINUE_SCAN: yyg->yy_c_buf_p = yyg->yytext_ptr + offset; break; } } } c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ yyg->yy_hold_char = *++yyg->yy_c_buf_p; return c; } #endif /* ifndef YY_NO_INPUT */ /** Immediately switch to a different input stream. * @param input_file A readable stream. * @param yyscanner The scanner object. * @note This function does not reset the start condition to @c INITIAL . */ void pprestart (FILE * input_file , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! YY_CURRENT_BUFFER ){ ppensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); } pp_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); pp_load_buffer_state(yyscanner ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * @param yyscanner The scanner object. */ void pp_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* TODO. We should be able to replace this entire function body * with * pppop_buffer_state(); * pppush_buffer_state(new_buffer); */ ppensure_buffer_stack (yyscanner); if ( YY_CURRENT_BUFFER == new_buffer ) return; if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *yyg->yy_c_buf_p = yyg->yy_hold_char; YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } YY_CURRENT_BUFFER_LVALUE = new_buffer; pp_load_buffer_state(yyscanner ); /* We don't actually know whether we did this switch during * EOF (ppwrap()) processing, but the only time this flag * is looked at is after ppwrap() is called, so it's safe * to go ahead and always set it. */ yyg->yy_did_buffer_switch_on_eof = 1; } static void pp_load_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; yyg->yy_hold_char = *yyg->yy_c_buf_p; } /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. * @param yyscanner The scanner object. * @return the allocated buffer state. */ YY_BUFFER_STATE pp_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) ppalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in pp_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) ppalloc(b->yy_buf_size + 2 ,yyscanner ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in pp_create_buffer()" ); b->yy_is_our_buffer = 1; pp_init_buffer(b,file ,yyscanner); return b; } /** Destroy the buffer. * @param b a buffer created with pp_create_buffer() * @param yyscanner The scanner object. */ void pp_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! b ) return; if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) ppfree((void *) b->yy_ch_buf ,yyscanner ); ppfree((void *) b ,yyscanner ); } /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a pprestart() or at EOF. */ static void pp_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) { int oerrno = errno; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; pp_flush_buffer(b ,yyscanner); b->yy_input_file = file; b->yy_fill_buffer = 1; /* If b is the current buffer, then pp_init_buffer was _probably_ * called from pprestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ b->yy_bs_lineno = 1; b->yy_bs_column = 0; } b->yy_is_interactive = 0; errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * @param yyscanner The scanner object. */ void pp_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! b ) return; b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes * a jam in that state. */ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; b->yy_buf_pos = &b->yy_ch_buf[0]; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) pp_load_buffer_state(yyscanner ); } /** Pushes the new state onto the stack. The new state becomes * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. * @param yyscanner The scanner object. */ void pppush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (new_buffer == NULL) return; ppensure_buffer_stack(yyscanner); /* This block is copied from pp_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *yyg->yy_c_buf_p = yyg->yy_hold_char; YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } /* Only push if top exists. Otherwise, replace top. */ if (YY_CURRENT_BUFFER) yyg->yy_buffer_stack_top++; YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from pp_switch_to_buffer. */ pp_load_buffer_state(yyscanner ); yyg->yy_did_buffer_switch_on_eof = 1; } /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. * @param yyscanner The scanner object. */ void pppop_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!YY_CURRENT_BUFFER) return; pp_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); YY_CURRENT_BUFFER_LVALUE = NULL; if (yyg->yy_buffer_stack_top > 0) --yyg->yy_buffer_stack_top; if (YY_CURRENT_BUFFER) { pp_load_buffer_state(yyscanner ); yyg->yy_did_buffer_switch_on_eof = 1; } } /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ static void ppensure_buffer_stack (yyscan_t yyscanner) { yy_size_t num_to_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!yyg->yy_buffer_stack) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ num_to_alloc = 1; yyg->yy_buffer_stack = (struct yy_buffer_state**)ppalloc (num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); if ( ! yyg->yy_buffer_stack ) YY_FATAL_ERROR( "out of dynamic memory in ppensure_buffer_stack()" ); memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); yyg->yy_buffer_stack_max = num_to_alloc; yyg->yy_buffer_stack_top = 0; return; } if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; num_to_alloc = yyg->yy_buffer_stack_max + grow_size; yyg->yy_buffer_stack = (struct yy_buffer_state**)pprealloc (yyg->yy_buffer_stack, num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); if ( ! yyg->yy_buffer_stack ) YY_FATAL_ERROR( "out of dynamic memory in ppensure_buffer_stack()" ); /* zero only the new slots.*/ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); yyg->yy_buffer_stack_max = num_to_alloc; } } /** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ YY_BUFFER_STATE pp_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ return 0; b = (YY_BUFFER_STATE) ppalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in pp_scan_buffer()" ); b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = 0; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; pp_switch_to_buffer(b ,yyscanner ); return b; } /** Setup the input buffer state to scan a string. The next call to pplex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * @param yyscanner The scanner object. * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use * pp_scan_bytes() instead. */ YY_BUFFER_STATE pp_scan_string (yyconst char * yystr , yyscan_t yyscanner) { return pp_scan_bytes(yystr,strlen(yystr) ,yyscanner); } /** Setup the input buffer state to scan the given bytes. The next call to pplex() will * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ YY_BUFFER_STATE pp_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) { YY_BUFFER_STATE b; char *buf; yy_size_t n; yy_size_t i; /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; buf = (char *) ppalloc(n ,yyscanner ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in pp_scan_bytes()" ); for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; b = pp_scan_buffer(buf,n ,yyscanner); if ( ! b ) YY_FATAL_ERROR( "bad buffer in pp_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. */ b->yy_is_our_buffer = 1; return b; } #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = yyg->yy_hold_char; \ yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ yyg->yy_hold_char = *yyg->yy_c_buf_p; \ *yyg->yy_c_buf_p = '\0'; \ yyleng = yyless_macro_arg; \ } \ while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ /** Get the user-defined data for this scanner. * @param yyscanner The scanner object. */ YY_EXTRA_TYPE ppget_extra (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyextra; } /** Get the current line number. * @param yyscanner The scanner object. */ int ppget_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (! YY_CURRENT_BUFFER) return 0; return yylineno; } /** Get the current column number. * @param yyscanner The scanner object. */ int ppget_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (! YY_CURRENT_BUFFER) return 0; return yycolumn; } /** Get the input stream. * @param yyscanner The scanner object. */ FILE *ppget_in (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyin; } /** Get the output stream. * @param yyscanner The scanner object. */ FILE *ppget_out (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyout; } /** Get the length of the current token. * @param yyscanner The scanner object. */ yy_size_t ppget_leng (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyleng; } /** Get the current token. * @param yyscanner The scanner object. */ char *ppget_text (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yytext; } /** Set the user-defined data. This data is never touched by the scanner. * @param user_defined The data to be associated with this scanner. * @param yyscanner The scanner object. */ void ppset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyextra = user_defined ; } /** Set the current line number. * @param line_number * @param yyscanner The scanner object. */ void ppset_lineno (int line_number , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) YY_FATAL_ERROR( "ppset_lineno called with no buffer" ); yylineno = line_number; } /** Set the current column. * @param line_number * @param yyscanner The scanner object. */ void ppset_column (int column_no , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) YY_FATAL_ERROR( "ppset_column called with no buffer" ); yycolumn = column_no; } /** Set the input stream. This does not discard the current * input buffer. * @param in_str A readable stream. * @param yyscanner The scanner object. * @see pp_switch_to_buffer */ void ppset_in (FILE * in_str , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyin = in_str ; } void ppset_out (FILE * out_str , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyout = out_str ; } int ppget_debug (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yy_flex_debug; } void ppset_debug (int bdebug , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_flex_debug = bdebug ; } /* Accessor methods for yylval and yylloc */ YYSTYPE * ppget_lval (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yylval; } void ppset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylval = yylval_param; } YYLTYPE *ppget_lloc (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yylloc; } void ppset_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylloc = yylloc_param; } /* User-visible API */ /* pplex_init is special because it creates the scanner itself, so it is * the ONLY reentrant function that doesn't take the scanner as the last argument. * That's why we explicitly handle the declaration, instead of using our macros. */ int pplex_init(yyscan_t* ptr_yy_globals) { if (ptr_yy_globals == NULL){ errno = EINVAL; return 1; } *ptr_yy_globals = (yyscan_t) ppalloc ( sizeof( struct yyguts_t ), NULL ); if (*ptr_yy_globals == NULL){ errno = ENOMEM; return 1; } /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); return yy_init_globals ( *ptr_yy_globals ); } /* pplex_init_extra has the same functionality as pplex_init, but follows the * convention of taking the scanner as the last argument. Note however, that * this is a *pointer* to a scanner, as it will be allocated by this call (and * is the reason, too, why this function also must handle its own declaration). * The user defined value in the first argument will be available to ppalloc in * the yyextra field. */ int pplex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) { struct yyguts_t dummy_yyguts; ppset_extra (yy_user_defined, &dummy_yyguts); if (ptr_yy_globals == NULL){ errno = EINVAL; return 1; } *ptr_yy_globals = (yyscan_t) ppalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); if (*ptr_yy_globals == NULL){ errno = ENOMEM; return 1; } /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); ppset_extra (yy_user_defined, *ptr_yy_globals); return yy_init_globals ( *ptr_yy_globals ); } static int yy_init_globals (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Initialization is the same as for the non-reentrant scanner. * This function is called from pplex_destroy(), so don't allocate here. */ yyg->yy_buffer_stack = 0; yyg->yy_buffer_stack_top = 0; yyg->yy_buffer_stack_max = 0; yyg->yy_c_buf_p = (char *) 0; yyg->yy_init = 0; yyg->yy_start = 0; yyg->yy_start_stack_ptr = 0; yyg->yy_start_stack_depth = 0; yyg->yy_start_stack = NULL; /* Defined in main.c */ #ifdef YY_STDINIT yyin = stdin; yyout = stdout; #else yyin = (FILE *) 0; yyout = (FILE *) 0; #endif /* For future reference: Set errno on error, since we are called by * pplex_init() */ return 0; } /* pplex_destroy is for both reentrant and non-reentrant scanners. */ int pplex_destroy (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ pp_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); YY_CURRENT_BUFFER_LVALUE = NULL; pppop_buffer_state(yyscanner); } /* Destroy the stack itself. */ ppfree(yyg->yy_buffer_stack ,yyscanner); yyg->yy_buffer_stack = NULL; /* Destroy the start condition stack. */ ppfree(yyg->yy_start_stack ,yyscanner ); yyg->yy_start_stack = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time * pplex() is called, initialization will occur. */ yy_init_globals( yyscanner); /* Destroy the main struct (reentrant only). */ ppfree ( yyscanner , yyscanner ); yyscanner = NULL; return 0; } /* * Internal utility routines. */ #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) { register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) { register int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif void *ppalloc (yy_size_t size , yyscan_t yyscanner) { return (void *) malloc( size ); } void *pprealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter * because both ANSI C and C++ allow castless assignment from * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); } void ppfree (void * ptr , yyscan_t yyscanner) { free( (char *) ptr ); /* see pprealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" namespace pp { Tokenizer::Tokenizer(Diagnostics *diagnostics) : mHandle(0), mMaxTokenSize(256) { mContext.diagnostics = diagnostics; } Tokenizer::~Tokenizer() { destroyScanner(); } bool Tokenizer::init(size_t count, const char * const string[], const int length[]) { if ((count > 0) && (string == 0)) return false; mContext.input = Input(count, string, length); return initScanner(); } void Tokenizer::setFileNumber(int file) { // We use column number as file number. // See macro yyfileno. ppset_column(file,mHandle); } void Tokenizer::setLineNumber(int line) { ppset_lineno(line,mHandle); } void Tokenizer::setMaxTokenSize(size_t maxTokenSize) { mMaxTokenSize = maxTokenSize; } void Tokenizer::lex(Token *token) { token->type = pplex(&token->text,&token->location,mHandle); if (token->text.size() > mMaxTokenSize) { mContext.diagnostics->report(Diagnostics::PP_TOKEN_TOO_LONG, token->location, token->text); token->text.erase(mMaxTokenSize); } token->flags = 0; token->setAtStartOfLine(mContext.lineStart); mContext.lineStart = token->type == '\n'; token->setHasLeadingSpace(mContext.leadingSpace); mContext.leadingSpace = false; } bool Tokenizer::initScanner() { if ((mHandle == NULL) && pplex_init_extra(&mContext,&mHandle)) return false; pprestart(0,mHandle); return true; } void Tokenizer::destroyScanner() { if (mHandle == NULL) return; pplex_destroy(mHandle); mHandle = NULL; } } // namespace pp freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/Tokenizer.h000066400000000000000000000025721321746453100274120ustar00rootroot00000000000000// // Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_PREPROCESSOR_TOKENIZER_H_ #define COMPILER_PREPROCESSOR_TOKENIZER_H_ #include "Input.h" #include "Lexer.h" #include "pp_utils.h" namespace pp { class Diagnostics; class Tokenizer : public Lexer { public: struct Context { Diagnostics *diagnostics; Input input; // The location where yytext points to. Token location should track // scanLoc instead of Input::mReadLoc because they may not be the same // if text is buffered up in the scanner input buffer. Input::Location scanLoc; bool leadingSpace; bool lineStart; }; Tokenizer(Diagnostics *diagnostics); ~Tokenizer(); bool init(size_t count, const char * const string[], const int length[]); void setFileNumber(int file); void setLineNumber(int line); void setMaxTokenSize(size_t maxTokenSize); virtual void lex(Token *token); private: PP_DISALLOW_COPY_AND_ASSIGN(Tokenizer); bool initScanner(); void destroyScanner(); void *mHandle; // Scanner handle. Context mContext; // Scanner extra. size_t mMaxTokenSize; // Maximum token size }; } // namespace pp #endif // COMPILER_PREPROCESSOR_TOKENIZER_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/Tokenizer.l000066400000000000000000000212531321746453100274130ustar00rootroot00000000000000/* // // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file contains the Lex specification for GLSL ES preprocessor. Based on Microsoft Visual Studio 2010 Preprocessor Grammar: http://msdn.microsoft.com/en-us/library/2scxys89.aspx IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh. */ %top{ // // Copyright (c) 2011-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // This file is auto-generated by generate_parser.sh. DO NOT EDIT! } %{ #if defined(_MSC_VER) #pragma warning(disable: 4005) #endif #include "Tokenizer.h" #include "DiagnosticsBase.h" #include "Token.h" #if defined(__GNUC__) // Triggered by the auto-generated yy_fatal_error function. #pragma GCC diagnostic ignored "-Wmissing-noreturn" #elif defined(_MSC_VER) #pragma warning(disable: 4244) #endif // Workaround for flex using the register keyword, deprecated in C++11. #ifdef __cplusplus #if __cplusplus > 199711L #define register #endif #endif typedef std::string YYSTYPE; typedef pp::SourceLocation YYLTYPE; // Use the unused yycolumn variable to track file (string) number. #define yyfileno yycolumn #define YY_USER_INIT \ do { \ yyfileno = 0; \ yylineno = 1; \ yyextra->leadingSpace = false; \ yyextra->lineStart = true; \ } while(0); #define YY_USER_ACTION \ do \ { \ pp::Input* input = &yyextra->input; \ pp::Input::Location* scanLoc = &yyextra->scanLoc; \ while ((scanLoc->sIndex < input->count()) && \ (scanLoc->cIndex >= input->length(scanLoc->sIndex))) \ { \ scanLoc->cIndex -= input->length(scanLoc->sIndex++); \ ++yyfileno; yylineno = 1; \ } \ yylloc->file = yyfileno; \ yylloc->line = yylineno; \ scanLoc->cIndex += yyleng; \ } while(0); #define YY_INPUT(buf, result, maxSize) \ result = yyextra->input.read(buf, maxSize); %} %option noyywrap nounput never-interactive %option reentrant bison-bridge bison-locations %option prefix="pp" %option extra-type="pp::Tokenizer::Context*" %x COMMENT NEWLINE \n|\r|\r\n IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]* PUNCTUATOR [][<>(){}.+-/*%^|&~=!:;,?] DECIMAL_CONSTANT [1-9][0-9]*[uU]? OCTAL_CONSTANT 0[0-7]*[uU]? HEXADECIMAL_CONSTANT 0[xX][0-9a-fA-F]+[uU]? DIGIT [0-9] EXPONENT_PART [eE][+-]?{DIGIT}+ FRACTIONAL_CONSTANT ({DIGIT}*"."{DIGIT}+)|({DIGIT}+".") %% /* Line comment */ "//"[^\r\n]* /* Block comment */ /* Line breaks are just counted - not returned. */ /* The comment is replaced by a single space. */ "/*" { BEGIN(COMMENT); } [^*\r\n]+ "*" {NEWLINE} { ++yylineno; } "*/" { yyextra->leadingSpace = true; BEGIN(INITIAL); } # { // # is only valid at start of line for preprocessor directives. yylval->assign(1, yytext[0]); return yyextra->lineStart ? pp::Token::PP_HASH : pp::Token::PP_OTHER; } {IDENTIFIER} { yylval->assign(yytext, yyleng); return pp::Token::IDENTIFIER; } ({DECIMAL_CONSTANT}[uU]?)|({OCTAL_CONSTANT}[uU]?)|({HEXADECIMAL_CONSTANT}[uU]?) { yylval->assign(yytext, yyleng); return pp::Token::CONST_INT; } ({DIGIT}+{EXPONENT_PART}[fF]?)|({FRACTIONAL_CONSTANT}{EXPONENT_PART}?[fF]?) { yylval->assign(yytext, yyleng); return pp::Token::CONST_FLOAT; } /* Anything that starts with a {DIGIT} or .{DIGIT} must be a number. */ /* Rule to catch all invalid integers and floats. */ ({DIGIT}+[_a-zA-Z0-9.]*)|("."{DIGIT}+[_a-zA-Z0-9.]*) { yylval->assign(yytext, yyleng); return pp::Token::PP_NUMBER; } "++" { yylval->assign(yytext, yyleng); return pp::Token::OP_INC; } "--" { yylval->assign(yytext, yyleng); return pp::Token::OP_DEC; } "<<" { yylval->assign(yytext, yyleng); return pp::Token::OP_LEFT; } ">>" { yylval->assign(yytext, yyleng); return pp::Token::OP_RIGHT; } "<=" { yylval->assign(yytext, yyleng); return pp::Token::OP_LE; } ">=" { yylval->assign(yytext, yyleng); return pp::Token::OP_GE; } "==" { yylval->assign(yytext, yyleng); return pp::Token::OP_EQ; } "!=" { yylval->assign(yytext, yyleng); return pp::Token::OP_NE; } "&&" { yylval->assign(yytext, yyleng); return pp::Token::OP_AND; } "^^" { yylval->assign(yytext, yyleng); return pp::Token::OP_XOR; } "||" { yylval->assign(yytext, yyleng); return pp::Token::OP_OR; } "+=" { yylval->assign(yytext, yyleng); return pp::Token::OP_ADD_ASSIGN; } "-=" { yylval->assign(yytext, yyleng); return pp::Token::OP_SUB_ASSIGN; } "*=" { yylval->assign(yytext, yyleng); return pp::Token::OP_MUL_ASSIGN; } "/=" { yylval->assign(yytext, yyleng); return pp::Token::OP_DIV_ASSIGN; } "%=" { yylval->assign(yytext, yyleng); return pp::Token::OP_MOD_ASSIGN; } "<<=" { yylval->assign(yytext, yyleng); return pp::Token::OP_LEFT_ASSIGN; } ">>=" { yylval->assign(yytext, yyleng); return pp::Token::OP_RIGHT_ASSIGN; } "&=" { yylval->assign(yytext, yyleng); return pp::Token::OP_AND_ASSIGN; } "^=" { yylval->assign(yytext, yyleng); return pp::Token::OP_XOR_ASSIGN; } "|=" { yylval->assign(yytext, yyleng); return pp::Token::OP_OR_ASSIGN; } {PUNCTUATOR} { yylval->assign(1, yytext[0]); return yytext[0]; } [ \t\v\f]+ { yyextra->leadingSpace = true; } {NEWLINE} { ++yylineno; yylval->assign(1, '\n'); return '\n'; } \\{NEWLINE} { ++yylineno; } . { yylval->assign(1, yytext[0]); return pp::Token::PP_OTHER; } <*><> { // YY_USER_ACTION is not invoked for handling EOF. // Set the location for EOF token manually. pp::Input* input = &yyextra->input; pp::Input::Location* scanLoc = &yyextra->scanLoc; yy_size_t sIndexMax = input->count() ? input->count() - 1 : 0; if (scanLoc->sIndex != sIndexMax) { // We can only reach here if there are empty strings at the // end of the input. scanLoc->sIndex = sIndexMax; scanLoc->cIndex = 0; // FIXME: this is not 64-bit clean. yyfileno = static_cast(sIndexMax); yylineno = 1; } yylloc->file = yyfileno; yylloc->line = yylineno; yylval->clear(); if (YY_START == COMMENT) { yyextra->diagnostics->report(pp::Diagnostics::PP_EOF_IN_COMMENT, pp::SourceLocation(yyfileno, yylineno), ""); } yyterminate(); } %% namespace pp { Tokenizer::Tokenizer(Diagnostics *diagnostics) : mHandle(0), mMaxTokenSize(256) { mContext.diagnostics = diagnostics; } Tokenizer::~Tokenizer() { destroyScanner(); } bool Tokenizer::init(size_t count, const char * const string[], const int length[]) { if ((count > 0) && (string == 0)) return false; mContext.input = Input(count, string, length); return initScanner(); } void Tokenizer::setFileNumber(int file) { // We use column number as file number. // See macro yyfileno. yyset_column(file, mHandle); } void Tokenizer::setLineNumber(int line) { yyset_lineno(line, mHandle); } void Tokenizer::setMaxTokenSize(size_t maxTokenSize) { mMaxTokenSize = maxTokenSize; } void Tokenizer::lex(Token *token) { token->type = yylex(&token->text, &token->location, mHandle); if (token->text.size() > mMaxTokenSize) { mContext.diagnostics->report(Diagnostics::PP_TOKEN_TOO_LONG, token->location, token->text); token->text.erase(mMaxTokenSize); } token->flags = 0; token->setAtStartOfLine(mContext.lineStart); mContext.lineStart = token->type == '\n'; token->setHasLeadingSpace(mContext.leadingSpace); mContext.leadingSpace = false; } bool Tokenizer::initScanner() { if ((mHandle == NULL) && yylex_init_extra(&mContext, &mHandle)) return false; yyrestart(0, mHandle); return true; } void Tokenizer::destroyScanner() { if (mHandle == NULL) return; yylex_destroy(mHandle); mHandle = NULL; } } // namespace pp freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/generate_parser.sh000077500000000000000000000013041321746453100307640ustar00rootroot00000000000000#!/bin/bash # Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # Generates various components of GLSL ES preprocessor. run_flex() { input_file=$script_dir/$1 output_source=$script_dir/$2 flex --noline --nounistd --outfile=$output_source $input_file } run_bison() { input_file=$script_dir/$1 output_source=$script_dir/$2 bison --no-lines --skeleton=yacc.c --output=$output_source $input_file } script_dir=$(dirname $0) # Generate preprocessor run_flex Tokenizer.l Tokenizer.cpp run_bison ExpressionParser.y ExpressionParser.cpp patch --silent --forward < 64bit-tokenizer-safety.patch freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/numeric_lex.h000066400000000000000000000042131321746453100277440ustar00rootroot00000000000000// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // numeric_lex.h: Functions to extract numeric values from string. #ifndef COMPILER_PREPROCESSOR_NUMERICLEX_H_ #define COMPILER_PREPROCESSOR_NUMERICLEX_H_ #include namespace pp { inline std::ios::fmtflags numeric_base_int(const std::string &str) { if ((str.size() >= 2) && (str[0] == '0') && (str[1] == 'x' || str[1] == 'X')) { return std::ios::hex; } if ((str.size() >= 1) && (str[0] == '0')) { return std::ios::oct; } return std::ios::dec; } // The following functions parse the given string to extract a numerical // value of the given type. These functions assume that the string is // of the correct form. They can only fail if the parsed value is too big, // in which case false is returned. template bool numeric_lex_int(const std::string &str, IntType *value) { std::istringstream stream(str); // This should not be necessary, but MSVS has a buggy implementation. // It returns incorrect results if the base is not specified. stream.setf(numeric_base_int(str), std::ios::basefield); stream >> (*value); return !stream.fail(); } template bool numeric_lex_float(const std::string &str, FloatType *value) { // On 64-bit Intel Android, istringstream is broken. Until this is fixed in // a newer NDK, don't use it. Android doesn't have locale support, so this // doesn't have to force the C locale. // TODO(thakis): Remove this once this bug has been fixed in the NDK and // that NDK has been rolled into chromium. #if defined(ANGLE_PLATFORM_ANDROID) && __x86_64__ *value = strtod(str.c_str(), nullptr); return errno != ERANGE; #else std::istringstream stream(str); // Force "C" locale so that decimal character is always '.', and // not dependent on the current locale. stream.imbue(std::locale::classic()); stream >> (*value); return !stream.fail(); #endif } } // namespace pp. #endif // COMPILER_PREPROCESSOR_NUMERICLEX_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/preprocessor/pp_utils.h000066400000000000000000000011461321746453100272730ustar00rootroot00000000000000// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // pp_utils.h: Common preprocessor utilities #ifndef COMPILER_PREPROCESSOR_PPUTILS_H_ #define COMPILER_PREPROCESSOR_PPUTILS_H_ // A macro to disallow the copy constructor and operator= functions // This must be used in the private: declarations for a class. #define PP_DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName &); \ void operator=(const TypeName &) #endif // COMPILER_PREPROCESSOR_PPUTILS_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/000077500000000000000000000000001321746453100247245ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/64bit-lexer-safety.patch000066400000000000000000000023611321746453100313050ustar00rootroot00000000000000--- a/src/compiler/glslang_lex.cpp +++ b/src/compiler/glslang_lex.cpp @@ -68,6 +68,7 @@ typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; @@ -191,6 +192,11 @@ typedef void* yyscan_t; typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 @@ -204,7 +210,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; */ #define YY_LESS_LINENO(n) \ do { \ - int yyl;\ + yy_size_t yyl;\ for ( yyl = n; yyl < yyleng; ++yyl )\ if ( yytext[yyl] == '\n' )\ --yylineno;\ @@ -378,7 +379,7 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); */ #define YY_DO_BEFORE_ACTION \ yyg->yytext_ptr = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/BaseTypes.h000066400000000000000000000320251321746453100267760ustar00rootroot00000000000000// // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_BASETYPES_H_ #define COMPILER_TRANSLATOR_BASETYPES_H_ #include "common/debug.h" // // Precision qualifiers // enum TPrecision { // These need to be kept sorted EbpUndefined, EbpLow, EbpMedium, EbpHigh, // end of list EbpLast }; inline const char* getPrecisionString(TPrecision p) { switch(p) { case EbpHigh: return "highp"; break; case EbpMedium: return "mediump"; break; case EbpLow: return "lowp"; break; default: return "mediump"; break; // Safest fallback } } // // Basic type. Arrays, vectors, etc., are orthogonal to this. // enum TBasicType { EbtVoid, EbtFloat, EbtInt, EbtUInt, EbtBool, EbtGVec4, // non type: represents vec4, ivec4, and uvec4 EbtGenType, // non type: represents float, vec2, vec3, and vec4 EbtGenIType, // non type: represents int, ivec2, ivec3, and ivec4 EbtGenUType, // non type: represents uint, uvec2, uvec3, and uvec4 EbtGenBType, // non type: represents bool, bvec2, bvec3, and bvec4 EbtVec, // non type: represents vec2, vec3, and vec4 EbtIVec, // non type: represents ivec2, ivec3, and ivec4 EbtUVec, // non type: represents uvec2, uvec3, and uvec4 EbtBVec, // non type: represents bvec2, bvec3, and bvec4 EbtGuardSamplerBegin, // non type: see implementation of IsSampler() EbtSampler2D, EbtSampler3D, EbtSamplerCube, EbtSampler2DArray, EbtSamplerExternalOES, // Only valid if OES_EGL_image_external exists. EbtSampler2DRect, // Only valid if GL_ARB_texture_rectangle exists. EbtISampler2D, EbtISampler3D, EbtISamplerCube, EbtISampler2DArray, EbtUSampler2D, EbtUSampler3D, EbtUSamplerCube, EbtUSampler2DArray, EbtSampler2DShadow, EbtSamplerCubeShadow, EbtSampler2DArrayShadow, EbtGuardSamplerEnd, // non type: see implementation of IsSampler() EbtGSampler2D, // non type: represents sampler2D, isampler2D, and usampler2D EbtGSampler3D, // non type: represents sampler3D, isampler3D, and usampler3D EbtGSamplerCube, // non type: represents samplerCube, isamplerCube, and usamplerCube EbtGSampler2DArray, // non type: represents sampler2DArray, isampler2DArray, and usampler2DArray EbtStruct, EbtInterfaceBlock, EbtAddress, // should be deprecated?? // end of list EbtLast }; const char* getBasicString(TBasicType t); inline bool IsSampler(TBasicType type) { return type > EbtGuardSamplerBegin && type < EbtGuardSamplerEnd; } inline bool IsIntegerSampler(TBasicType type) { switch (type) { case EbtISampler2D: case EbtISampler3D: case EbtISamplerCube: case EbtISampler2DArray: case EbtUSampler2D: case EbtUSampler3D: case EbtUSamplerCube: case EbtUSampler2DArray: return true; case EbtSampler2D: case EbtSampler3D: case EbtSamplerCube: case EbtSamplerExternalOES: case EbtSampler2DRect: case EbtSampler2DArray: case EbtSampler2DShadow: case EbtSamplerCubeShadow: case EbtSampler2DArrayShadow: return false; default: assert(!IsSampler(type)); } return false; } inline bool IsSampler2D(TBasicType type) { switch (type) { case EbtSampler2D: case EbtISampler2D: case EbtUSampler2D: case EbtSampler2DArray: case EbtISampler2DArray: case EbtUSampler2DArray: case EbtSampler2DRect: case EbtSamplerExternalOES: case EbtSampler2DShadow: case EbtSampler2DArrayShadow: return true; case EbtSampler3D: case EbtISampler3D: case EbtUSampler3D: case EbtISamplerCube: case EbtUSamplerCube: case EbtSamplerCube: case EbtSamplerCubeShadow: return false; default: assert(!IsSampler(type)); } return false; } inline bool IsSamplerCube(TBasicType type) { switch (type) { case EbtSamplerCube: case EbtISamplerCube: case EbtUSamplerCube: case EbtSamplerCubeShadow: return true; case EbtSampler2D: case EbtSampler3D: case EbtSamplerExternalOES: case EbtSampler2DRect: case EbtSampler2DArray: case EbtISampler2D: case EbtISampler3D: case EbtISampler2DArray: case EbtUSampler2D: case EbtUSampler3D: case EbtUSampler2DArray: case EbtSampler2DShadow: case EbtSampler2DArrayShadow: return false; default: assert(!IsSampler(type)); } return false; } inline bool IsSampler3D(TBasicType type) { switch (type) { case EbtSampler3D: case EbtISampler3D: case EbtUSampler3D: return true; case EbtSampler2D: case EbtSamplerCube: case EbtSamplerExternalOES: case EbtSampler2DRect: case EbtSampler2DArray: case EbtISampler2D: case EbtISamplerCube: case EbtISampler2DArray: case EbtUSampler2D: case EbtUSamplerCube: case EbtUSampler2DArray: case EbtSampler2DShadow: case EbtSamplerCubeShadow: case EbtSampler2DArrayShadow: return false; default: assert(!IsSampler(type)); } return false; } inline bool IsSamplerArray(TBasicType type) { switch (type) { case EbtSampler2DArray: case EbtISampler2DArray: case EbtUSampler2DArray: case EbtSampler2DArrayShadow: return true; case EbtSampler2D: case EbtISampler2D: case EbtUSampler2D: case EbtSampler2DRect: case EbtSamplerExternalOES: case EbtSampler3D: case EbtISampler3D: case EbtUSampler3D: case EbtISamplerCube: case EbtUSamplerCube: case EbtSamplerCube: case EbtSampler2DShadow: case EbtSamplerCubeShadow: return false; default: assert(!IsSampler(type)); } return false; } inline bool IsShadowSampler(TBasicType type) { switch (type) { case EbtSampler2DShadow: case EbtSamplerCubeShadow: case EbtSampler2DArrayShadow: return true; case EbtISampler2D: case EbtISampler3D: case EbtISamplerCube: case EbtISampler2DArray: case EbtUSampler2D: case EbtUSampler3D: case EbtUSamplerCube: case EbtUSampler2DArray: case EbtSampler2D: case EbtSampler3D: case EbtSamplerCube: case EbtSamplerExternalOES: case EbtSampler2DRect: case EbtSampler2DArray: return false; default: assert(!IsSampler(type)); } return false; } inline bool IsInteger(TBasicType type) { return type == EbtInt || type == EbtUInt; } inline bool SupportsPrecision(TBasicType type) { return type == EbtFloat || type == EbtInt || type == EbtUInt || IsSampler(type); } // // Qualifiers and built-ins. These are mainly used to see what can be read // or written, and by the machine dependent translator to know which registers // to allocate variables in. Since built-ins tend to go to different registers // than varying or uniform, it makes sense they are peers, not sub-classes. // enum TQualifier { EvqTemporary, // For temporaries (within a function), read/write EvqGlobal, // For globals read/write EvqConst, // User defined constants and non-output parameters in functions EvqAttribute, // Readonly EvqVaryingIn, // readonly, fragment shaders only EvqVaryingOut, // vertex shaders only read/write EvqUniform, // Readonly, vertex and fragment EvqVertexIn, // Vertex shader input EvqFragmentOut, // Fragment shader output EvqVertexOut, // Vertex shader output EvqFragmentIn, // Fragment shader input // parameters EvqIn, EvqOut, EvqInOut, EvqConstReadOnly, // built-ins read by vertex shader EvqInstanceID, // built-ins written by vertex shader EvqPosition, EvqPointSize, // built-ins read by fragment shader EvqFragCoord, EvqFrontFacing, EvqPointCoord, // built-ins written by fragment shader EvqFragColor, EvqFragData, EvqFragDepth, EvqSecondaryFragColorEXT, // EXT_blend_func_extended EvqSecondaryFragDataEXT, // EXT_blend_func_extended // built-ins written by the shader_framebuffer_fetch extension(s) EvqLastFragColor, EvqLastFragData, // GLSL ES 3.0 vertex output and fragment input EvqSmooth, // Incomplete qualifier, smooth is the default EvqFlat, // Incomplete qualifier EvqSmoothOut = EvqSmooth, EvqFlatOut = EvqFlat, EvqCentroidOut, // Implies smooth EvqSmoothIn, EvqFlatIn, EvqCentroidIn, // Implies smooth // end of list EvqLast }; enum TLayoutMatrixPacking { EmpUnspecified, EmpRowMajor, EmpColumnMajor }; enum TLayoutBlockStorage { EbsUnspecified, EbsShared, EbsPacked, EbsStd140 }; struct TLayoutQualifier { int location; TLayoutMatrixPacking matrixPacking; TLayoutBlockStorage blockStorage; static TLayoutQualifier create() { TLayoutQualifier layoutQualifier; layoutQualifier.location = -1; layoutQualifier.matrixPacking = EmpUnspecified; layoutQualifier.blockStorage = EbsUnspecified; return layoutQualifier; } bool isEmpty() const { return location == -1 && matrixPacking == EmpUnspecified && blockStorage == EbsUnspecified; } }; // // This is just for debug print out, carried along with the definitions above. // inline const char* getQualifierString(TQualifier q) { switch(q) { case EvqTemporary: return "Temporary"; break; case EvqGlobal: return "Global"; break; case EvqConst: return "const"; break; case EvqAttribute: return "attribute"; break; case EvqVaryingIn: return "varying"; break; case EvqVaryingOut: return "varying"; break; case EvqUniform: return "uniform"; break; case EvqVertexIn: return "in"; break; case EvqFragmentOut: return "out"; break; case EvqVertexOut: return "out"; break; case EvqFragmentIn: return "in"; break; case EvqIn: return "in"; break; case EvqOut: return "out"; break; case EvqInOut: return "inout"; break; case EvqConstReadOnly: return "const"; break; case EvqInstanceID: return "InstanceID"; break; case EvqPosition: return "Position"; break; case EvqPointSize: return "PointSize"; break; case EvqFragCoord: return "FragCoord"; break; case EvqFrontFacing: return "FrontFacing"; break; case EvqPointCoord: return "PointCoord"; break; case EvqFragColor: return "FragColor"; break; case EvqFragData: return "FragData"; break; case EvqFragDepth: return "FragDepth"; break; case EvqSecondaryFragColorEXT: return "SecondaryFragColorEXT"; break; case EvqSecondaryFragDataEXT: return "SecondaryFragDataEXT"; break; case EvqLastFragColor: return "LastFragColor"; break; case EvqLastFragData: return "LastFragData"; break; case EvqSmoothOut: return "smooth out"; break; case EvqCentroidOut: return "centroid out"; break; case EvqFlatOut: return "flat out"; break; case EvqSmoothIn: return "smooth in"; break; case EvqFlatIn: return "flat in"; break; case EvqCentroidIn: return "centroid in"; break; default: UNREACHABLE(); return "unknown qualifier"; } } inline const char* getMatrixPackingString(TLayoutMatrixPacking mpq) { switch (mpq) { case EmpUnspecified: return "mp_unspecified"; case EmpRowMajor: return "row_major"; case EmpColumnMajor: return "column_major"; default: UNREACHABLE(); return "unknown matrix packing"; } } inline const char* getBlockStorageString(TLayoutBlockStorage bsq) { switch (bsq) { case EbsUnspecified: return "bs_unspecified"; case EbsShared: return "shared"; case EbsPacked: return "packed"; case EbsStd140: return "std140"; default: UNREACHABLE(); return "unknown block storage"; } } inline const char* getInterpolationString(TQualifier q) { switch(q) { case EvqSmoothOut: return "smooth"; break; case EvqCentroidOut: return "centroid"; break; case EvqFlatOut: return "flat"; break; case EvqSmoothIn: return "smooth"; break; case EvqCentroidIn: return "centroid"; break; case EvqFlatIn: return "flat"; break; default: UNREACHABLE(); return "unknown interpolation"; } } #endif // COMPILER_TRANSLATOR_BASETYPES_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulator.cpp000066400000000000000000000173041321746453100322220ustar00rootroot00000000000000// // Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "angle_gl.h" #include "compiler/translator/BuiltInFunctionEmulator.h" #include "compiler/translator/SymbolTable.h" class BuiltInFunctionEmulator::BuiltInFunctionEmulationMarker : public TIntermTraverser { public: BuiltInFunctionEmulationMarker(BuiltInFunctionEmulator &emulator) : TIntermTraverser(true, false, false), mEmulator(emulator) { } virtual bool visitUnary(Visit visit, TIntermUnary *node) { if (visit == PreVisit) { bool needToEmulate = mEmulator.SetFunctionCalled(node->getOp(), node->getOperand()->getType()); if (needToEmulate) node->setUseEmulatedFunction(); } return true; } virtual bool visitAggregate(Visit visit, TIntermAggregate *node) { if (visit == PreVisit) { // Here we handle all the built-in functions instead of the ones we // currently identified as problematic. switch (node->getOp()) { case EOpLessThan: case EOpGreaterThan: case EOpLessThanEqual: case EOpGreaterThanEqual: case EOpVectorEqual: case EOpVectorNotEqual: case EOpMod: case EOpPow: case EOpAtan: case EOpMin: case EOpMax: case EOpClamp: case EOpMix: case EOpStep: case EOpSmoothStep: case EOpDistance: case EOpDot: case EOpCross: case EOpFaceForward: case EOpReflect: case EOpRefract: case EOpOuterProduct: case EOpMul: break; default: return true; } const TIntermSequence &sequence = *(node->getSequence()); bool needToEmulate = false; // Right now we only handle built-in functions with two or three parameters. if (sequence.size() == 2) { TIntermTyped *param1 = sequence[0]->getAsTyped(); TIntermTyped *param2 = sequence[1]->getAsTyped(); if (!param1 || !param2) return true; needToEmulate = mEmulator.SetFunctionCalled( node->getOp(), param1->getType(), param2->getType()); } else if (sequence.size() == 3) { TIntermTyped *param1 = sequence[0]->getAsTyped(); TIntermTyped *param2 = sequence[1]->getAsTyped(); TIntermTyped *param3 = sequence[2]->getAsTyped(); if (!param1 || !param2 || !param3) return true; needToEmulate = mEmulator.SetFunctionCalled( node->getOp(), param1->getType(), param2->getType(), param3->getType()); } else { return true; } if (needToEmulate) node->setUseEmulatedFunction(); } return true; } private: BuiltInFunctionEmulator &mEmulator; }; BuiltInFunctionEmulator::BuiltInFunctionEmulator() {} void BuiltInFunctionEmulator::addEmulatedFunction(TOperator op, const TType *param, const char *emulatedFunctionDefinition) { mEmulatedFunctions[FunctionId(op, param)] = std::string(emulatedFunctionDefinition); } void BuiltInFunctionEmulator::addEmulatedFunction(TOperator op, const TType *param1, const TType *param2, const char *emulatedFunctionDefinition) { mEmulatedFunctions[FunctionId(op, param1, param2)] = std::string(emulatedFunctionDefinition); } void BuiltInFunctionEmulator::addEmulatedFunction(TOperator op, const TType *param1, const TType *param2, const TType *param3, const char *emulatedFunctionDefinition) { mEmulatedFunctions[FunctionId(op, param1, param2, param3)] = std::string(emulatedFunctionDefinition); } bool BuiltInFunctionEmulator::IsOutputEmpty() const { return (mFunctions.size() == 0); } void BuiltInFunctionEmulator::OutputEmulatedFunctions(TInfoSinkBase &out) const { for (size_t i = 0; i < mFunctions.size(); ++i) { out << mEmulatedFunctions.find(mFunctions[i])->second << "\n\n"; } } bool BuiltInFunctionEmulator::SetFunctionCalled(TOperator op, const TType ¶m) { return SetFunctionCalled(FunctionId(op, ¶m)); } bool BuiltInFunctionEmulator::SetFunctionCalled(TOperator op, const TType ¶m1, const TType ¶m2) { return SetFunctionCalled(FunctionId(op, ¶m1, ¶m2)); } bool BuiltInFunctionEmulator::SetFunctionCalled(TOperator op, const TType ¶m1, const TType ¶m2, const TType ¶m3) { return SetFunctionCalled(FunctionId(op, ¶m1, ¶m2, ¶m3)); } bool BuiltInFunctionEmulator::SetFunctionCalled(const FunctionId &functionId) { if (mEmulatedFunctions.find(functionId) != mEmulatedFunctions.end()) { for (size_t i = 0; i < mFunctions.size(); ++i) { if (mFunctions[i] == functionId) return true; } // Copy the functionId if it needs to be stored, to make sure that the TType pointers inside // remain valid and constant. mFunctions.push_back(functionId.getCopy()); return true; } return false; } void BuiltInFunctionEmulator::MarkBuiltInFunctionsForEmulation(TIntermNode *root) { ASSERT(root); if (mEmulatedFunctions.empty()) return; BuiltInFunctionEmulationMarker marker(*this); root->traverse(&marker); } void BuiltInFunctionEmulator::Cleanup() { mFunctions.clear(); } //static TString BuiltInFunctionEmulator::GetEmulatedFunctionName( const TString &name) { ASSERT(name[name.length() - 1] == '('); return "webgl_" + name.substr(0, name.length() - 1) + "_emu("; } BuiltInFunctionEmulator::FunctionId::FunctionId(TOperator op, const TType *param) : mOp(op), mParam1(param), mParam2(new TType(EbtVoid)), mParam3(new TType(EbtVoid)) { } BuiltInFunctionEmulator::FunctionId::FunctionId(TOperator op, const TType *param1, const TType *param2) : mOp(op), mParam1(param1), mParam2(param2), mParam3(new TType(EbtVoid)) { } BuiltInFunctionEmulator::FunctionId::FunctionId(TOperator op, const TType *param1, const TType *param2, const TType *param3) : mOp(op), mParam1(param1), mParam2(param2), mParam3(param3) { } bool BuiltInFunctionEmulator::FunctionId::operator==(const BuiltInFunctionEmulator::FunctionId &other) const { return (mOp == other.mOp && *mParam1 == *other.mParam1 && *mParam2 == *other.mParam2 && *mParam3 == *other.mParam3); } bool BuiltInFunctionEmulator::FunctionId::operator<(const BuiltInFunctionEmulator::FunctionId &other) const { if (mOp != other.mOp) return mOp < other.mOp; if (*mParam1 != *other.mParam1) return *mParam1 < *other.mParam1; if (*mParam2 != *other.mParam2) return *mParam2 < *other.mParam2; if (*mParam3 != *other.mParam3) return *mParam3 < *other.mParam3; return false; // all fields are equal } BuiltInFunctionEmulator::FunctionId BuiltInFunctionEmulator::FunctionId::getCopy() const { return FunctionId(mOp, new TType(*mParam1), new TType(*mParam2), new TType(*mParam3)); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulator.h000066400000000000000000000062311321746453100316640ustar00rootroot00000000000000// // Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATOR_H_ #define COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATOR_H_ #include "compiler/translator/InfoSink.h" #include "compiler/translator/IntermNode.h" // // This class decides which built-in functions need to be replaced with the // emulated ones. // It can be used to work around driver bugs or implement functions that are // not natively implemented on a specific platform. // class BuiltInFunctionEmulator { public: BuiltInFunctionEmulator(); void MarkBuiltInFunctionsForEmulation(TIntermNode *root); void Cleanup(); // "name(" becomes "webgl_name_emu(". static TString GetEmulatedFunctionName(const TString &name); bool IsOutputEmpty() const; // Output function emulation definition. This should be before any other // shader source. void OutputEmulatedFunctions(TInfoSinkBase &out) const; // Add functions that need to be emulated. void addEmulatedFunction(TOperator op, const TType *param, const char *emulatedFunctionDefinition); void addEmulatedFunction(TOperator op, const TType *param1, const TType *param2, const char *emulatedFunctionDefinition); void addEmulatedFunction(TOperator op, const TType *param1, const TType *param2, const TType *param3, const char *emulatedFunctionDefinition); private: class BuiltInFunctionEmulationMarker; // Records that a function is called by the shader and might need to be // emulated. If the function is not in mEmulatedFunctions, this becomes a // no-op. Returns true if the function call needs to be replaced with an // emulated one. bool SetFunctionCalled(TOperator op, const TType ¶m); bool SetFunctionCalled(TOperator op, const TType ¶m1, const TType ¶m2); bool SetFunctionCalled(TOperator op, const TType ¶m1, const TType ¶m2, const TType ¶m3); class FunctionId { public: FunctionId(TOperator op, const TType *param); FunctionId(TOperator op, const TType *param1, const TType *param2); FunctionId(TOperator op, const TType *param1, const TType *param2, const TType *param3); bool operator==(const FunctionId &other) const; bool operator<(const FunctionId &other) const; FunctionId getCopy() const; private: TOperator mOp; // The memory that these TType objects use is freed by PoolAllocator. The BuiltInFunctionEmulator's lifetime // can extend until after the memory pool is freed, but that's not an issue since this class never destructs // these objects. const TType *mParam1; const TType *mParam2; const TType *mParam3; }; bool SetFunctionCalled(const FunctionId &functionId); // Map from function id to emulated function definition std::map mEmulatedFunctions; // Called function ids std::vector mFunctions; }; #endif // COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATOR_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorGLSL.cpp000066400000000000000000000131051321746453100326770ustar00rootroot00000000000000// // Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "angle_gl.h" #include "compiler/translator/BuiltInFunctionEmulator.h" #include "compiler/translator/BuiltInFunctionEmulatorGLSL.h" #include "compiler/translator/Cache.h" #include "compiler/translator/SymbolTable.h" #include "compiler/translator/VersionGLSL.h" // Emulate built-in functions missing from GLSL 1.30 and higher void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator *emu, sh::GLenum shaderType, int targetGLSLVersion) { // Emulate packSnorm2x16, packHalf2x16, unpackSnorm2x16, and unpackHalf2x16 (GLSL 4.20) // by using floatBitsToInt, floatBitsToUint, intBitsToFloat, and uintBitsToFloat (GLSL 3.30). if (targetGLSLVersion >= GLSL_VERSION_330 && targetGLSLVersion < GLSL_VERSION_420) { const TType *float2 = TCache::getType(EbtFloat, 2); const TType *uint1 = TCache::getType(EbtUInt); emu->addEmulatedFunction(EOpPackSnorm2x16, float2, "uint webgl_packSnorm2x16_emu(vec2 v)\n" "{\n" " int x = int(round(clamp(v.x, -1.0, 1.0) * 32767.0));\n" " int y = int(round(clamp(v.y, -1.0, 1.0) * 32767.0));\n" " return uint((y << 16) | (x & 0xFFFF));\n" "}\n"); emu->addEmulatedFunction(EOpUnpackSnorm2x16, uint1, "float webgl_fromSnorm(uint x)\n" "{\n" " int xi = (int(x) & 0x7FFF) - (int(x) & 0x8000);\n" " return clamp(float(xi) / 32767.0, -1.0, 1.0);\n" "}\n" "\n" "vec2 webgl_unpackSnorm2x16_emu(uint u)\n" "{\n" " uint y = (u >> 16);\n" " uint x = u;\n" " return vec2(webgl_fromSnorm(x), webgl_fromSnorm(y));\n" "}\n"); // Functions uint webgl_f32tof16(float val) and float webgl_f16tof32(uint val) are // based on the OpenGL redbook Appendix Session "Floating-Point Formats Used in OpenGL". emu->addEmulatedFunction(EOpPackHalf2x16, float2, "uint webgl_f32tof16(float val)\n" "{\n" " uint f32 = floatBitsToUint(val);\n" " uint f16 = 0u;\n" " uint sign = (f32 >> 16) & 0x8000u;\n" " int exponent = int((f32 >> 23) & 0xFFu) - 127;\n" " uint mantissa = f32 & 0x007FFFFFu;\n" " if (exponent == 128)\n" " {\n" " // Infinity or NaN\n" " // NaN bits that are masked out by 0x3FF get discarded.\n" " // This can turn some NaNs to infinity, but this is allowed by the spec.\n" " f16 = sign | (0x1Fu << 10);\n" " f16 |= (mantissa & 0x3FFu);\n" " }\n" " else if (exponent > 15)\n" " {\n" " // Overflow - flush to Infinity\n" " f16 = sign | (0x1Fu << 10);\n" " }\n" " else if (exponent > -15)\n" " {\n" " // Representable value\n" " exponent += 15;\n" " mantissa >>= 13;\n" " f16 = sign | uint(exponent << 10) | mantissa;\n" " }\n" " else\n" " {\n" " f16 = sign;\n" " }\n" " return f16;\n" "}\n" "\n" "uint webgl_packHalf2x16_emu(vec2 v)\n" "{\n" " uint x = webgl_f32tof16(v.x);\n" " uint y = webgl_f32tof16(v.y);\n" " return (y << 16) | x;\n" "}\n"); emu->addEmulatedFunction(EOpUnpackHalf2x16, uint1, "float webgl_f16tof32(uint val)\n" "{\n" " uint sign = (val & 0x8000u) << 16;\n" " int exponent = int((val & 0x7C00u) >> 10);\n" " uint mantissa = val & 0x03FFu;\n" " float f32 = 0.0;\n" " if(exponent == 0)\n" " {\n" " if (mantissa != 0u)\n" " {\n" " const float scale = 1.0 / (1 << 24);\n" " f32 = scale * mantissa;\n" " }\n" " }\n" " else if (exponent == 31)\n" " {\n" " return uintBitsToFloat(sign | 0x7F800000u | mantissa);\n" " }\n" " else\n" " {\n" " exponent -= 15;\n" " float scale;\n" " if(exponent < 0)\n" " {\n" " scale = 1.0 / (1 << -exponent);\n" " }\n" " else\n" " {\n" " scale = 1 << exponent;\n" " }\n" " float decimal = 1.0 + float(mantissa) / float(1 << 10);\n" " f32 = scale * decimal;\n" " }\n" "\n" " if (sign != 0u)\n" " {\n" " f32 = -f32;\n" " }\n" "\n" " return f32;\n" "}\n" "\n" "vec2 webgl_unpackHalf2x16_emu(uint u)\n" "{\n" " uint y = (u >> 16);\n" " uint x = u & 0xFFFFu;\n" " return vec2(webgl_f16tof32(x), webgl_f16tof32(y));\n" "}\n"); } } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorGLSL.h000066400000000000000000000013041321746453100323420ustar00rootroot00000000000000// // Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATORGLSL_H_ #define COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATORGLSL_H_ #include "GLSLANG/ShaderLang.h" class BuiltInFunctionEmulator; // // This function is emulating built-in functions missing from GLSL 1.30 and higher. // void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator *emu, sh::GLenum shaderType, int targetGLSLVersion); #endif // COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATORGLSL_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/Cache.cpp000066400000000000000000000052621321746453100264400ustar00rootroot00000000000000// // Copyright (c) 2015 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // Cache.cpp: Implements a cache for various commonly created objects. #include #include "common/angleutils.h" #include "common/debug.h" #include "compiler/translator/Cache.h" namespace { class TScopedAllocator : angle::NonCopyable { public: TScopedAllocator(TPoolAllocator *allocator) : mPreviousAllocator(GetGlobalPoolAllocator()) { SetGlobalPoolAllocator(allocator); } ~TScopedAllocator() { SetGlobalPoolAllocator(mPreviousAllocator); } private: TPoolAllocator *mPreviousAllocator; }; } // namespace TCache::TypeKey::TypeKey(TBasicType basicType, TPrecision precision, TQualifier qualifier, unsigned char primarySize, unsigned char secondarySize) { static_assert(sizeof(components) <= sizeof(value), "TypeKey::value is too small"); const size_t MaxEnumValue = std::numeric_limits::max(); UNUSED_ASSERTION_VARIABLE(MaxEnumValue); // TODO: change to static_assert() once we deprecate MSVC 2013 support ASSERT(MaxEnumValue >= EbtLast && MaxEnumValue >= EbpLast && MaxEnumValue >= EvqLast && "TypeKey::EnumComponentType is too small"); value = 0; components.basicType = static_cast(basicType); components.precision = static_cast(precision); components.qualifier = static_cast(qualifier); components.primarySize = primarySize; components.secondarySize = secondarySize; } TCache *TCache::sCache = nullptr; void TCache::initialize() { if (sCache == nullptr) { sCache = new TCache(); } } void TCache::destroy() { SafeDelete(sCache); } const TType *TCache::getType(TBasicType basicType, TPrecision precision, TQualifier qualifier, unsigned char primarySize, unsigned char secondarySize) { TypeKey key(basicType, precision, qualifier, primarySize, secondarySize); auto it = sCache->mTypes.find(key); if (it != sCache->mTypes.end()) { return it->second; } TScopedAllocator scopedAllocator(&sCache->mAllocator); TType *type = new TType(basicType, precision, qualifier, primarySize, secondarySize); type->realize(); sCache->mTypes.insert(std::make_pair(key, type)); return type; } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/Cache.h000066400000000000000000000050321321746453100261000ustar00rootroot00000000000000// // Copyright (c) 2015 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // Cache.h: Implements a cache for various commonly created objects. #ifndef COMPILER_TRANSLATOR_CACHE_H_ #define COMPILER_TRANSLATOR_CACHE_H_ #include #include #include #include "compiler/translator/Types.h" #include "compiler/translator/PoolAlloc.h" class TCache { public: static void initialize(); static void destroy(); static const TType *getType(TBasicType basicType, TPrecision precision) { return getType(basicType, precision, EvqTemporary, 1, 1); } static const TType *getType(TBasicType basicType, unsigned char primarySize = 1, unsigned char secondarySize = 1) { return getType(basicType, EbpUndefined, EvqGlobal, primarySize, secondarySize); } static const TType *getType(TBasicType basicType, TQualifier qualifier, unsigned char primarySize = 1, unsigned char secondarySize = 1) { return getType(basicType, EbpUndefined, qualifier, primarySize, secondarySize); } static const TType *getType(TBasicType basicType, TPrecision precision, TQualifier qualifier, unsigned char primarySize, unsigned char secondarySize); private: TCache() { } union TypeKey { TypeKey(TBasicType basicType, TPrecision precision, TQualifier qualifier, unsigned char primarySize, unsigned char secondarySize); typedef uint8_t EnumComponentType; struct { EnumComponentType basicType; EnumComponentType precision; EnumComponentType qualifier; unsigned char primarySize; unsigned char secondarySize; } components; uint64_t value; bool operator < (const TypeKey &other) const { return value < other.value; } }; typedef std::map TypeMap; TypeMap mTypes; TPoolAllocator mAllocator; static TCache *sCache; }; #endif // COMPILER_TRANSLATOR_CACHE_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/CallDAG.cpp000066400000000000000000000176171321746453100266330ustar00rootroot00000000000000// // Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // CallDAG.h: Implements a call graph DAG of functions to be re-used across // analyses, allows to efficiently traverse the functions in topological // order. #include "compiler/translator/CallDAG.h" #include "compiler/translator/InfoSink.h" // The CallDAGCreator does all the processing required to create the CallDAG // structure so that the latter contains only the necessary variables. class CallDAG::CallDAGCreator : public TIntermTraverser { public: CallDAGCreator(TInfoSinkBase *info) : TIntermTraverser(true, false, true), mCreationInfo(info), mCurrentFunction(nullptr), mCurrentIndex(0) { } InitResult assignIndices() { int skipped = 0; for (auto &it : mFunctions) { // Skip unimplemented functions if (it.second.node) { InitResult result = assignIndicesInternal(&it.second); if (result != INITDAG_SUCCESS) { return result; } } else { skipped++; } } ASSERT(mFunctions.size() == mCurrentIndex + skipped); return INITDAG_SUCCESS; } void fillDataStructures(std::vector *records, std::map *idToIndex) { ASSERT(records->empty()); ASSERT(idToIndex->empty()); records->resize(mCurrentIndex); for (auto &it : mFunctions) { CreatorFunctionData &data = it.second; // Skip unimplemented functions if (!data.node) { continue; } ASSERT(data.index < records->size()); Record &record = (*records)[data.index]; record.name = data.name.data(); record.node = data.node; record.callees.reserve(data.callees.size()); for (auto &callee : data.callees) { record.callees.push_back(static_cast(callee->index)); } (*idToIndex)[data.node->getFunctionId()] = static_cast(data.index); } } private: struct CreatorFunctionData { CreatorFunctionData() : node(nullptr), index(0), indexAssigned(false), visiting(false) { } std::set callees; TIntermAggregate *node; TString name; size_t index; bool indexAssigned; bool visiting; }; // Aggregates the AST node for each function as well as the name of the functions called by it bool visitAggregate(Visit visit, TIntermAggregate *node) override { switch (node->getOp()) { case EOpPrototype: if (visit == PreVisit) { // Function declaration, create an empty record. mFunctions[node->getName()]; } break; case EOpFunction: { // Function definition, create the record if need be and remember the node. if (visit == PreVisit) { auto it = mFunctions.find(node->getName()); if (it == mFunctions.end()) { mCurrentFunction = &mFunctions[node->getName()]; } else { mCurrentFunction = &it->second; } mCurrentFunction->node = node; mCurrentFunction->name = node->getName(); } else if (visit == PostVisit) { mCurrentFunction = nullptr; } break; } case EOpFunctionCall: { // Function call, add the callees if (visit == PreVisit) { // Do not handle calls to builtin functions if (node->isUserDefined()) { auto it = mFunctions.find(node->getName()); ASSERT(it != mFunctions.end()); // We might be in a top-level function call to set a global variable if (mCurrentFunction) { mCurrentFunction->callees.insert(&it->second); } } } break; } default: break; } return true; } // Recursively assigns indices to a sub DAG InitResult assignIndicesInternal(CreatorFunctionData *function) { ASSERT(function); if (!function->node) { *mCreationInfo << "Undefined function: " << function->name; return INITDAG_UNDEFINED; } if (function->indexAssigned) { return INITDAG_SUCCESS; } if (function->visiting) { if (mCreationInfo) { *mCreationInfo << "Recursive function call in the following call chain: " << function->name; } return INITDAG_RECURSION; } function->visiting = true; for (auto &callee : function->callees) { InitResult result = assignIndicesInternal(callee); if (result == INITDAG_RECURSION) { // We know that there is a recursive function call chain in the AST, // print the link of the chain we were processing. if (mCreationInfo) { *mCreationInfo << " <- " << function->name; } return INITDAG_RECURSION; } else if (result == INITDAG_UNDEFINED) { return INITDAG_UNDEFINED; } } function->index = mCurrentIndex++; function->indexAssigned = true; function->visiting = false; return INITDAG_SUCCESS; } TInfoSinkBase *mCreationInfo; std::map mFunctions; CreatorFunctionData *mCurrentFunction; size_t mCurrentIndex; }; // CallDAG CallDAG::CallDAG() { } CallDAG::~CallDAG() { } const size_t CallDAG::InvalidIndex = std::numeric_limits::max(); size_t CallDAG::findIndex(const TIntermAggregate *function) const { TOperator op = function->getOp(); ASSERT(op == EOpPrototype || op == EOpFunction || op == EOpFunctionCall); UNUSED_ASSERTION_VARIABLE(op); auto it = mFunctionIdToIndex.find(function->getFunctionId()); if (it == mFunctionIdToIndex.end()) { return InvalidIndex; } else { return it->second; } } const CallDAG::Record &CallDAG::getRecordFromIndex(size_t index) const { ASSERT(index != InvalidIndex && index < mRecords.size()); return mRecords[index]; } const CallDAG::Record &CallDAG::getRecord(const TIntermAggregate *function) const { size_t index = findIndex(function); ASSERT(index != InvalidIndex && index < mRecords.size()); return mRecords[index]; } size_t CallDAG::size() const { return mRecords.size(); } void CallDAG::clear() { mRecords.clear(); mFunctionIdToIndex.clear(); } CallDAG::InitResult CallDAG::init(TIntermNode *root, TInfoSinkBase *info) { CallDAGCreator creator(info); // Creates the mapping of functions to callees root->traverse(&creator); // Does the topological sort and detects recursions InitResult result = creator.assignIndices(); if (result != INITDAG_SUCCESS) { return result; } creator.fillDataStructures(&mRecords, &mFunctionIdToIndex); return INITDAG_SUCCESS; } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/CallDAG.h000066400000000000000000000043511321746453100262670ustar00rootroot00000000000000// // Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // CallDAG.h: Defines a call graph DAG of functions to be re-used across // analyses, allows to efficiently traverse the functions in topological // order. #ifndef COMPILER_TRANSLATOR_CALLDAG_H_ #define COMPILER_TRANSLATOR_CALLDAG_H_ #include #include "compiler/translator/IntermNode.h" // The translator needs to analyze the the graph of the function calls // to run checks and analyses; since in GLSL recursion is not allowed // that graph is a DAG. // This class is used to precompute that function call DAG so that it // can be reused by multiple analyses. // // It stores a vector of function records, with one record per function. // Records are accessed by index but a mangled function name can be converted // to the index of the corresponding record. The records mostly contain the // AST node of the function and the indices of the function's callees. // // In addition, records are in reverse topological order: a function F being // called by a function G will have index index(F) < index(G), that way // depth-first analysis becomes analysis in the order of indices. class CallDAG : angle::NonCopyable { public: CallDAG(); ~CallDAG(); struct Record { std::string name; TIntermAggregate *node; std::vector callees; }; enum InitResult { INITDAG_SUCCESS, INITDAG_RECURSION, INITDAG_UNDEFINED, }; // Returns INITDAG_SUCCESS if it was able to create the DAG, otherwise prints // the initialization error in info, if present. InitResult init(TIntermNode *root, TInfoSinkBase *info); // Returns InvalidIndex if the function wasn't found size_t findIndex(const TIntermAggregate *function) const; const Record &getRecordFromIndex(size_t index) const; const Record &getRecord(const TIntermAggregate *function) const; size_t size() const; void clear(); const static size_t InvalidIndex; private: std::vector mRecords; std::map mFunctionIdToIndex; class CallDAGCreator; }; #endif // COMPILER_TRANSLATOR_CALLDAG_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/CodeGen.cpp000066400000000000000000000014731321746453100267410ustar00rootroot00000000000000// // Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/TranslatorGLSL.h" // // This function must be provided to create the actual // compile object used by higher level code. It returns // a subclass of TCompiler. // TCompiler* ConstructCompiler( sh::GLenum type, ShShaderSpec spec, ShShaderOutput output) { switch (output) { case SH_GLSL_COMPATIBILITY_OUTPUT: return new TranslatorGLSL(type, spec, output); default: // Unknown format. Return NULL per the ShConstructCompiler API. return NULL; } } // // Delete the compiler made by ConstructCompiler // void DeleteCompiler(TCompiler* compiler) { delete compiler; } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/Common.h000066400000000000000000000062671321746453100263400ustar00rootroot00000000000000// // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_COMMON_H_ #define COMPILER_TRANSLATOR_COMMON_H_ #include #include #include #include #include #include #include "common/angleutils.h" #include "common/debug.h" #include "compiler/translator/PoolAlloc.h" struct TSourceLoc { int first_file; int first_line; int last_file; int last_line; }; // // Put POOL_ALLOCATOR_NEW_DELETE in base classes to make them use this scheme. // #define POOL_ALLOCATOR_NEW_DELETE() \ void* operator new(size_t s) { return GetGlobalPoolAllocator()->allocate(s); } \ void* operator new(size_t, void *_Where) { return (_Where); } \ void operator delete(void*) { } \ void operator delete(void *, void *) { } \ void* operator new[](size_t s) { return GetGlobalPoolAllocator()->allocate(s); } \ void* operator new[](size_t, void *_Where) { return (_Where); } \ void operator delete[](void*) { } \ void operator delete[](void *, void *) { } // // Pool version of string. // typedef pool_allocator TStringAllocator; typedef std::basic_string , TStringAllocator> TString; typedef std::basic_ostringstream, TStringAllocator> TStringStream; inline TString* NewPoolTString(const char* s) { void* memory = GetGlobalPoolAllocator()->allocate(sizeof(TString)); return new(memory) TString(s); } // // Persistent string memory. Should only be used for strings that survive // across compiles. // #define TPersistString std::string #define TPersistStringStream std::ostringstream // // Pool allocator versions of vectors, lists, and maps // template class TVector : public std::vector > { public: typedef typename std::vector >::size_type size_type; TVector() : std::vector >() {} TVector(const pool_allocator& a) : std::vector >(a) {} TVector(size_type i): std::vector >(i) {} }; template > class TMap : public std::map > > { public: typedef pool_allocator > tAllocator; TMap() : std::map() {} // use correct two-stage name lookup supported in gcc 3.4 and above TMap(const tAllocator& a) : std::map(std::map::key_compare(), a) {} }; // Integer to TString conversion template inline TString str(T i) { ASSERT(std::numeric_limits::is_integer); char buffer[((8 * sizeof(T)) / 3) + 3]; const char *formatStr = std::numeric_limits::is_signed ? "%d" : "%u"; snprintf(buffer, sizeof(buffer), formatStr, i); return buffer; } #endif // COMPILER_TRANSLATOR_COMMON_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/Compiler.cpp000066400000000000000000000332611321746453100272070ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/Cache.h" #include "compiler/translator/Compiler.h" #include "compiler/translator/CallDAG.h" #include "compiler/translator/Initialize.h" #include "compiler/translator/InitializeParseContext.h" #include "compiler/translator/ParseContext.h" #include "compiler/translator/PruneEmptyDeclarations.h" #include "compiler/translator/ValidateOutputs.h" #include "angle_gl.h" #include "common/utilities.h" size_t GetGlobalMaxTokenSize(ShShaderSpec spec) { return 1024; } namespace { class TScopedPoolAllocator { public: TScopedPoolAllocator(TPoolAllocator* allocator) : mAllocator(allocator) { mAllocator->push(); SetGlobalPoolAllocator(mAllocator); } ~TScopedPoolAllocator() { SetGlobalPoolAllocator(NULL); mAllocator->pop(); } private: TPoolAllocator* mAllocator; }; class TScopedSymbolTableLevel { public: TScopedSymbolTableLevel(TSymbolTable* table) : mTable(table) { ASSERT(mTable->atBuiltInLevel()); mTable->push(); } ~TScopedSymbolTableLevel() { while (!mTable->atBuiltInLevel()) mTable->pop(); } private: TSymbolTable* mTable; }; int MapSpecToShaderVersion(ShShaderSpec spec) { return 100; } } // namespace TShHandleBase::TShHandleBase() { allocator.push(); SetGlobalPoolAllocator(&allocator); } TShHandleBase::~TShHandleBase() { SetGlobalPoolAllocator(NULL); allocator.popAll(); } TCompiler::TCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output) : shaderType(type), shaderSpec(spec), outputType(output), maxUniformVectors(0), maxExpressionComplexity(0), maxCallStackDepth(0), fragmentPrecisionHigh(false), builtInFunctionEmulator(), mSourcePath(NULL) { } TCompiler::~TCompiler() { } bool TCompiler::Init(const ShBuiltInResources& resources) { shaderVersion = 100; maxUniformVectors = (shaderType == GL_VERTEX_SHADER) ? resources.MaxVertexUniformVectors : resources.MaxFragmentUniformVectors; maxExpressionComplexity = resources.MaxExpressionComplexity; maxCallStackDepth = resources.MaxCallStackDepth; SetGlobalPoolAllocator(&allocator); // Generate built-in symbol table. if (!InitBuiltInSymbolTable(resources)) return false; InitExtensionBehavior(resources, extensionBehavior); fragmentPrecisionHigh = resources.FragmentPrecisionHigh == 1; hashFunction = resources.HashFunction; return true; } TIntermNode *TCompiler::compileTreeForTesting(const char* const shaderStrings[], size_t numStrings, int compileOptions) { return compileTreeImpl(shaderStrings, numStrings, compileOptions); } TIntermNode *TCompiler::compileTreeImpl(const char* const shaderStrings[], size_t numStrings, int compileOptions) { clearResults(); ASSERT(numStrings > 0); ASSERT(GetGlobalPoolAllocator()); // Reset the extension behavior for each compilation unit. ResetExtensionBehavior(extensionBehavior); // First string is path of source file if flag is set. The actual source follows. size_t firstSource = 0; bool debugShaderPrecision = getResources().WEBGL_debug_shader_precision == 1; TIntermediate intermediate(infoSink); TParseContext parseContext(symbolTable, extensionBehavior, intermediate, shaderType, shaderSpec, compileOptions, true, infoSink, debugShaderPrecision); parseContext.setFragmentPrecisionHigh(fragmentPrecisionHigh); SetGlobalParseContext(&parseContext); // We preserve symbols at the built-in level from compile-to-compile. // Start pushing the user-defined symbols at global level. TScopedSymbolTableLevel scopedSymbolLevel(&symbolTable); // Parse shader. bool success = (PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], nullptr, &parseContext) == 0) && (parseContext.getTreeRoot() != nullptr); shaderVersion = parseContext.getShaderVersion(); if (success && MapSpecToShaderVersion(shaderSpec) < shaderVersion) { infoSink.info.prefix(EPrefixError); infoSink.info << "unsupported shader version"; success = false; } TIntermNode *root = nullptr; if (success) { mPragma = parseContext.pragma(); if (mPragma.stdgl.invariantAll) { symbolTable.setGlobalInvariant(); } root = parseContext.getTreeRoot(); root = intermediate.postProcess(root); // Create the function DAG and check there is no recursion if (success) success = initCallDag(root); // Checks which functions are used and if "main" exists if (success) { functionMetadata.clear(); functionMetadata.resize(mCallDag.size()); success = tagUsedFunctions(); } // Prune empty declarations to work around driver bugs and to keep declaration output simple. if (success) PruneEmptyDeclarations(root); if (success && shaderVersion == 300 && shaderType == GL_FRAGMENT_SHADER) success = validateOutputs(root); // Built-in function emulation needs to happen after validateLimitations pass. if (success) { initBuiltInFunctionEmulator(&builtInFunctionEmulator, compileOptions); builtInFunctionEmulator.MarkBuiltInFunctionsForEmulation(root); } } SetGlobalParseContext(NULL); if (success) return root; return NULL; } bool TCompiler::compile(const char* const shaderStrings[], size_t numStrings, int compileOptions) { if (numStrings == 0) return true; TScopedPoolAllocator scopedAlloc(&allocator); TIntermNode *root = compileTreeImpl(shaderStrings, numStrings, compileOptions); if (root) { if (compileOptions & SH_OBJECT_CODE) translate(root, compileOptions); // The IntermNode tree doesn't need to be deleted here, since the // memory will be freed in a big chunk by the PoolAllocator. return true; } return false; } bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources) { compileResources = resources; setResourceString(); assert(symbolTable.isEmpty()); symbolTable.push(); // COMMON_BUILTINS symbolTable.push(); // ESSL1_BUILTINS symbolTable.push(); // ESSL3_BUILTINS TPublicType integer; integer.type = EbtInt; integer.primarySize = 1; integer.secondarySize = 1; integer.array = false; TPublicType floatingPoint; floatingPoint.type = EbtFloat; floatingPoint.primarySize = 1; floatingPoint.secondarySize = 1; floatingPoint.array = false; TPublicType sampler; sampler.primarySize = 1; sampler.secondarySize = 1; sampler.array = false; switch(shaderType) { case GL_FRAGMENT_SHADER: symbolTable.setDefaultPrecision(integer, EbpMedium); break; case GL_VERTEX_SHADER: symbolTable.setDefaultPrecision(integer, EbpHigh); symbolTable.setDefaultPrecision(floatingPoint, EbpHigh); break; default: assert(false && "Language not supported"); } // We set defaults for all the sampler types, even those that are // only available if an extension exists. for (int samplerType = EbtGuardSamplerBegin + 1; samplerType < EbtGuardSamplerEnd; ++samplerType) { sampler.type = static_cast(samplerType); symbolTable.setDefaultPrecision(sampler, EbpLow); } InsertBuiltInFunctions(shaderType, shaderSpec, resources, symbolTable); IdentifyBuiltIns(shaderType, shaderSpec, resources, symbolTable); return true; } void TCompiler::setResourceString() { std::ostringstream strstream; strstream << ":MaxVertexAttribs:" << compileResources.MaxVertexAttribs << ":MaxVertexUniformVectors:" << compileResources.MaxVertexUniformVectors << ":MaxVaryingVectors:" << compileResources.MaxVaryingVectors << ":MaxVertexTextureImageUnits:" << compileResources.MaxVertexTextureImageUnits << ":MaxCombinedTextureImageUnits:" << compileResources.MaxCombinedTextureImageUnits << ":MaxTextureImageUnits:" << compileResources.MaxTextureImageUnits << ":MaxFragmentUniformVectors:" << compileResources.MaxFragmentUniformVectors << ":MaxDrawBuffers:" << compileResources.MaxDrawBuffers << ":OES_standard_derivatives:" << compileResources.OES_standard_derivatives << ":OES_EGL_image_external:" << compileResources.OES_EGL_image_external << ":ARB_texture_rectangle:" << compileResources.ARB_texture_rectangle << ":EXT_draw_buffers:" << compileResources.EXT_draw_buffers << ":FragmentPrecisionHigh:" << compileResources.FragmentPrecisionHigh << ":MaxExpressionComplexity:" << compileResources.MaxExpressionComplexity << ":MaxCallStackDepth:" << compileResources.MaxCallStackDepth << ":EXT_blend_func_extended:" << compileResources.EXT_blend_func_extended << ":EXT_frag_depth:" << compileResources.EXT_frag_depth << ":EXT_shader_texture_lod:" << compileResources.EXT_shader_texture_lod << ":EXT_shader_framebuffer_fetch:" << compileResources.EXT_shader_framebuffer_fetch << ":NV_shader_framebuffer_fetch:" << compileResources.NV_shader_framebuffer_fetch << ":ARM_shader_framebuffer_fetch:" << compileResources.ARM_shader_framebuffer_fetch << ":MaxVertexOutputVectors:" << compileResources.MaxVertexOutputVectors << ":MaxFragmentInputVectors:" << compileResources.MaxFragmentInputVectors << ":MinProgramTexelOffset:" << compileResources.MinProgramTexelOffset << ":MaxProgramTexelOffset:" << compileResources.MaxProgramTexelOffset << ":MaxDualSourceDrawBuffers:" << compileResources.MaxDualSourceDrawBuffers << ":NV_draw_buffers:" << compileResources.NV_draw_buffers << ":WEBGL_debug_shader_precision:" << compileResources.WEBGL_debug_shader_precision; builtInResourcesString = strstream.str(); } void TCompiler::clearResults() { infoSink.info.erase(); infoSink.obj.erase(); infoSink.debug.erase(); builtInFunctionEmulator.Cleanup(); nameMap.clear(); mSourcePath = NULL; } bool TCompiler::initCallDag(TIntermNode *root) { mCallDag.clear(); switch (mCallDag.init(root, &infoSink.info)) { case CallDAG::INITDAG_SUCCESS: return true; case CallDAG::INITDAG_RECURSION: infoSink.info.prefix(EPrefixError); infoSink.info << "Function recursion detected"; return false; case CallDAG::INITDAG_UNDEFINED: infoSink.info.prefix(EPrefixError); infoSink.info << "Unimplemented function detected"; return false; } UNREACHABLE(); return true; } bool TCompiler::tagUsedFunctions() { // Search from main, starting from the end of the DAG as it usually is the root. for (size_t i = mCallDag.size(); i-- > 0;) { if (mCallDag.getRecordFromIndex(i).name == "main(") { internalTagUsedFunction(i); return true; } } infoSink.info.prefix(EPrefixError); infoSink.info << "Missing main()"; return false; } void TCompiler::internalTagUsedFunction(size_t index) { if (functionMetadata[index].used) { return; } functionMetadata[index].used = true; for (int calleeIndex : mCallDag.getRecordFromIndex(index).callees) { internalTagUsedFunction(calleeIndex); } } // A predicate for the stl that returns if a top-level node is unused class TCompiler::UnusedPredicate { public: UnusedPredicate(const CallDAG *callDag, const std::vector *metadatas) : mCallDag(callDag), mMetadatas(metadatas) { } bool operator ()(TIntermNode *node) { const TIntermAggregate *asAggregate = node->getAsAggregate(); if (asAggregate == nullptr) { return false; } if (!(asAggregate->getOp() == EOpFunction || asAggregate->getOp() == EOpPrototype)) { return false; } size_t callDagIndex = mCallDag->findIndex(asAggregate); if (callDagIndex == CallDAG::InvalidIndex) { // This happens only for unimplemented prototypes which are thus unused ASSERT(asAggregate->getOp() == EOpPrototype); return true; } ASSERT(callDagIndex < mMetadatas->size()); return !(*mMetadatas)[callDagIndex].used; } private: const CallDAG *mCallDag; const std::vector *mMetadatas; }; bool TCompiler::validateOutputs(TIntermNode* root) { ValidateOutputs validateOutputs(getExtensionBehavior(), compileResources.MaxDrawBuffers); root->traverse(&validateOutputs); return (validateOutputs.validateAndCountErrors(infoSink.info) == 0); } const TExtensionBehavior& TCompiler::getExtensionBehavior() const { return extensionBehavior; } const char *TCompiler::getSourcePath() const { return mSourcePath; } const ShBuiltInResources& TCompiler::getResources() const { return compileResources; } const BuiltInFunctionEmulator& TCompiler::getBuiltInFunctionEmulator() const { return builtInFunctionEmulator; } void TCompiler::writePragma() { TInfoSinkBase &sink = infoSink.obj; if (mPragma.stdgl.invariantAll) sink << "#pragma STDGL invariant(all)\n"; } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/Compiler.h000066400000000000000000000131711321746453100266520ustar00rootroot00000000000000// // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_COMPILER_H_ #define COMPILER_TRANSLATOR_COMPILER_H_ // // Machine independent part of the compiler private objects // sent as ShHandle to the driver. // // This should not be included by driver code. // #include "compiler/translator/BuiltInFunctionEmulator.h" #include "compiler/translator/CallDAG.h" #include "compiler/translator/ExtensionBehavior.h" #include "compiler/translator/HashNames.h" #include "compiler/translator/InfoSink.h" #include "compiler/translator/Pragma.h" #include "compiler/translator/SymbolTable.h" class TCompiler; // // The base class used to back handles returned to the driver. // class TShHandleBase { public: TShHandleBase(); virtual ~TShHandleBase(); virtual TCompiler* getAsCompiler() { return 0; } protected: // Memory allocator. Allocates and tracks memory required by the compiler. // Deallocates all memory when compiler is destructed. TPoolAllocator allocator; }; // // The base class for the machine dependent compiler to derive from // for managing object code from the compile. // class TCompiler : public TShHandleBase { public: TCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output); virtual ~TCompiler(); virtual TCompiler* getAsCompiler() { return this; } bool Init(const ShBuiltInResources& resources); // compileTreeForTesting should be used only when tests require access to // the AST. Users of this function need to manually manage the global pool // allocator. Returns NULL whenever there are compilation errors. TIntermNode *compileTreeForTesting(const char* const shaderStrings[], size_t numStrings, int compileOptions); bool compile(const char* const shaderStrings[], size_t numStrings, int compileOptions); // Get results of the last compilation. int getShaderVersion() const { return shaderVersion; } TInfoSink& getInfoSink() { return infoSink; } // Clears the results from the previous compilation. void clearResults(); ShHashFunction64 getHashFunction() const { return hashFunction; } NameMap& getNameMap() { return nameMap; } TSymbolTable& getSymbolTable() { return symbolTable; } ShShaderSpec getShaderSpec() const { return shaderSpec; } ShShaderOutput getOutputType() const { return outputType; } const std::string &getBuiltInResourcesString() const { return builtInResourcesString; } // Get the resources set by InitBuiltInSymbolTable const ShBuiltInResources& getResources() const; protected: sh::GLenum getShaderType() const { return shaderType; } // Initialize symbol-table with built-in symbols. bool InitBuiltInSymbolTable(const ShBuiltInResources& resources); // Compute the string representation of the built-in resources void setResourceString(); // Returns true if a program has no conflicting or missing fragment outputs bool validateOutputs(TIntermNode* root); // Add emulated functions to the built-in function emulator. virtual void initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu, int compileOptions) {}; // Translate to object code. virtual void translate(TIntermNode *root, int compileOptions) = 0; // Get built-in extensions with default behavior. const TExtensionBehavior& getExtensionBehavior() const; const char *getSourcePath() const; const TPragma& getPragma() const { return mPragma; } void writePragma(); const BuiltInFunctionEmulator& getBuiltInFunctionEmulator() const; private: // Creates the function call DAG for further analysis, returning false if there is a recursion bool initCallDag(TIntermNode *root); // Return false if "main" doesn't exist bool tagUsedFunctions(); void internalTagUsedFunction(size_t index); // Removes unused function declarations and prototypes from the AST class UnusedPredicate; TIntermNode *compileTreeImpl(const char* const shaderStrings[], size_t numStrings, int compileOptions); sh::GLenum shaderType; ShShaderSpec shaderSpec; ShShaderOutput outputType; struct FunctionMetadata { FunctionMetadata() : used(false) { } bool used; }; CallDAG mCallDag; std::vector functionMetadata; int maxUniformVectors; int maxExpressionComplexity; int maxCallStackDepth; ShBuiltInResources compileResources; std::string builtInResourcesString; // Built-in symbol table for the given language, spec, and resources. // It is preserved from compile-to-compile. TSymbolTable symbolTable; // Built-in extensions with default behavior. TExtensionBehavior extensionBehavior; bool fragmentPrecisionHigh; BuiltInFunctionEmulator builtInFunctionEmulator; // Results of compilation. int shaderVersion; TInfoSink infoSink; // Output sink. const char *mSourcePath; // Path of source file or NULL // name hashing. ShHashFunction64 hashFunction; NameMap nameMap; TPragma mPragma; }; // // This is the interface between the machine independent code // and the machine dependent code. // // The machine dependent code should derive from the classes // above. Then Construct*() and Delete*() will create and // destroy the machine dependent objects, which contain the // above machine independent information. // TCompiler* ConstructCompiler( sh::GLenum type, ShShaderSpec spec, ShShaderOutput output); void DeleteCompiler(TCompiler*); #endif // COMPILER_TRANSLATOR_COMPILER_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/ConstantUnion.h000066400000000000000000000257051321746453100277100ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_CONSTANTUNION_H_ #define COMPILER_TRANSLATOR_CONSTANTUNION_H_ #include #include "compiler/translator/BaseTypes.h" class TConstantUnion { public: POOL_ALLOCATOR_NEW_DELETE(); TConstantUnion() { iConst = 0; type = EbtVoid; } bool cast(TBasicType newType, const TConstantUnion &constant) { switch (newType) { case EbtFloat: switch (constant.type) { case EbtInt: setFConst(static_cast(constant.getIConst())); break; case EbtUInt: setFConst(static_cast(constant.getUConst())); break; case EbtBool: setFConst(static_cast(constant.getBConst())); break; case EbtFloat: setFConst(static_cast(constant.getFConst())); break; default: return false; } break; case EbtInt: switch (constant.type) { case EbtInt: setIConst(static_cast(constant.getIConst())); break; case EbtUInt: setIConst(static_cast(constant.getUConst())); break; case EbtBool: setIConst(static_cast(constant.getBConst())); break; case EbtFloat: setIConst(static_cast(constant.getFConst())); break; default: return false; } break; case EbtUInt: switch (constant.type) { case EbtInt: setUConst(static_cast(constant.getIConst())); break; case EbtUInt: setUConst(static_cast(constant.getUConst())); break; case EbtBool: setUConst(static_cast(constant.getBConst())); break; case EbtFloat: setUConst(static_cast(constant.getFConst())); break; default: return false; } break; case EbtBool: switch (constant.type) { case EbtInt: setBConst(constant.getIConst() != 0); break; case EbtUInt: setBConst(constant.getUConst() != 0); break; case EbtBool: setBConst(constant.getBConst()); break; case EbtFloat: setBConst(constant.getFConst() != 0.0f); break; default: return false; } break; case EbtStruct: // Struct fields don't get cast switch (constant.type) { case EbtInt: setIConst(constant.getIConst()); break; case EbtUInt: setUConst(constant.getUConst()); break; case EbtBool: setBConst(constant.getBConst()); break; case EbtFloat: setFConst(constant.getFConst()); break; default: return false; } break; default: return false; } return true; } void setIConst(int i) {iConst = i; type = EbtInt; } void setUConst(unsigned int u) { uConst = u; type = EbtUInt; } void setFConst(float f) {fConst = f; type = EbtFloat; } void setBConst(bool b) {bConst = b; type = EbtBool; } int getIConst() const { return iConst; } unsigned int getUConst() const { return uConst; } float getFConst() const { return fConst; } bool getBConst() const { return bConst; } bool operator==(const int i) const { return i == iConst; } bool operator==(const unsigned int u) const { return u == uConst; } bool operator==(const float f) const { return f == fConst; } bool operator==(const bool b) const { return b == bConst; } bool operator==(const TConstantUnion& constant) const { if (constant.type != type) return false; switch (type) { case EbtInt: return constant.iConst == iConst; case EbtUInt: return constant.uConst == uConst; case EbtFloat: return constant.fConst == fConst; case EbtBool: return constant.bConst == bConst; default: return false; } } bool operator!=(const int i) const { return !operator==(i); } bool operator!=(const unsigned int u) const { return !operator==(u); } bool operator!=(const float f) const { return !operator==(f); } bool operator!=(const bool b) const { return !operator==(b); } bool operator!=(const TConstantUnion& constant) const { return !operator==(constant); } bool operator>(const TConstantUnion& constant) const { assert(type == constant.type); switch (type) { case EbtInt: return iConst > constant.iConst; case EbtUInt: return uConst > constant.uConst; case EbtFloat: return fConst > constant.fConst; default: return false; // Invalid operation, handled at semantic analysis } } bool operator<(const TConstantUnion& constant) const { assert(type == constant.type); switch (type) { case EbtInt: return iConst < constant.iConst; case EbtUInt: return uConst < constant.uConst; case EbtFloat: return fConst < constant.fConst; default: return false; // Invalid operation, handled at semantic analysis } } TConstantUnion operator+(const TConstantUnion& constant) const { TConstantUnion returnValue; assert(type == constant.type); switch (type) { case EbtInt: returnValue.setIConst(iConst + constant.iConst); break; case EbtUInt: returnValue.setUConst(uConst + constant.uConst); break; case EbtFloat: returnValue.setFConst(fConst + constant.fConst); break; default: assert(false && "Default missing"); } return returnValue; } TConstantUnion operator-(const TConstantUnion& constant) const { TConstantUnion returnValue; assert(type == constant.type); switch (type) { case EbtInt: returnValue.setIConst(iConst - constant.iConst); break; case EbtUInt: returnValue.setUConst(uConst - constant.uConst); break; case EbtFloat: returnValue.setFConst(fConst - constant.fConst); break; default: assert(false && "Default missing"); } return returnValue; } TConstantUnion operator*(const TConstantUnion& constant) const { TConstantUnion returnValue; assert(type == constant.type); switch (type) { case EbtInt: returnValue.setIConst(iConst * constant.iConst); break; case EbtUInt: returnValue.setUConst(uConst * constant.uConst); break; case EbtFloat: returnValue.setFConst(fConst * constant.fConst); break; default: assert(false && "Default missing"); } return returnValue; } TConstantUnion operator%(const TConstantUnion& constant) const { TConstantUnion returnValue; assert(type == constant.type); switch (type) { case EbtInt: returnValue.setIConst(iConst % constant.iConst); break; case EbtUInt: returnValue.setUConst(uConst % constant.uConst); break; default: assert(false && "Default missing"); } return returnValue; } TConstantUnion operator>>(const TConstantUnion& constant) const { TConstantUnion returnValue; assert(type == constant.type); switch (type) { case EbtInt: returnValue.setIConst(iConst >> constant.iConst); break; case EbtUInt: returnValue.setUConst(uConst >> constant.uConst); break; default: assert(false && "Default missing"); } return returnValue; } TConstantUnion operator<<(const TConstantUnion& constant) const { TConstantUnion returnValue; // The signedness of the second parameter might be different, but we // don't care, since the result is undefined if the second parameter is // negative, and aliasing should not be a problem with unions. assert(constant.type == EbtInt || constant.type == EbtUInt); switch (type) { case EbtInt: returnValue.setIConst(iConst << constant.iConst); break; case EbtUInt: returnValue.setUConst(uConst << constant.uConst); break; default: assert(false && "Default missing"); } return returnValue; } TConstantUnion operator&(const TConstantUnion& constant) const { TConstantUnion returnValue; assert(constant.type == EbtInt || constant.type == EbtUInt); switch (type) { case EbtInt: returnValue.setIConst(iConst & constant.iConst); break; case EbtUInt: returnValue.setUConst(uConst & constant.uConst); break; default: assert(false && "Default missing"); } return returnValue; } TConstantUnion operator|(const TConstantUnion& constant) const { TConstantUnion returnValue; assert(type == constant.type); switch (type) { case EbtInt: returnValue.setIConst(iConst | constant.iConst); break; case EbtUInt: returnValue.setUConst(uConst | constant.uConst); break; default: assert(false && "Default missing"); } return returnValue; } TConstantUnion operator^(const TConstantUnion& constant) const { TConstantUnion returnValue; assert(type == constant.type); switch (type) { case EbtInt: returnValue.setIConst(iConst ^ constant.iConst); break; case EbtUInt: returnValue.setUConst(uConst ^ constant.uConst); break; default: assert(false && "Default missing"); } return returnValue; } TConstantUnion operator&&(const TConstantUnion& constant) const { TConstantUnion returnValue; assert(type == constant.type); switch (type) { case EbtBool: returnValue.setBConst(bConst && constant.bConst); break; default: assert(false && "Default missing"); } return returnValue; } TConstantUnion operator||(const TConstantUnion& constant) const { TConstantUnion returnValue; assert(type == constant.type); switch (type) { case EbtBool: returnValue.setBConst(bConst || constant.bConst); break; default: assert(false && "Default missing"); } return returnValue; } TBasicType getType() const { return type; } private: union { int iConst; // used for ivec, scalar ints unsigned int uConst; // used for uvec, scalar uints bool bConst; // used for bvec, scalar bools float fConst; // used for vec, mat, scalar floats } ; TBasicType type; }; #endif // COMPILER_TRANSLATOR_CONSTANTUNION_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/Diagnostics.cpp000066400000000000000000000030021321746453100276720ustar00rootroot00000000000000// // Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/Diagnostics.h" #include "common/debug.h" #include "compiler/translator/InfoSink.h" #include "compiler/preprocessor/SourceLocation.h" TDiagnostics::TDiagnostics(TInfoSink& infoSink) : mInfoSink(infoSink), mNumErrors(0), mNumWarnings(0) { } TDiagnostics::~TDiagnostics() { } void TDiagnostics::writeInfo(Severity severity, const pp::SourceLocation& loc, const std::string& reason, const std::string& token, const std::string& extra) { TPrefixType prefix = EPrefixNone; switch (severity) { case PP_ERROR: ++mNumErrors; prefix = EPrefixError; break; case PP_WARNING: ++mNumWarnings; prefix = EPrefixWarning; break; default: UNREACHABLE(); break; } TInfoSinkBase& sink = mInfoSink.info; /* VC++ format: file(linenum) : error #: 'token' : extrainfo */ sink.prefix(prefix); sink.location(loc.file, loc.line); sink << "'" << token << "' : " << reason << " " << extra << "\n"; } void TDiagnostics::print(ID id, const pp::SourceLocation& loc, const std::string& text) { writeInfo(severity(id), loc, message(id), text, ""); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/Diagnostics.h000066400000000000000000000022251321746453100273450ustar00rootroot00000000000000// // Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_DIAGNOSTICS_H_ #define COMPILER_TRANSLATOR_DIAGNOSTICS_H_ #include "common/angleutils.h" #include "compiler/preprocessor/DiagnosticsBase.h" class TInfoSink; class TDiagnostics : public pp::Diagnostics, angle::NonCopyable { public: TDiagnostics(TInfoSink& infoSink); virtual ~TDiagnostics(); TInfoSink& infoSink() { return mInfoSink; } int numErrors() const { return mNumErrors; } int numWarnings() const { return mNumWarnings; } void writeInfo(Severity severity, const pp::SourceLocation& loc, const std::string& reason, const std::string& token, const std::string& extra); protected: virtual void print(ID id, const pp::SourceLocation& loc, const std::string& text); private: TInfoSink& mInfoSink; int mNumErrors; int mNumWarnings; }; #endif // COMPILER_TRANSLATOR_DIAGNOSTICS_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/DirectiveHandler.cpp000066400000000000000000000133001321746453100306410ustar00rootroot00000000000000// // Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/DirectiveHandler.h" #include #include "common/debug.h" #include "compiler/translator/Diagnostics.h" static TBehavior getBehavior(const std::string& str) { const char kRequire[] = "require"; const char kEnable[] = "enable"; const char kDisable[] = "disable"; const char kWarn[] = "warn"; if (str == kRequire) return EBhRequire; else if (str == kEnable) return EBhEnable; else if (str == kDisable) return EBhDisable; else if (str == kWarn) return EBhWarn; return EBhUndefined; } TDirectiveHandler::TDirectiveHandler(TExtensionBehavior& extBehavior, TDiagnostics& diagnostics, int& shaderVersion, bool debugShaderPrecisionSupported) : mExtensionBehavior(extBehavior), mDiagnostics(diagnostics), mShaderVersion(shaderVersion), mDebugShaderPrecisionSupported(debugShaderPrecisionSupported) { } TDirectiveHandler::~TDirectiveHandler() { } void TDirectiveHandler::handleError(const pp::SourceLocation& loc, const std::string& msg) { mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, msg, "", ""); } void TDirectiveHandler::handlePragma(const pp::SourceLocation& loc, const std::string& name, const std::string& value, bool stdgl) { if (stdgl) { const char kInvariant[] = "invariant"; const char kAll[] = "all"; if (name == kInvariant && value == kAll) mPragma.stdgl.invariantAll = true; // The STDGL pragma is used to reserve pragmas for use by future // revisions of GLSL. Do not generate an error on unexpected // name and value. return; } else { const char kOptimize[] = "optimize"; const char kDebug[] = "debug"; const char kDebugShaderPrecision[] = "webgl_debug_shader_precision"; const char kOn[] = "on"; const char kOff[] = "off"; bool invalidValue = false; if (name == kOptimize) { if (value == kOn) mPragma.optimize = true; else if (value == kOff) mPragma.optimize = false; else invalidValue = true; } else if (name == kDebug) { if (value == kOn) mPragma.debug = true; else if (value == kOff) mPragma.debug = false; else invalidValue = true; } else if (name == kDebugShaderPrecision && mDebugShaderPrecisionSupported) { if (value == kOn) mPragma.debugShaderPrecision = true; else if (value == kOff) mPragma.debugShaderPrecision = false; else invalidValue = true; } else { mDiagnostics.report(pp::Diagnostics::PP_UNRECOGNIZED_PRAGMA, loc, name); return; } if (invalidValue) { mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "invalid pragma value", value, "'on' or 'off' expected"); } } } void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc, const std::string& name, const std::string& behavior) { const char kExtAll[] = "all"; TBehavior behaviorVal = getBehavior(behavior); if (behaviorVal == EBhUndefined) { mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "behavior", name, "invalid"); return; } if (name == kExtAll) { if (behaviorVal == EBhRequire) { mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "extension", name, "cannot have 'require' behavior"); } else if (behaviorVal == EBhEnable) { mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "extension", name, "cannot have 'enable' behavior"); } else { for (TExtensionBehavior::iterator iter = mExtensionBehavior.begin(); iter != mExtensionBehavior.end(); ++iter) iter->second = behaviorVal; } return; } TExtensionBehavior::iterator iter = mExtensionBehavior.find(name); if (iter != mExtensionBehavior.end()) { iter->second = behaviorVal; return; } pp::Diagnostics::Severity severity = pp::Diagnostics::PP_ERROR; switch (behaviorVal) { case EBhRequire: severity = pp::Diagnostics::PP_ERROR; break; case EBhEnable: case EBhWarn: case EBhDisable: severity = pp::Diagnostics::PP_WARNING; break; default: UNREACHABLE(); break; } mDiagnostics.writeInfo(severity, loc, "extension", name, "is not supported"); } void TDirectiveHandler::handleVersion(const pp::SourceLocation& loc, int version) { if (version == 100 || version == 300) { mShaderVersion = version; } else { std::stringstream stream; stream << version; std::string str = stream.str(); mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "version number", str, "not supported"); } } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/DirectiveHandler.h000066400000000000000000000034101321746453100303070ustar00rootroot00000000000000// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_DIRECTIVEHANDLER_H_ #define COMPILER_TRANSLATOR_DIRECTIVEHANDLER_H_ #include "common/angleutils.h" #include "compiler/translator/ExtensionBehavior.h" #include "compiler/translator/Pragma.h" #include "compiler/preprocessor/DirectiveHandlerBase.h" class TDiagnostics; class TDirectiveHandler : public pp::DirectiveHandler, angle::NonCopyable { public: TDirectiveHandler(TExtensionBehavior& extBehavior, TDiagnostics& diagnostics, int& shaderVersion, bool debugShaderPrecisionSupported); virtual ~TDirectiveHandler(); const TPragma& pragma() const { return mPragma; } const TExtensionBehavior& extensionBehavior() const { return mExtensionBehavior; } virtual void handleError(const pp::SourceLocation& loc, const std::string& msg); virtual void handlePragma(const pp::SourceLocation& loc, const std::string& name, const std::string& value, bool stdgl); virtual void handleExtension(const pp::SourceLocation& loc, const std::string& name, const std::string& behavior); virtual void handleVersion(const pp::SourceLocation& loc, int version); private: TPragma mPragma; TExtensionBehavior& mExtensionBehavior; TDiagnostics& mDiagnostics; int& mShaderVersion; bool mDebugShaderPrecisionSupported; }; #endif // COMPILER_TRANSLATOR_DIRECTIVEHANDLER_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/EmulatePrecision.cpp000066400000000000000000000414151321746453100307050ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/EmulatePrecision.h" namespace { static void writeVectorPrecisionEmulationHelpers( TInfoSinkBase& sink, ShShaderOutput outputLanguage, unsigned int size) { std::stringstream vecTypeStrStr; vecTypeStrStr << "vec" << size; std::string vecType = vecTypeStrStr.str(); sink << vecType << " angle_frm(in " << vecType << " v) {\n" " v = clamp(v, -65504.0, 65504.0);\n" " " << vecType << " exponent = floor(log2(abs(v) + 1e-30)) - 10.0;\n" " bvec" << size << " isNonZero = greaterThanEqual(exponent, vec" << size << "(-25.0));\n" " v = v * exp2(-exponent);\n" " v = sign(v) * floor(abs(v));\n" " return v * exp2(exponent) * vec" << size << "(isNonZero);\n" "}\n"; sink << vecType << " angle_frl(in " << vecType << " v) {\n" " v = clamp(v, -2.0, 2.0);\n" " v = v * 256.0;\n" " v = sign(v) * floor(abs(v));\n" " return v * 0.00390625;\n" "}\n"; } static void writeMatrixPrecisionEmulationHelper( TInfoSinkBase& sink, ShShaderOutput outputLanguage, unsigned int size, const char *functionName) { std::stringstream matTypeStrStr; matTypeStrStr << "mat" << size; std::string matType = matTypeStrStr.str(); sink << matType << " " << functionName << "(in " << matType << " m) {\n" " " << matType << " rounded;\n"; for (unsigned int i = 0; i < size; ++i) { sink << " rounded[" << i << "] = " << functionName << "(m[" << i << "]);\n"; } sink << " return rounded;\n" "}\n"; } static void writeCommonPrecisionEmulationHelpers(TInfoSinkBase& sink, ShShaderOutput outputLanguage) { // Write the angle_frm functions that round floating point numbers to // half precision, and angle_frl functions that round them to minimum lowp // precision. // Unoptimized version of angle_frm for single floats: // // int webgl_maxNormalExponent(in int exponentBits) { // int possibleExponents = int(exp2(float(exponentBits))); // int exponentBias = possibleExponents / 2 - 1; // int allExponentBitsOne = possibleExponents - 1; // return (allExponentBitsOne - 1) - exponentBias; // } // // float angle_frm(in float x) { // int mantissaBits = 10; // int exponentBits = 5; // float possibleMantissas = exp2(float(mantissaBits)); // float mantissaMax = 2.0 - 1.0 / possibleMantissas; // int maxNE = webgl_maxNormalExponent(exponentBits); // float max = exp2(float(maxNE)) * mantissaMax; // if (x > max) { // return max; // } // if (x < -max) { // return -max; // } // float exponent = floor(log2(abs(x))); // if (abs(x) == 0.0 || exponent < -float(maxNE)) { // return 0.0 * sign(x) // } // x = x * exp2(-(exponent - float(mantissaBits))); // x = sign(x) * floor(abs(x)); // return x * exp2(exponent - float(mantissaBits)); // } // All numbers with a magnitude less than 2^-15 are subnormal, and are // flushed to zero. // Note the constant numbers below: // a) 65504 is the maximum possible mantissa (1.1111111111 in binary) times // 2^15, the maximum normal exponent. // b) 10.0 is the number of mantissa bits. // c) -25.0 is the minimum normal half-float exponent -15.0 minus the number // of mantissa bits. // d) + 1e-30 is to make sure the argument of log2() won't be zero. It can // only affect the result of log2 on x where abs(x) < 1e-22. Since these // numbers will be flushed to zero either way (2^-15 is the smallest // normal positive number), this does not introduce any error. std::string floatType = "float"; sink << floatType << " angle_frm(in " << floatType << " x) {\n" " x = clamp(x, -65504.0, 65504.0);\n" " " << floatType << " exponent = floor(log2(abs(x) + 1e-30)) - 10.0;\n" " bool isNonZero = (exponent >= -25.0);\n" " x = x * exp2(-exponent);\n" " x = sign(x) * floor(abs(x));\n" " return x * exp2(exponent) * float(isNonZero);\n" "}\n"; sink << floatType << " angle_frl(in " << floatType << " x) {\n" " x = clamp(x, -2.0, 2.0);\n" " x = x * 256.0;\n" " x = sign(x) * floor(abs(x));\n" " return x * 0.00390625;\n" "}\n"; writeVectorPrecisionEmulationHelpers(sink, outputLanguage, 2); writeVectorPrecisionEmulationHelpers(sink, outputLanguage, 3); writeVectorPrecisionEmulationHelpers(sink, outputLanguage, 4); for (unsigned int size = 2; size <= 4; ++size) { writeMatrixPrecisionEmulationHelper(sink, outputLanguage, size, "angle_frm"); writeMatrixPrecisionEmulationHelper(sink, outputLanguage, size, "angle_frl"); } } static void writeCompoundAssignmentPrecisionEmulation( TInfoSinkBase& sink, ShShaderOutput outputLanguage, const char *lType, const char *rType, const char *opStr, const char *opNameStr) { std::string lTypeStr = lType; std::string rTypeStr = rType; // Note that y should be passed through angle_frm at the function call site, // but x can't be passed through angle_frm there since it is an inout parameter. // So only pass x and the result through angle_frm here. sink << lTypeStr << " angle_compound_" << opNameStr << "_frm(inout " << lTypeStr << " x, in " << rTypeStr << " y) {\n" " x = angle_frm(angle_frm(x) " << opStr << " y);\n" " return x;\n" "}\n"; sink << lTypeStr << " angle_compound_" << opNameStr << "_frl(inout " << lTypeStr << " x, in " << rTypeStr << " y) {\n" " x = angle_frl(angle_frm(x) " << opStr << " y);\n" " return x;\n" "}\n"; } const char *getFloatTypeStr(const TType& type) { switch (type.getNominalSize()) { case 1: return "float"; case 2: switch(type.getSecondarySize()) { case 1: return "vec2"; case 2: return "mat2"; case 3: return "mat2x3"; case 4: return "mat2x4"; default: UNREACHABLE(); return NULL; } case 3: switch(type.getSecondarySize()) { case 1: return "vec3"; case 2: return "mat3x2"; case 3: return "mat3"; case 4: return "mat3x4"; default: UNREACHABLE(); return NULL; } case 4: switch(type.getSecondarySize()) { case 1: return "vec4"; case 2: return "mat4x2"; case 3: return "mat4x3"; case 4: return "mat4"; default: UNREACHABLE(); return NULL; } default: UNREACHABLE(); return NULL; } } bool canRoundFloat(const TType &type) { return type.getBasicType() == EbtFloat && !type.isNonSquareMatrix() && !type.isArray() && (type.getPrecision() == EbpLow || type.getPrecision() == EbpMedium); } TIntermAggregate *createInternalFunctionCallNode(TString name, TIntermNode *child) { TIntermAggregate *callNode = new TIntermAggregate(); callNode->setOp(EOpFunctionCall); TName nameObj(TFunction::mangleName(name)); nameObj.setInternal(true); callNode->setNameObj(nameObj); callNode->getSequence()->push_back(child); return callNode; } TIntermAggregate *createRoundingFunctionCallNode(TIntermTyped *roundedChild) { TString roundFunctionName; if (roundedChild->getPrecision() == EbpMedium) roundFunctionName = "angle_frm"; else roundFunctionName = "angle_frl"; return createInternalFunctionCallNode(roundFunctionName, roundedChild); } TIntermAggregate *createCompoundAssignmentFunctionCallNode(TIntermTyped *left, TIntermTyped *right, const char *opNameStr) { std::stringstream strstr; if (left->getPrecision() == EbpMedium) strstr << "angle_compound_" << opNameStr << "_frm"; else strstr << "angle_compound_" << opNameStr << "_frl"; TString functionName = strstr.str().c_str(); TIntermAggregate *callNode = createInternalFunctionCallNode(functionName, left); callNode->getSequence()->push_back(right); return callNode; } bool parentUsesResult(TIntermNode* parent, TIntermNode* node) { if (!parent) { return false; } TIntermAggregate *aggParent = parent->getAsAggregate(); // If the parent's op is EOpSequence, the result is not assigned anywhere, // so rounding it is not needed. In particular, this can avoid a lot of // unnecessary rounding of unused return values of assignment. if (aggParent && aggParent->getOp() == EOpSequence) { return false; } if (aggParent && aggParent->getOp() == EOpComma && (aggParent->getSequence()->back() != node)) { return false; } return true; } } // namespace anonymous EmulatePrecision::EmulatePrecision(const TSymbolTable &symbolTable, int shaderVersion) : TLValueTrackingTraverser(true, true, true, symbolTable, shaderVersion), mDeclaringVariables(false) {} void EmulatePrecision::visitSymbol(TIntermSymbol *node) { if (canRoundFloat(node->getType()) && !mDeclaringVariables && !isLValueRequiredHere()) { TIntermNode *parent = getParentNode(); TIntermNode *replacement = createRoundingFunctionCallNode(node); mReplacements.push_back(NodeUpdateEntry(parent, node, replacement, true)); } } bool EmulatePrecision::visitBinary(Visit visit, TIntermBinary *node) { bool visitChildren = true; TOperator op = node->getOp(); // RHS of initialize is not being declared. if (op == EOpInitialize && visit == InVisit) mDeclaringVariables = false; if ((op == EOpIndexDirectStruct || op == EOpVectorSwizzle) && visit == InVisit) visitChildren = false; if (visit != PreVisit) return visitChildren; const TType& type = node->getType(); bool roundFloat = canRoundFloat(type); if (roundFloat) { switch (op) { // Math operators that can result in a float may need to apply rounding to the return // value. Note that in the case of assignment, the rounding is applied to its return // value here, not the value being assigned. case EOpAssign: case EOpAdd: case EOpSub: case EOpMul: case EOpDiv: case EOpVectorTimesScalar: case EOpVectorTimesMatrix: case EOpMatrixTimesVector: case EOpMatrixTimesScalar: case EOpMatrixTimesMatrix: { TIntermNode *parent = getParentNode(); if (!parentUsesResult(parent, node)) { break; } TIntermNode *replacement = createRoundingFunctionCallNode(node); mReplacements.push_back(NodeUpdateEntry(parent, node, replacement, true)); break; } // Compound assignment cases need to replace the operator with a function call. case EOpAddAssign: { mEmulateCompoundAdd.insert(TypePair(getFloatTypeStr(type), getFloatTypeStr(node->getRight()->getType()))); TIntermNode *parent = getParentNode(); TIntermNode *replacement = createCompoundAssignmentFunctionCallNode(node->getLeft(), node->getRight(), "add"); mReplacements.push_back(NodeUpdateEntry(parent, node, replacement, false)); break; } case EOpSubAssign: { mEmulateCompoundSub.insert(TypePair(getFloatTypeStr(type), getFloatTypeStr(node->getRight()->getType()))); TIntermNode *parent = getParentNode(); TIntermNode *replacement = createCompoundAssignmentFunctionCallNode(node->getLeft(), node->getRight(), "sub"); mReplacements.push_back(NodeUpdateEntry(parent, node, replacement, false)); break; } case EOpMulAssign: case EOpVectorTimesMatrixAssign: case EOpVectorTimesScalarAssign: case EOpMatrixTimesScalarAssign: case EOpMatrixTimesMatrixAssign: { mEmulateCompoundMul.insert(TypePair(getFloatTypeStr(type), getFloatTypeStr(node->getRight()->getType()))); TIntermNode *parent = getParentNode(); TIntermNode *replacement = createCompoundAssignmentFunctionCallNode(node->getLeft(), node->getRight(), "mul"); mReplacements.push_back(NodeUpdateEntry(parent, node, replacement, false)); break; } case EOpDivAssign: { mEmulateCompoundDiv.insert(TypePair(getFloatTypeStr(type), getFloatTypeStr(node->getRight()->getType()))); TIntermNode *parent = getParentNode(); TIntermNode *replacement = createCompoundAssignmentFunctionCallNode(node->getLeft(), node->getRight(), "div"); mReplacements.push_back(NodeUpdateEntry(parent, node, replacement, false)); break; } default: // The rest of the binary operations should not need precision emulation. break; } } return visitChildren; } bool EmulatePrecision::visitAggregate(Visit visit, TIntermAggregate *node) { bool visitChildren = true; switch (node->getOp()) { case EOpSequence: case EOpConstructStruct: case EOpFunction: break; case EOpPrototype: visitChildren = false; break; case EOpParameters: visitChildren = false; break; case EOpInvariantDeclaration: visitChildren = false; break; case EOpDeclaration: // Variable declaration. if (visit == PreVisit) { mDeclaringVariables = true; } else if (visit == InVisit) { mDeclaringVariables = true; } else { mDeclaringVariables = false; } break; case EOpFunctionCall: { // Function call. if (visit == PreVisit) { // User-defined function return values are not rounded, this relies on that // calculations producing the value were rounded. TIntermNode *parent = getParentNode(); if (canRoundFloat(node->getType()) && !isInFunctionMap(node) && parentUsesResult(parent, node)) { TIntermNode *replacement = createRoundingFunctionCallNode(node); mReplacements.push_back(NodeUpdateEntry(parent, node, replacement, true)); } } break; } default: TIntermNode *parent = getParentNode(); if (canRoundFloat(node->getType()) && visit == PreVisit && parentUsesResult(parent, node)) { TIntermNode *replacement = createRoundingFunctionCallNode(node); mReplacements.push_back(NodeUpdateEntry(parent, node, replacement, true)); } break; } return visitChildren; } bool EmulatePrecision::visitUnary(Visit visit, TIntermUnary *node) { switch (node->getOp()) { case EOpNegative: case EOpVectorLogicalNot: case EOpLogicalNot: case EOpPostIncrement: case EOpPostDecrement: case EOpPreIncrement: case EOpPreDecrement: break; default: if (canRoundFloat(node->getType()) && visit == PreVisit) { TIntermNode *parent = getParentNode(); TIntermNode *replacement = createRoundingFunctionCallNode(node); mReplacements.push_back(NodeUpdateEntry(parent, node, replacement, true)); } break; } return true; } void EmulatePrecision::writeEmulationHelpers(TInfoSinkBase& sink, ShShaderOutput outputLanguage) { // Other languages not yet supported ASSERT(outputLanguage == SH_GLSL_COMPATIBILITY_OUTPUT); writeCommonPrecisionEmulationHelpers(sink, outputLanguage); EmulationSet::const_iterator it; for (it = mEmulateCompoundAdd.begin(); it != mEmulateCompoundAdd.end(); it++) writeCompoundAssignmentPrecisionEmulation(sink, outputLanguage, it->lType, it->rType, "+", "add"); for (it = mEmulateCompoundSub.begin(); it != mEmulateCompoundSub.end(); it++) writeCompoundAssignmentPrecisionEmulation(sink, outputLanguage, it->lType, it->rType, "-", "sub"); for (it = mEmulateCompoundDiv.begin(); it != mEmulateCompoundDiv.end(); it++) writeCompoundAssignmentPrecisionEmulation(sink, outputLanguage, it->lType, it->rType, "/", "div"); for (it = mEmulateCompoundMul.begin(); it != mEmulateCompoundMul.end(); it++) writeCompoundAssignmentPrecisionEmulation(sink, outputLanguage, it->lType, it->rType, "*", "mul"); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/EmulatePrecision.h000066400000000000000000000037001321746453100303450ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_EMULATE_PRECISION_H_ #define COMPILER_TRANSLATOR_EMULATE_PRECISION_H_ #include "common/angleutils.h" #include "compiler/translator/Compiler.h" #include "compiler/translator/InfoSink.h" #include "compiler/translator/IntermNode.h" #include "GLSLANG/ShaderLang.h" // This class gathers all compound assignments from the AST and can then write // the functions required for their precision emulation. This way there is no // need to write a huge number of variations of the emulated compound assignment // to every translated shader with emulation enabled. class EmulatePrecision : public TLValueTrackingTraverser { public: EmulatePrecision(const TSymbolTable &symbolTable, int shaderVersion); virtual void visitSymbol(TIntermSymbol *node); virtual bool visitBinary(Visit visit, TIntermBinary *node); virtual bool visitUnary(Visit visit, TIntermUnary *node); virtual bool visitAggregate(Visit visit, TIntermAggregate *node); void writeEmulationHelpers(TInfoSinkBase& sink, ShShaderOutput outputLanguage); private: struct TypePair { TypePair(const char *l, const char *r) : lType(l), rType(r) { } const char *lType; const char *rType; }; struct TypePairComparator { bool operator() (const TypePair& l, const TypePair& r) const { if (l.lType == r.lType) return l.rType < r.rType; return l.lType < r.lType; } }; typedef std::set EmulationSet; EmulationSet mEmulateCompoundAdd; EmulationSet mEmulateCompoundSub; EmulationSet mEmulateCompoundMul; EmulationSet mEmulateCompoundDiv; bool mDeclaringVariables; }; #endif // COMPILER_TRANSLATOR_EMULATE_PRECISION_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/ExtensionBehavior.h000066400000000000000000000021051321746453100305270ustar00rootroot00000000000000// // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_EXTENSIONBEHAVIOR_H_ #define COMPILER_TRANSLATOR_EXTENSIONBEHAVIOR_H_ #include #include typedef enum { EBhRequire, EBhEnable, EBhWarn, EBhDisable, EBhUndefined } TBehavior; inline const char* getBehaviorString(TBehavior b) { switch(b) { case EBhRequire: return "require"; case EBhEnable: return "enable"; case EBhWarn: return "warn"; case EBhDisable: return "disable"; default: return NULL; } } // Mapping between extension name and behavior. typedef std::map TExtensionBehavior; inline bool IsExtensionEnabled(const TExtensionBehavior &extBehavior, const char *extension) { auto iter = extBehavior.find(extension); return iter != extBehavior.end() && (iter->second == EBhEnable || iter->second == EBhRequire); } #endif // COMPILER_TRANSLATOR_EXTENSIONBEHAVIOR_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/HashNames.h000066400000000000000000000007261321746453100267510ustar00rootroot00000000000000// // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_HASHNAMES_H_ #define COMPILER_TRANSLATOR_HASHNAMES_H_ #include #include "compiler/translator/IntermNode.h" #define HASHED_NAME_PREFIX "webgl_" typedef std::map NameMap; #endif // COMPILER_TRANSLATOR_HASHNAMES_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/InfoSink.cpp000066400000000000000000000025271321746453100271560ustar00rootroot00000000000000// // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/InfoSink.h" void TInfoSinkBase::prefix(TPrefixType p) { switch(p) { case EPrefixNone: break; case EPrefixWarning: sink.append("WARNING: "); break; case EPrefixError: sink.append("ERROR: "); break; case EPrefixInternalError: sink.append("INTERNAL ERROR: "); break; case EPrefixUnimplemented: sink.append("UNIMPLEMENTED: "); break; case EPrefixNote: sink.append("NOTE: "); break; default: sink.append("UNKNOWN ERROR: "); break; } } void TInfoSinkBase::location(int file, int line) { TPersistStringStream stream; if (line) stream << file << ":" << line; else stream << file << ":? "; stream << ": "; sink.append(stream.str()); } void TInfoSinkBase::location(const TSourceLoc& loc) { location(loc.first_file, loc.first_line); } void TInfoSinkBase::message(TPrefixType p, const TSourceLoc& loc, const char* m) { prefix(p); location(loc); sink.append(m); sink.append("\n"); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/InfoSink.h000066400000000000000000000062771321746453100266310ustar00rootroot00000000000000// // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_INFOSINK_H_ #define COMPILER_TRANSLATOR_INFOSINK_H_ #include #include #include "compiler/translator/Common.h" // Returns the fractional part of the given floating-point number. inline float fractionalPart(float f) { float intPart = 0.0f; return modff(f, &intPart); } // // TPrefixType is used to centralize how info log messages start. // See below. // enum TPrefixType { EPrefixNone, EPrefixWarning, EPrefixError, EPrefixInternalError, EPrefixUnimplemented, EPrefixNote }; // // Encapsulate info logs for all objects that have them. // // The methods are a general set of tools for getting a variety of // messages and types inserted into the log. // class TInfoSinkBase { public: TInfoSinkBase() {} template TInfoSinkBase& operator<<(const T& t) { TPersistStringStream stream; stream << t; sink.append(stream.str()); return *this; } // Override << operator for specific types. It is faster to append strings // and characters directly to the sink. TInfoSinkBase& operator<<(char c) { sink.append(1, c); return *this; } TInfoSinkBase& operator<<(const char* str) { sink.append(str); return *this; } TInfoSinkBase& operator<<(const TPersistString& str) { sink.append(str); return *this; } TInfoSinkBase& operator<<(const TString& str) { sink.append(str.c_str()); return *this; } // Make sure floats are written with correct precision. TInfoSinkBase& operator<<(float f) { // Make sure that at least one decimal point is written. If a number // does not have a fractional part, the default precision format does // not write the decimal portion which gets interpreted as integer by // the compiler. TPersistStringStream stream; if (fractionalPart(f) == 0.0f) { stream.precision(1); stream << std::showpoint << std::fixed << f; } else { stream.unsetf(std::ios::fixed); stream.unsetf(std::ios::scientific); stream.precision(8); stream << f; } sink.append(stream.str()); return *this; } // Write boolean values as their names instead of integral value. TInfoSinkBase& operator<<(bool b) { const char* str = b ? "true" : "false"; sink.append(str); return *this; } void erase() { sink.clear(); } int size() { return static_cast(sink.size()); } const TPersistString& str() const { return sink; } const char* c_str() const { return sink.c_str(); } void prefix(TPrefixType p); void location(int file, int line); void location(const TSourceLoc& loc); void message(TPrefixType p, const TSourceLoc& loc, const char* m); private: TPersistString sink; }; class TInfoSink { public: TInfoSinkBase info; TInfoSinkBase debug; TInfoSinkBase obj; }; #endif // COMPILER_TRANSLATOR_INFOSINK_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/Initialize.cpp000066400000000000000000001126161321746453100275400ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // // Create symbols that declare built-in definitions, add built-ins that // cannot be expressed in the files, and establish mappings between // built-in functions and operators. // #include "compiler/translator/Initialize.h" #include "compiler/translator/Cache.h" #include "compiler/translator/IntermNode.h" #include "angle_gl.h" void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &symbolTable) { const TType *float1 = TCache::getType(EbtFloat); const TType *float2 = TCache::getType(EbtFloat, 2); const TType *float3 = TCache::getType(EbtFloat, 3); const TType *float4 = TCache::getType(EbtFloat, 4); const TType *int1 = TCache::getType(EbtInt); const TType *int2 = TCache::getType(EbtInt, 2); const TType *int3 = TCache::getType(EbtInt, 3); const TType *uint1 = TCache::getType(EbtUInt); const TType *bool1 = TCache::getType(EbtBool); const TType *genType = TCache::getType(EbtGenType); const TType *genIType = TCache::getType(EbtGenIType); const TType *genUType = TCache::getType(EbtGenUType); const TType *genBType = TCache::getType(EbtGenBType); // // Angle and Trigonometric Functions. // symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpRadians, genType, "radians", genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpDegrees, genType, "degrees", genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSin, genType, "sin", genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpCos, genType, "cos", genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpTan, genType, "tan", genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAsin, genType, "asin", genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAcos, genType, "acos", genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAtan, genType, "atan", genType, genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAtan, genType, "atan", genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpSinh, genType, "sinh", genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpCosh, genType, "cosh", genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTanh, genType, "tanh", genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpAsinh, genType, "asinh", genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpAcosh, genType, "acosh", genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpAtanh, genType, "atanh", genType); // // Exponential Functions. // symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpPow, genType, "pow", genType, genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpExp, genType, "exp", genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLog, genType, "log", genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpExp2, genType, "exp2", genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLog2, genType, "log2", genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSqrt, genType, "sqrt", genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpInverseSqrt, genType, "inversesqrt", genType); // // Common Functions. // symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAbs, genType, "abs", genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpAbs, genIType, "abs", genIType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSign, genType, "sign", genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpSign, genIType, "sign", genIType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpFloor, genType, "floor", genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTrunc, genType, "trunc", genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpRound, genType, "round", genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpRoundEven, genType, "roundEven", genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpCeil, genType, "ceil", genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpFract, genType, "fract", genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMod, genType, "mod", genType, float1); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMod, genType, "mod", genType, genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMin, genType, "min", genType, float1); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMin, genType, "min", genType, genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMin, genIType, "min", genIType, genIType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMin, genIType, "min", genIType, int1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMin, genUType, "min", genUType, genUType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMin, genUType, "min", genUType, uint1); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMax, genType, "max", genType, float1); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMax, genType, "max", genType, genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMax, genIType, "max", genIType, genIType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMax, genIType, "max", genIType, int1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMax, genUType, "max", genUType, genUType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMax, genUType, "max", genUType, uint1); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpClamp, genType, "clamp", genType, float1, float1); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpClamp, genType, "clamp", genType, genType, genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpClamp, genIType, "clamp", genIType, int1, int1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpClamp, genIType, "clamp", genIType, genIType, genIType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpClamp, genUType, "clamp", genUType, uint1, uint1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpClamp, genUType, "clamp", genUType, genUType, genUType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMix, genType, "mix", genType, genType, float1); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMix, genType, "mix", genType, genType, genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMix, genType, "mix", genType, genType, genBType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpStep, genType, "step", genType, genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpStep, genType, "step", float1, genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSmoothStep, genType, "smoothstep", genType, genType, genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSmoothStep, genType, "smoothstep", float1, float1, genType); const TType *outFloat1 = TCache::getType(EbtFloat, EvqOut); const TType *outFloat2 = TCache::getType(EbtFloat, EvqOut, 2); const TType *outFloat3 = TCache::getType(EbtFloat, EvqOut, 3); const TType *outFloat4 = TCache::getType(EbtFloat, EvqOut, 4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpModf, float1, "modf", float1, outFloat1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpModf, float2, "modf", float2, outFloat2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpModf, float3, "modf", float3, outFloat3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpModf, float4, "modf", float4, outFloat4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpIsNan, genBType, "isnan", genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpIsInf, genBType, "isinf", genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpFloatBitsToInt, genIType, "floatBitsToInt", genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpFloatBitsToUint, genUType, "floatBitsToUint", genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpIntBitsToFloat, genType, "intBitsToFloat", genIType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpUintBitsToFloat, genType, "uintBitsToFloat", genUType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpPackSnorm2x16, uint1, "packSnorm2x16", float2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpPackUnorm2x16, uint1, "packUnorm2x16", float2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpPackHalf2x16, uint1, "packHalf2x16", float2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpUnpackSnorm2x16, float2, "unpackSnorm2x16", uint1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpUnpackUnorm2x16, float2, "unpackUnorm2x16", uint1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpUnpackHalf2x16, float2, "unpackHalf2x16", uint1); // // Geometric Functions. // symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLength, float1, "length", genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpDistance, float1, "distance", genType, genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpDot, float1, "dot", genType, genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpCross, float3, "cross", float3, float3); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpNormalize, genType, "normalize", genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpFaceForward, genType, "faceforward", genType, genType, genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpReflect, genType, "reflect", genType, genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpRefract, genType, "refract", genType, genType, float1); const TType *mat2 = TCache::getType(EbtFloat, 2, 2); const TType *mat3 = TCache::getType(EbtFloat, 3, 3); const TType *mat4 = TCache::getType(EbtFloat, 4, 4); const TType *mat2x3 = TCache::getType(EbtFloat, 2, 3); const TType *mat3x2 = TCache::getType(EbtFloat, 3, 2); const TType *mat2x4 = TCache::getType(EbtFloat, 2, 4); const TType *mat4x2 = TCache::getType(EbtFloat, 4, 2); const TType *mat3x4 = TCache::getType(EbtFloat, 3, 4); const TType *mat4x3 = TCache::getType(EbtFloat, 4, 3); // // Matrix Functions. // symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMul, mat2, "matrixCompMult", mat2, mat2); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMul, mat3, "matrixCompMult", mat3, mat3); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMul, mat4, "matrixCompMult", mat4, mat4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat2x3, "matrixCompMult", mat2x3, mat2x3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat3x2, "matrixCompMult", mat3x2, mat3x2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat2x4, "matrixCompMult", mat2x4, mat2x4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat4x2, "matrixCompMult", mat4x2, mat4x2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat3x4, "matrixCompMult", mat3x4, mat3x4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat4x3, "matrixCompMult", mat4x3, mat4x3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat2, "outerProduct", float2, float2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat3, "outerProduct", float3, float3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat4, "outerProduct", float4, float4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat2x3, "outerProduct", float3, float2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat3x2, "outerProduct", float2, float3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat2x4, "outerProduct", float4, float2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat4x2, "outerProduct", float2, float4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat3x4, "outerProduct", float4, float3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat4x3, "outerProduct", float3, float4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat2, "transpose", mat2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat3, "transpose", mat3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat4, "transpose", mat4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat2x3, "transpose", mat3x2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat3x2, "transpose", mat2x3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat2x4, "transpose", mat4x2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat4x2, "transpose", mat2x4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat3x4, "transpose", mat4x3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat4x3, "transpose", mat3x4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDeterminant, float1, "determinant", mat2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDeterminant, float1, "determinant", mat3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDeterminant, float1, "determinant", mat4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpInverse, mat2, "inverse", mat2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpInverse, mat3, "inverse", mat3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpInverse, mat4, "inverse", mat4); const TType *vec = TCache::getType(EbtVec); const TType *ivec = TCache::getType(EbtIVec); const TType *uvec = TCache::getType(EbtUVec); const TType *bvec = TCache::getType(EbtBVec); // // Vector relational functions. // symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThan, bvec, "lessThan", vec, vec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThan, bvec, "lessThan", ivec, ivec); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpLessThan, bvec, "lessThan", uvec, uvec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThanEqual, bvec, "lessThanEqual", vec, vec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThanEqual, bvec, "lessThanEqual", ivec, ivec); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpLessThanEqual, bvec, "lessThanEqual", uvec, uvec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThan, bvec, "greaterThan", vec, vec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThan, bvec, "greaterThan", ivec, ivec); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpGreaterThan, bvec, "greaterThan", uvec, uvec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThanEqual, bvec, "greaterThanEqual", vec, vec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThanEqual, bvec, "greaterThanEqual", ivec, ivec); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpGreaterThanEqual, bvec, "greaterThanEqual", uvec, uvec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorEqual, bvec, "equal", vec, vec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorEqual, bvec, "equal", ivec, ivec); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpVectorEqual, bvec, "equal", uvec, uvec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorEqual, bvec, "equal", bvec, bvec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", vec, vec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", ivec, ivec); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", uvec, uvec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", bvec, bvec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAny, bool1, "any", bvec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAll, bool1, "all", bvec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorLogicalNot, bvec, "not", bvec); const TType *sampler2D = TCache::getType(EbtSampler2D); const TType *samplerCube = TCache::getType(EbtSamplerCube); // // Texture Functions for GLSL ES 1.0 // symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, float2); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float3); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float4); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, float3); if (resources.OES_EGL_image_external) { const TType *samplerExternalOES = TCache::getType(EbtSamplerExternalOES); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", samplerExternalOES, float2); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, float3); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, float4); } if (resources.ARB_texture_rectangle) { const TType *sampler2DRect = TCache::getType(EbtSampler2DRect); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRect", sampler2DRect, float2); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, float3); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, float4); } if (resources.EXT_shader_texture_lod) { /* The *Grad* variants are new to both vertex and fragment shaders; the fragment * shader specific pieces are added separately below. */ symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DGradEXT", sampler2D, float2, float2, float2); symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DProjGradEXT", sampler2D, float3, float2, float2); symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DProjGradEXT", sampler2D, float4, float2, float2); symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "textureCubeGradEXT", samplerCube, float3, float3, float3); } if (type == GL_FRAGMENT_SHADER) { symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, float2, float1); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float3, float1); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float4, float1); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, float3, float1); if (resources.OES_standard_derivatives) { symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpDFdx, "GL_OES_standard_derivatives", genType, "dFdx", genType); symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpDFdy, "GL_OES_standard_derivatives", genType, "dFdy", genType); symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpFwidth, "GL_OES_standard_derivatives", genType, "fwidth", genType); } if (resources.EXT_shader_texture_lod) { symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DLodEXT", sampler2D, float2, float1); symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DProjLodEXT", sampler2D, float3, float1); symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DProjLodEXT", sampler2D, float4, float1); symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "textureCubeLodEXT", samplerCube, float3, float1); } } if (type == GL_VERTEX_SHADER) { symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DLod", sampler2D, float2, float1); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float3, float1); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float4, float1); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeLod", samplerCube, float3, float1); } const TType *gvec4 = TCache::getType(EbtGVec4); const TType *gsampler2D = TCache::getType(EbtGSampler2D); const TType *gsamplerCube = TCache::getType(EbtGSamplerCube); const TType *gsampler3D = TCache::getType(EbtGSampler3D); const TType *gsampler2DArray = TCache::getType(EbtGSampler2DArray); // // Texture Functions for GLSL ES 3.0 // symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2D, float2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler3D, float3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsamplerCube, float3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2DArray, float3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler2D, float2, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler3D, float3, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsamplerCube, float3, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler2DArray, float3, float1); if (type == GL_FRAGMENT_SHADER) { symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2D, float2, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler3D, float3, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsamplerCube, float3, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2DArray, float3, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float3, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float4, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4, float1); } const TType *sampler2DShadow = TCache::getType(EbtSampler2DShadow); const TType *samplerCubeShadow = TCache::getType(EbtSamplerCubeShadow); const TType *sampler2DArrayShadow = TCache::getType(EbtSampler2DArrayShadow); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DArrayShadow, float4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProj", sampler2DShadow, float4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureLod", sampler2DShadow, float3, float1); if (type == GL_FRAGMENT_SHADER) { symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProj", sampler2DShadow, float4, float1); } symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", gsampler2D, int1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", gsampler3D, int1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", gsamplerCube, int1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", gsampler2DArray, int1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", sampler2DShadow, int1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", samplerCubeShadow, int1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", sampler2DArrayShadow, int1); if (type == GL_FRAGMENT_SHADER) { symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDFdx, genType, "dFdx", genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDFdy, genType, "dFdy", genType); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpFwidth, genType, "fwidth", genType); } symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler3D, float3, int3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3, int2); if (type == GL_FRAGMENT_SHADER) { symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler3D, float3, int3, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3, int2, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3, int2, float1); } symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float3, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float4, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4, int3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow, float4, int2); if (type == GL_FRAGMENT_SHADER) { symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float3, int2, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float4, int2, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4, int3, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow, float4, int2, float1); } symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler2D, float2, float1, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler3D, float3, float1, int3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureLodOffset", sampler2DShadow, float3, float1, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler2DArray, float3, float1, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler2D, float3, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler2D, float4, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler3D, float4, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjLod", sampler2DShadow, float4, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler2D, float3, float1, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler2D, float4, float1, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler3D, float4, float1, int3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjLodOffset", sampler2DShadow, float4, float1, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler2D, int2, int1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler3D, int3, int1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler2DArray, int3, int1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler2D, int2, int1, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler3D, int3, int1, int3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler2DArray, int3, int1, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler2D, float2, float2, float2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler3D, float3, float3, float3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsamplerCube, float3, float3, float3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", sampler2DShadow, float3, float2, float2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", samplerCubeShadow, float4, float3, float3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler2DArray, float3, float2, float2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", sampler2DArrayShadow, float4, float2, float2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler2D, float2, float2, float2, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler3D, float3, float3, float3, int3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGradOffset", sampler2DShadow, float3, float2, float2, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler2DArray, float3, float2, float2, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGradOffset", sampler2DArrayShadow, float4, float2, float2, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler2D, float3, float2, float2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler2D, float4, float2, float2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler3D, float4, float3, float3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjGrad", sampler2DShadow, float4, float2, float2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler2D, float3, float2, float2, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler2D, float4, float2, float2, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler3D, float4, float3, float3, int3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjGradOffset", sampler2DShadow, float4, float2, float2, int2); // // Depth range in window coordinates // TFieldList *fields = NewPoolTFieldList(); TSourceLoc zeroSourceLoc = {0, 0, 0, 0}; TField *near = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("near"), zeroSourceLoc); TField *far = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("far"), zeroSourceLoc); TField *diff = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("diff"), zeroSourceLoc); fields->push_back(near); fields->push_back(far); fields->push_back(diff); TStructure *depthRangeStruct = new TStructure(NewPoolTString("gl_DepthRangeParameters"), fields); TVariable *depthRangeParameters = new TVariable(&depthRangeStruct->name(), depthRangeStruct, true); symbolTable.insert(COMMON_BUILTINS, depthRangeParameters); TVariable *depthRange = new TVariable(NewPoolTString("gl_DepthRange"), TType(depthRangeStruct)); depthRange->setQualifier(EvqUniform); symbolTable.insert(COMMON_BUILTINS, depthRange); // // Implementation dependent built-in constants. // symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexAttribs", resources.MaxVertexAttribs); symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexUniformVectors", resources.MaxVertexUniformVectors); symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexTextureImageUnits", resources.MaxVertexTextureImageUnits); symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxCombinedTextureImageUnits", resources.MaxCombinedTextureImageUnits); symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxTextureImageUnits", resources.MaxTextureImageUnits); symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxFragmentUniformVectors", resources.MaxFragmentUniformVectors); symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxVaryingVectors", resources.MaxVaryingVectors); { symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxDrawBuffers", resources.MaxDrawBuffers); if (resources.EXT_blend_func_extended) { symbolTable.insertConstIntExt(COMMON_BUILTINS, "GL_EXT_blend_func_extended", "gl_MaxDualSourceDrawBuffersEXT", resources.MaxDualSourceDrawBuffers); } } symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxVertexOutputVectors", resources.MaxVertexOutputVectors); symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxFragmentInputVectors", resources.MaxFragmentInputVectors); symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MinProgramTexelOffset", resources.MinProgramTexelOffset); symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxProgramTexelOffset", resources.MaxProgramTexelOffset); } void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &symbolTable) { // // Insert some special built-in variables that are not in // the built-in header files. // switch (type) { case GL_FRAGMENT_SHADER: symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EbpMedium, EvqFragCoord, 4))); symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EbpUndefined, EvqFrontFacing, 1))); symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointCoord"), TType(EbtFloat, EbpMedium, EvqPointCoord, 2))); { symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EbpMedium, EvqFragColor, 4))); TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true); fragData.setArraySize(resources.MaxDrawBuffers); symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData"), fragData)); if (resources.EXT_blend_func_extended) { symbolTable.insert( ESSL1_BUILTINS, "GL_EXT_blend_func_extended", new TVariable(NewPoolTString("gl_SecondaryFragColorEXT"), TType(EbtFloat, EbpMedium, EvqSecondaryFragColorEXT, 4))); TType secondaryFragData(EbtFloat, EbpMedium, EvqSecondaryFragDataEXT, 4, 1, true); secondaryFragData.setArraySize(resources.MaxDualSourceDrawBuffers); symbolTable.insert( ESSL1_BUILTINS, "GL_EXT_blend_func_extended", new TVariable(NewPoolTString("gl_SecondaryFragDataEXT"), secondaryFragData)); } if (resources.EXT_frag_depth) { symbolTable.insert(ESSL1_BUILTINS, "GL_EXT_frag_depth", new TVariable(NewPoolTString("gl_FragDepthEXT"), TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepth, 1))); } if (resources.EXT_shader_framebuffer_fetch || resources.NV_shader_framebuffer_fetch) { TType lastFragData(EbtFloat, EbpMedium, EvqLastFragData, 4, 1, true); lastFragData.setArraySize(resources.MaxDrawBuffers); if (resources.EXT_shader_framebuffer_fetch) { symbolTable.insert(ESSL1_BUILTINS, "GL_EXT_shader_framebuffer_fetch", new TVariable(NewPoolTString("gl_LastFragData"), lastFragData)); } else if (resources.NV_shader_framebuffer_fetch) { symbolTable.insert(ESSL1_BUILTINS, "GL_NV_shader_framebuffer_fetch", new TVariable(NewPoolTString("gl_LastFragColor"), TType(EbtFloat, EbpMedium, EvqLastFragColor, 4))); symbolTable.insert(ESSL1_BUILTINS, "GL_NV_shader_framebuffer_fetch", new TVariable(NewPoolTString("gl_LastFragData"), lastFragData)); } } else if (resources.ARM_shader_framebuffer_fetch) { symbolTable.insert(ESSL1_BUILTINS, "GL_ARM_shader_framebuffer_fetch", new TVariable(NewPoolTString("gl_LastFragColorARM"), TType(EbtFloat, EbpMedium, EvqLastFragColor, 4))); } } break; case GL_VERTEX_SHADER: symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpHigh, EvqPosition, 4))); symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1))); symbolTable.insert(ESSL3_BUILTINS, new TVariable(NewPoolTString("gl_InstanceID"), TType(EbtInt, EbpHigh, EvqInstanceID, 1))); break; default: assert(false && "Language not supported"); } } void InitExtensionBehavior(const ShBuiltInResources& resources, TExtensionBehavior& extBehavior) { if (resources.OES_standard_derivatives) extBehavior["GL_OES_standard_derivatives"] = EBhUndefined; if (resources.OES_EGL_image_external) extBehavior["GL_OES_EGL_image_external"] = EBhUndefined; if (resources.ARB_texture_rectangle) extBehavior["GL_ARB_texture_rectangle"] = EBhUndefined; if (resources.EXT_blend_func_extended) extBehavior["GL_EXT_blend_func_extended"] = EBhUndefined; if (resources.EXT_draw_buffers) extBehavior["GL_EXT_draw_buffers"] = EBhUndefined; if (resources.EXT_frag_depth) extBehavior["GL_EXT_frag_depth"] = EBhUndefined; if (resources.EXT_shader_texture_lod) extBehavior["GL_EXT_shader_texture_lod"] = EBhUndefined; if (resources.EXT_shader_framebuffer_fetch) extBehavior["GL_EXT_shader_framebuffer_fetch"] = EBhUndefined; if (resources.NV_shader_framebuffer_fetch) extBehavior["GL_NV_shader_framebuffer_fetch"] = EBhUndefined; if (resources.ARM_shader_framebuffer_fetch) extBehavior["GL_ARM_shader_framebuffer_fetch"] = EBhUndefined; } void ResetExtensionBehavior(TExtensionBehavior &extBehavior) { for (auto ext_iter = extBehavior.begin(); ext_iter != extBehavior.end(); ++ext_iter) { ext_iter->second = EBhUndefined; } } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/Initialize.h000066400000000000000000000022631321746453100272010ustar00rootroot00000000000000// // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_INITIALIZE_H_ #define COMPILER_TRANSLATOR_INITIALIZE_H_ #include "compiler/translator/Common.h" #include "compiler/translator/Compiler.h" #include "compiler/translator/SymbolTable.h" void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &table); void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec, const ShBuiltInResources& resources, TSymbolTable& symbolTable); void InitExtensionBehavior(const ShBuiltInResources& resources, TExtensionBehavior& extensionBehavior); // Resets the behavior of the extensions listed in |extensionBehavior| to the // undefined state. These extensions will only be those initially supported in // the ShBuiltInResources object for this compiler instance. All other // extensions will remain unsupported. void ResetExtensionBehavior(TExtensionBehavior &extensionBehavior); #endif // COMPILER_TRANSLATOR_INITIALIZE_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/InitializeDll.cpp000066400000000000000000000015551321746453100301730ustar00rootroot00000000000000// // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/Cache.h" #include "compiler/translator/InitializeDll.h" #include "compiler/translator/InitializeGlobals.h" #include "compiler/translator/InitializeParseContext.h" #include "common/platform.h" #include bool InitProcess() { if (!InitializePoolIndex()) { assert(0 && "InitProcess(): Failed to initialize global pool"); return false; } if (!InitializeParseContextIndex()) { assert(0 && "InitProcess(): Failed to initialize parse context"); return false; } TCache::initialize(); return true; } void DetachProcess() { FreeParseContextIndex(); FreePoolIndex(); TCache::destroy(); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/InitializeDll.h000066400000000000000000000005571321746453100276410ustar00rootroot00000000000000// // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_INITIALIZEDLL_H_ #define COMPILER_TRANSLATOR_INITIALIZEDLL_H_ bool InitProcess(); void DetachProcess(); #endif // COMPILER_TRANSLATOR_INITIALIZEDLL_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/InitializeGlobals.h000066400000000000000000000006031321746453100305010ustar00rootroot00000000000000// // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_INITIALIZEGLOBALS_H_ #define COMPILER_TRANSLATOR_INITIALIZEGLOBALS_H_ bool InitializePoolIndex(); void FreePoolIndex(); #endif // COMPILER_TRANSLATOR_INITIALIZEGLOBALS_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/InitializeParseContext.cpp000066400000000000000000000020641321746453100320730ustar00rootroot00000000000000// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/InitializeParseContext.h" #include "common/tls.h" #include TLSIndex GlobalParseContextIndex = TLS_INVALID_INDEX; bool InitializeParseContextIndex() { assert(GlobalParseContextIndex == TLS_INVALID_INDEX); GlobalParseContextIndex = CreateTLSIndex(); return GlobalParseContextIndex != TLS_INVALID_INDEX; } void FreeParseContextIndex() { assert(GlobalParseContextIndex != TLS_INVALID_INDEX); DestroyTLSIndex(GlobalParseContextIndex); GlobalParseContextIndex = TLS_INVALID_INDEX; } void SetGlobalParseContext(TParseContext* context) { assert(GlobalParseContextIndex != TLS_INVALID_INDEX); SetTLSValue(GlobalParseContextIndex, context); } TParseContext* GetGlobalParseContext() { assert(GlobalParseContextIndex != TLS_INVALID_INDEX); return static_cast(GetTLSValue(GlobalParseContextIndex)); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/InitializeParseContext.h000066400000000000000000000010421321746453100315330ustar00rootroot00000000000000// // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_INITIALIZEPARSECONTEXT_H_ #define COMPILER_TRANSLATOR_INITIALIZEPARSECONTEXT_H_ bool InitializeParseContextIndex(); void FreeParseContextIndex(); class TParseContext; extern void SetGlobalParseContext(TParseContext* context); extern TParseContext* GetGlobalParseContext(); #endif // COMPILER_TRANSLATOR_INITIALIZEPARSECONTEXT_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/IntermNode.cpp000066400000000000000000002574471321746453100275170ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // // Build the intermediate representation. // #include #include #include #include #include #include #include "common/mathutil.h" #include "common/matrix_utils.h" #include "compiler/translator/HashNames.h" #include "compiler/translator/IntermNode.h" #include "compiler/translator/SymbolTable.h" namespace { const float kPi = 3.14159265358979323846f; const float kDegreesToRadiansMultiplier = kPi / 180.0f; const float kRadiansToDegreesMultiplier = 180.0f / kPi; TPrecision GetHigherPrecision(TPrecision left, TPrecision right) { return left > right ? left : right; } bool ValidateMultiplication(TOperator op, const TType &left, const TType &right) { switch (op) { case EOpMul: case EOpMulAssign: return left.getNominalSize() == right.getNominalSize() && left.getSecondarySize() == right.getSecondarySize(); case EOpVectorTimesScalar: case EOpVectorTimesScalarAssign: return true; case EOpVectorTimesMatrix: return left.getNominalSize() == right.getRows(); case EOpVectorTimesMatrixAssign: return left.getNominalSize() == right.getRows() && left.getNominalSize() == right.getCols(); case EOpMatrixTimesVector: return left.getCols() == right.getNominalSize(); case EOpMatrixTimesScalar: case EOpMatrixTimesScalarAssign: return true; case EOpMatrixTimesMatrix: return left.getCols() == right.getRows(); case EOpMatrixTimesMatrixAssign: return left.getCols() == right.getCols() && left.getRows() == right.getRows(); default: UNREACHABLE(); return false; } } bool CompareStructure(const TType& leftNodeType, const TConstantUnion *rightUnionArray, const TConstantUnion *leftUnionArray); bool CompareStruct(const TType &leftNodeType, const TConstantUnion *rightUnionArray, const TConstantUnion *leftUnionArray) { const TFieldList &fields = leftNodeType.getStruct()->fields(); size_t structSize = fields.size(); size_t index = 0; for (size_t j = 0; j < structSize; j++) { size_t size = fields[j]->type()->getObjectSize(); for (size_t i = 0; i < size; i++) { if (fields[j]->type()->getBasicType() == EbtStruct) { if (!CompareStructure(*fields[j]->type(), &rightUnionArray[index], &leftUnionArray[index])) { return false; } } else { if (leftUnionArray[index] != rightUnionArray[index]) return false; index++; } } } return true; } bool CompareStructure(const TType &leftNodeType, const TConstantUnion *rightUnionArray, const TConstantUnion *leftUnionArray) { if (leftNodeType.isArray()) { TType typeWithoutArrayness = leftNodeType; typeWithoutArrayness.clearArrayness(); size_t arraySize = leftNodeType.getArraySize(); for (size_t i = 0; i < arraySize; ++i) { size_t offset = typeWithoutArrayness.getObjectSize() * i; if (!CompareStruct(typeWithoutArrayness, &rightUnionArray[offset], &leftUnionArray[offset])) { return false; } } } else { return CompareStruct(leftNodeType, rightUnionArray, leftUnionArray); } return true; } TConstantUnion *Vectorize(const TConstantUnion &constant, size_t size) { TConstantUnion *constUnion = new TConstantUnion[size]; for (unsigned int i = 0; i < size; ++i) constUnion[i] = constant; return constUnion; } void UndefinedConstantFoldingError(const TSourceLoc &loc, TOperator op, TBasicType basicType, TInfoSink &infoSink, TConstantUnion *result) { std::stringstream constantFoldingErrorStream; constantFoldingErrorStream << "'" << GetOperatorString(op) << "' operation result is undefined for the values passed in"; infoSink.info.message(EPrefixWarning, loc, constantFoldingErrorStream.str().c_str()); switch (basicType) { case EbtFloat : result->setFConst(0.0f); break; case EbtInt: result->setIConst(0); break; case EbtUInt: result->setUConst(0u); break; case EbtBool: result->setBConst(false); break; default: break; } } float VectorLength(TConstantUnion *paramArray, size_t paramArraySize) { float result = 0.0f; for (size_t i = 0; i < paramArraySize; i++) { float f = paramArray[i].getFConst(); result += f * f; } return sqrtf(result); } float VectorDotProduct(TConstantUnion *paramArray1, TConstantUnion *paramArray2, size_t paramArraySize) { float result = 0.0f; for (size_t i = 0; i < paramArraySize; i++) result += paramArray1[i].getFConst() * paramArray2[i].getFConst(); return result; } TIntermTyped *CreateFoldedNode(TConstantUnion *constArray, const TIntermTyped *originalNode) { if (constArray == nullptr) { return nullptr; } TIntermTyped *folded = new TIntermConstantUnion(constArray, originalNode->getType()); folded->getTypePointer()->setQualifier(EvqConst); folded->setLine(originalNode->getLine()); return folded; } angle::Matrix GetMatrix(TConstantUnion *paramArray, const unsigned int &rows, const unsigned int &cols) { std::vector elements; for (size_t i = 0; i < rows * cols; i++) elements.push_back(paramArray[i].getFConst()); // Transpose is used since the Matrix constructor expects arguments in row-major order, // whereas the paramArray is in column-major order. return angle::Matrix(elements, rows, cols).transpose(); } angle::Matrix GetMatrix(TConstantUnion *paramArray, const unsigned int &size) { std::vector elements; for (size_t i = 0; i < size * size; i++) elements.push_back(paramArray[i].getFConst()); // Transpose is used since the Matrix constructor expects arguments in row-major order, // whereas the paramArray is in column-major order. return angle::Matrix(elements, size).transpose(); } void SetUnionArrayFromMatrix(const angle::Matrix &m, TConstantUnion *resultArray) { // Transpose is used since the input Matrix is in row-major order, // whereas the actual result should be in column-major order. angle::Matrix result = m.transpose(); std::vector resultElements = result.elements(); for (size_t i = 0; i < resultElements.size(); i++) resultArray[i].setFConst(resultElements[i]); } } // namespace anonymous //////////////////////////////////////////////////////////////// // // Member functions of the nodes used for building the tree. // //////////////////////////////////////////////////////////////// void TIntermTyped::setTypePreservePrecision(const TType &t) { TPrecision precision = getPrecision(); mType = t; ASSERT(mType.getBasicType() != EbtBool || precision == EbpUndefined); mType.setPrecision(precision); } #define REPLACE_IF_IS(node, type, original, replacement) \ if (node == original) { \ node = static_cast(replacement); \ return true; \ } bool TIntermLoop::replaceChildNode( TIntermNode *original, TIntermNode *replacement) { REPLACE_IF_IS(mInit, TIntermNode, original, replacement); REPLACE_IF_IS(mCond, TIntermTyped, original, replacement); REPLACE_IF_IS(mExpr, TIntermTyped, original, replacement); REPLACE_IF_IS(mBody, TIntermNode, original, replacement); return false; } bool TIntermBranch::replaceChildNode( TIntermNode *original, TIntermNode *replacement) { REPLACE_IF_IS(mExpression, TIntermTyped, original, replacement); return false; } bool TIntermBinary::replaceChildNode( TIntermNode *original, TIntermNode *replacement) { REPLACE_IF_IS(mLeft, TIntermTyped, original, replacement); REPLACE_IF_IS(mRight, TIntermTyped, original, replacement); return false; } bool TIntermUnary::replaceChildNode( TIntermNode *original, TIntermNode *replacement) { REPLACE_IF_IS(mOperand, TIntermTyped, original, replacement); return false; } bool TIntermAggregate::replaceChildNode( TIntermNode *original, TIntermNode *replacement) { for (size_t ii = 0; ii < mSequence.size(); ++ii) { REPLACE_IF_IS(mSequence[ii], TIntermNode, original, replacement); } return false; } bool TIntermAggregate::replaceChildNodeWithMultiple(TIntermNode *original, TIntermSequence replacements) { for (auto it = mSequence.begin(); it < mSequence.end(); ++it) { if (*it == original) { it = mSequence.erase(it); mSequence.insert(it, replacements.begin(), replacements.end()); return true; } } return false; } bool TIntermAggregate::insertChildNodes(TIntermSequence::size_type position, TIntermSequence insertions) { TIntermSequence::size_type itPosition = 0; for (auto it = mSequence.begin(); it < mSequence.end(); ++it) { if (itPosition == position) { mSequence.insert(it, insertions.begin(), insertions.end()); return true; } ++itPosition; } return false; } void TIntermAggregate::setPrecisionFromChildren() { mGotPrecisionFromChildren = true; if (getBasicType() == EbtBool) { mType.setPrecision(EbpUndefined); return; } TPrecision precision = EbpUndefined; TIntermSequence::iterator childIter = mSequence.begin(); while (childIter != mSequence.end()) { TIntermTyped *typed = (*childIter)->getAsTyped(); if (typed) precision = GetHigherPrecision(typed->getPrecision(), precision); ++childIter; } mType.setPrecision(precision); } void TIntermAggregate::setBuiltInFunctionPrecision() { // All built-ins returning bool should be handled as ops, not functions. ASSERT(getBasicType() != EbtBool); TPrecision precision = EbpUndefined; TIntermSequence::iterator childIter = mSequence.begin(); while (childIter != mSequence.end()) { TIntermTyped *typed = (*childIter)->getAsTyped(); // ESSL spec section 8: texture functions get their precision from the sampler. if (typed && IsSampler(typed->getBasicType())) { precision = typed->getPrecision(); break; } ++childIter; } // ESSL 3.0 spec section 8: textureSize always gets highp precision. // All other functions that take a sampler are assumed to be texture functions. if (mName.getString().find("textureSize") == 0) mType.setPrecision(EbpHigh); else mType.setPrecision(precision); } bool TIntermSelection::replaceChildNode( TIntermNode *original, TIntermNode *replacement) { REPLACE_IF_IS(mCondition, TIntermTyped, original, replacement); REPLACE_IF_IS(mTrueBlock, TIntermNode, original, replacement); REPLACE_IF_IS(mFalseBlock, TIntermNode, original, replacement); return false; } bool TIntermSwitch::replaceChildNode( TIntermNode *original, TIntermNode *replacement) { REPLACE_IF_IS(mInit, TIntermTyped, original, replacement); REPLACE_IF_IS(mStatementList, TIntermAggregate, original, replacement); return false; } bool TIntermCase::replaceChildNode( TIntermNode *original, TIntermNode *replacement) { REPLACE_IF_IS(mCondition, TIntermTyped, original, replacement); return false; } // // Say whether or not an operation node changes the value of a variable. // bool TIntermOperator::isAssignment() const { switch (mOp) { case EOpPostIncrement: case EOpPostDecrement: case EOpPreIncrement: case EOpPreDecrement: case EOpAssign: case EOpAddAssign: case EOpSubAssign: case EOpMulAssign: case EOpVectorTimesMatrixAssign: case EOpVectorTimesScalarAssign: case EOpMatrixTimesScalarAssign: case EOpMatrixTimesMatrixAssign: case EOpDivAssign: case EOpIModAssign: case EOpBitShiftLeftAssign: case EOpBitShiftRightAssign: case EOpBitwiseAndAssign: case EOpBitwiseXorAssign: case EOpBitwiseOrAssign: return true; default: return false; } } bool TIntermOperator::isMultiplication() const { switch (mOp) { case EOpMul: case EOpMatrixTimesMatrix: case EOpMatrixTimesVector: case EOpMatrixTimesScalar: case EOpVectorTimesMatrix: case EOpVectorTimesScalar: return true; default: return false; } } // // returns true if the operator is for one of the constructors // bool TIntermOperator::isConstructor() const { switch (mOp) { case EOpConstructVec2: case EOpConstructVec3: case EOpConstructVec4: case EOpConstructMat2: case EOpConstructMat2x3: case EOpConstructMat2x4: case EOpConstructMat3x2: case EOpConstructMat3: case EOpConstructMat3x4: case EOpConstructMat4x2: case EOpConstructMat4x3: case EOpConstructMat4: case EOpConstructFloat: case EOpConstructIVec2: case EOpConstructIVec3: case EOpConstructIVec4: case EOpConstructInt: case EOpConstructUVec2: case EOpConstructUVec3: case EOpConstructUVec4: case EOpConstructUInt: case EOpConstructBVec2: case EOpConstructBVec3: case EOpConstructBVec4: case EOpConstructBool: case EOpConstructStruct: return true; default: return false; } } // // Make sure the type of a unary operator is appropriate for its // combination of operation and operand type. // void TIntermUnary::promote(const TType *funcReturnType) { switch (mOp) { case EOpFloatBitsToInt: case EOpFloatBitsToUint: case EOpIntBitsToFloat: case EOpUintBitsToFloat: case EOpPackSnorm2x16: case EOpPackUnorm2x16: case EOpPackHalf2x16: case EOpUnpackSnorm2x16: case EOpUnpackUnorm2x16: mType.setPrecision(EbpHigh); break; case EOpUnpackHalf2x16: mType.setPrecision(EbpMedium); break; default: setType(mOperand->getType()); } if (funcReturnType != nullptr) { if (funcReturnType->getBasicType() == EbtBool) { // Bool types should not have precision. setType(*funcReturnType); } else { // Precision of the node has been set based on the operand. setTypePreservePrecision(*funcReturnType); } } mType.setQualifier(EvqTemporary); } // // Establishes the type of the resultant operation, as well as // makes the operator the correct one for the operands. // // For lots of operations it should already be established that the operand // combination is valid, but returns false if operator can't work on operands. // bool TIntermBinary::promote(TInfoSink &infoSink) { ASSERT(mLeft->isArray() == mRight->isArray()); // // Base assumption: just make the type the same as the left // operand. Then only deviations from this need be coded. // setType(mLeft->getType()); // The result gets promoted to the highest precision. TPrecision higherPrecision = GetHigherPrecision( mLeft->getPrecision(), mRight->getPrecision()); getTypePointer()->setPrecision(higherPrecision); // Binary operations results in temporary variables unless both // operands are const. if (mLeft->getQualifier() != EvqConst || mRight->getQualifier() != EvqConst) { getTypePointer()->setQualifier(EvqTemporary); } const int nominalSize = std::max(mLeft->getNominalSize(), mRight->getNominalSize()); // // All scalars or structs. Code after this test assumes this case is removed! // if (nominalSize == 1) { switch (mOp) { // // Promote to conditional // case EOpEqual: case EOpNotEqual: case EOpLessThan: case EOpGreaterThan: case EOpLessThanEqual: case EOpGreaterThanEqual: setType(TType(EbtBool, EbpUndefined)); break; // // And and Or operate on conditionals // case EOpLogicalAnd: case EOpLogicalXor: case EOpLogicalOr: ASSERT(mLeft->getBasicType() == EbtBool && mRight->getBasicType() == EbtBool); setType(TType(EbtBool, EbpUndefined)); break; default: break; } return true; } // If we reach here, at least one of the operands is vector or matrix. // The other operand could be a scalar, vector, or matrix. // Can these two operands be combined? // TBasicType basicType = mLeft->getBasicType(); switch (mOp) { case EOpMul: if (!mLeft->isMatrix() && mRight->isMatrix()) { if (mLeft->isVector()) { mOp = EOpVectorTimesMatrix; setType(TType(basicType, higherPrecision, EvqTemporary, static_cast(mRight->getCols()), 1)); } else { mOp = EOpMatrixTimesScalar; setType(TType(basicType, higherPrecision, EvqTemporary, static_cast(mRight->getCols()), static_cast(mRight->getRows()))); } } else if (mLeft->isMatrix() && !mRight->isMatrix()) { if (mRight->isVector()) { mOp = EOpMatrixTimesVector; setType(TType(basicType, higherPrecision, EvqTemporary, static_cast(mLeft->getRows()), 1)); } else { mOp = EOpMatrixTimesScalar; } } else if (mLeft->isMatrix() && mRight->isMatrix()) { mOp = EOpMatrixTimesMatrix; setType(TType(basicType, higherPrecision, EvqTemporary, static_cast(mRight->getCols()), static_cast(mLeft->getRows()))); } else if (!mLeft->isMatrix() && !mRight->isMatrix()) { if (mLeft->isVector() && mRight->isVector()) { // leave as component product } else if (mLeft->isVector() || mRight->isVector()) { mOp = EOpVectorTimesScalar; setType(TType(basicType, higherPrecision, EvqTemporary, static_cast(nominalSize), 1)); } } else { infoSink.info.message(EPrefixInternalError, getLine(), "Missing elses"); return false; } if (!ValidateMultiplication(mOp, mLeft->getType(), mRight->getType())) { return false; } break; case EOpMulAssign: if (!mLeft->isMatrix() && mRight->isMatrix()) { if (mLeft->isVector()) { mOp = EOpVectorTimesMatrixAssign; } else { return false; } } else if (mLeft->isMatrix() && !mRight->isMatrix()) { if (mRight->isVector()) { return false; } else { mOp = EOpMatrixTimesScalarAssign; } } else if (mLeft->isMatrix() && mRight->isMatrix()) { mOp = EOpMatrixTimesMatrixAssign; setType(TType(basicType, higherPrecision, EvqTemporary, static_cast(mRight->getCols()), static_cast(mLeft->getRows()))); } else if (!mLeft->isMatrix() && !mRight->isMatrix()) { if (mLeft->isVector() && mRight->isVector()) { // leave as component product } else if (mLeft->isVector() || mRight->isVector()) { if (!mLeft->isVector()) return false; mOp = EOpVectorTimesScalarAssign; setType(TType(basicType, higherPrecision, EvqTemporary, static_cast(mLeft->getNominalSize()), 1)); } } else { infoSink.info.message(EPrefixInternalError, getLine(), "Missing elses"); return false; } if (!ValidateMultiplication(mOp, mLeft->getType(), mRight->getType())) { return false; } break; case EOpAssign: case EOpInitialize: // No more additional checks are needed. ASSERT((mLeft->getNominalSize() == mRight->getNominalSize()) && (mLeft->getSecondarySize() == mRight->getSecondarySize())); break; case EOpAdd: case EOpSub: case EOpDiv: case EOpIMod: case EOpBitShiftLeft: case EOpBitShiftRight: case EOpBitwiseAnd: case EOpBitwiseXor: case EOpBitwiseOr: case EOpAddAssign: case EOpSubAssign: case EOpDivAssign: case EOpIModAssign: case EOpBitShiftLeftAssign: case EOpBitShiftRightAssign: case EOpBitwiseAndAssign: case EOpBitwiseXorAssign: case EOpBitwiseOrAssign: if ((mLeft->isMatrix() && mRight->isVector()) || (mLeft->isVector() && mRight->isMatrix())) { return false; } // Are the sizes compatible? if (mLeft->getNominalSize() != mRight->getNominalSize() || mLeft->getSecondarySize() != mRight->getSecondarySize()) { // If the nominal sizes of operands do not match: // One of them must be a scalar. if (!mLeft->isScalar() && !mRight->isScalar()) return false; // In the case of compound assignment other than multiply-assign, // the right side needs to be a scalar. Otherwise a vector/matrix // would be assigned to a scalar. A scalar can't be shifted by a // vector either. if (!mRight->isScalar() && (isAssignment() || mOp == EOpBitShiftLeft || mOp == EOpBitShiftRight)) return false; } { const int secondarySize = std::max( mLeft->getSecondarySize(), mRight->getSecondarySize()); setType(TType(basicType, higherPrecision, EvqTemporary, static_cast(nominalSize), static_cast(secondarySize))); if (mLeft->isArray()) { ASSERT(mLeft->getArraySize() == mRight->getArraySize()); mType.setArraySize(mLeft->getArraySize()); } } break; case EOpEqual: case EOpNotEqual: case EOpLessThan: case EOpGreaterThan: case EOpLessThanEqual: case EOpGreaterThanEqual: ASSERT((mLeft->getNominalSize() == mRight->getNominalSize()) && (mLeft->getSecondarySize() == mRight->getSecondarySize())); setType(TType(EbtBool, EbpUndefined)); break; default: return false; } return true; } TIntermTyped *TIntermBinary::fold(TInfoSink &infoSink) { TIntermConstantUnion *leftConstant = mLeft->getAsConstantUnion(); TIntermConstantUnion *rightConstant = mRight->getAsConstantUnion(); if (leftConstant == nullptr || rightConstant == nullptr) { return nullptr; } TConstantUnion *constArray = leftConstant->foldBinary(mOp, rightConstant, infoSink); return CreateFoldedNode(constArray, this); } TIntermTyped *TIntermUnary::fold(TInfoSink &infoSink) { TIntermConstantUnion *operandConstant = mOperand->getAsConstantUnion(); if (operandConstant == nullptr) { return nullptr; } TConstantUnion *constArray = nullptr; switch (mOp) { case EOpAny: case EOpAll: case EOpLength: case EOpTranspose: case EOpDeterminant: case EOpInverse: case EOpPackSnorm2x16: case EOpUnpackSnorm2x16: case EOpPackUnorm2x16: case EOpUnpackUnorm2x16: case EOpPackHalf2x16: case EOpUnpackHalf2x16: constArray = operandConstant->foldUnaryWithDifferentReturnType(mOp, infoSink); break; default: constArray = operandConstant->foldUnaryWithSameReturnType(mOp, infoSink); break; } return CreateFoldedNode(constArray, this); } TIntermTyped *TIntermAggregate::fold(TInfoSink &infoSink) { // Make sure that all params are constant before actual constant folding. for (auto *param : *getSequence()) { if (param->getAsConstantUnion() == nullptr) { return nullptr; } } TConstantUnion *constArray = TIntermConstantUnion::FoldAggregateBuiltIn(this, infoSink); return CreateFoldedNode(constArray, this); } // // The fold functions see if an operation on a constant can be done in place, // without generating run-time code. // // Returns the constant value to keep using or nullptr. // TConstantUnion *TIntermConstantUnion::foldBinary(TOperator op, TIntermConstantUnion *rightNode, TInfoSink &infoSink) { TConstantUnion *leftArray = getUnionArrayPointer(); TConstantUnion *rightArray = rightNode->getUnionArrayPointer(); if (!leftArray) return nullptr; if (!rightArray) return nullptr; size_t objectSize = getType().getObjectSize(); // for a case like float f = vec4(2, 3, 4, 5) + 1.2; if (rightNode->getType().getObjectSize() == 1 && objectSize > 1) { rightArray = Vectorize(*rightNode->getUnionArrayPointer(), objectSize); } else if (rightNode->getType().getObjectSize() > 1 && objectSize == 1) { // for a case like float f = 1.2 + vec4(2, 3, 4, 5); leftArray = Vectorize(*getUnionArrayPointer(), rightNode->getType().getObjectSize()); objectSize = rightNode->getType().getObjectSize(); } TConstantUnion *resultArray = nullptr; switch(op) { case EOpAdd: resultArray = new TConstantUnion[objectSize]; for (size_t i = 0; i < objectSize; i++) resultArray[i] = leftArray[i] + rightArray[i]; break; case EOpSub: resultArray = new TConstantUnion[objectSize]; for (size_t i = 0; i < objectSize; i++) resultArray[i] = leftArray[i] - rightArray[i]; break; case EOpMul: case EOpVectorTimesScalar: case EOpMatrixTimesScalar: resultArray = new TConstantUnion[objectSize]; for (size_t i = 0; i < objectSize; i++) resultArray[i] = leftArray[i] * rightArray[i]; break; case EOpMatrixTimesMatrix: { if (getType().getBasicType() != EbtFloat || rightNode->getBasicType() != EbtFloat) { infoSink.info.message( EPrefixInternalError, getLine(), "Constant Folding cannot be done for matrix multiply"); return nullptr; } const int leftCols = getCols(); const int leftRows = getRows(); const int rightCols = rightNode->getType().getCols(); const int rightRows = rightNode->getType().getRows(); const int resultCols = rightCols; const int resultRows = leftRows; resultArray = new TConstantUnion[resultCols * resultRows]; for (int row = 0; row < resultRows; row++) { for (int column = 0; column < resultCols; column++) { resultArray[resultRows * column + row].setFConst(0.0f); for (int i = 0; i < leftCols; i++) { resultArray[resultRows * column + row].setFConst( resultArray[resultRows * column + row].getFConst() + leftArray[i * leftRows + row].getFConst() * rightArray[column * rightRows + i].getFConst()); } } } } break; case EOpDiv: case EOpIMod: { resultArray = new TConstantUnion[objectSize]; for (size_t i = 0; i < objectSize; i++) { switch (getType().getBasicType()) { case EbtFloat: if (rightArray[i] == 0.0f) { infoSink.info.message(EPrefixWarning, getLine(), "Divide by zero error during constant folding"); resultArray[i].setFConst(leftArray[i].getFConst() < 0 ? -FLT_MAX : FLT_MAX); } else { ASSERT(op == EOpDiv); resultArray[i].setFConst(leftArray[i].getFConst() / rightArray[i].getFConst()); } break; case EbtInt: if (rightArray[i] == 0) { infoSink.info.message(EPrefixWarning, getLine(), "Divide by zero error during constant folding"); resultArray[i].setIConst(INT_MAX); } else { if (op == EOpDiv) { resultArray[i].setIConst(leftArray[i].getIConst() / rightArray[i].getIConst()); } else { ASSERT(op == EOpIMod); resultArray[i].setIConst(leftArray[i].getIConst() % rightArray[i].getIConst()); } } break; case EbtUInt: if (rightArray[i] == 0) { infoSink.info.message(EPrefixWarning, getLine(), "Divide by zero error during constant folding"); resultArray[i].setUConst(UINT_MAX); } else { if (op == EOpDiv) { resultArray[i].setUConst(leftArray[i].getUConst() / rightArray[i].getUConst()); } else { ASSERT(op == EOpIMod); resultArray[i].setUConst(leftArray[i].getUConst() % rightArray[i].getUConst()); } } break; default: infoSink.info.message(EPrefixInternalError, getLine(), "Constant folding cannot be done for \"/\""); return nullptr; } } } break; case EOpMatrixTimesVector: { if (rightNode->getBasicType() != EbtFloat) { infoSink.info.message(EPrefixInternalError, getLine(), "Constant Folding cannot be done for matrix times vector"); return nullptr; } const int matrixCols = getCols(); const int matrixRows = getRows(); resultArray = new TConstantUnion[matrixRows]; for (int matrixRow = 0; matrixRow < matrixRows; matrixRow++) { resultArray[matrixRow].setFConst(0.0f); for (int col = 0; col < matrixCols; col++) { resultArray[matrixRow].setFConst(resultArray[matrixRow].getFConst() + leftArray[col * matrixRows + matrixRow].getFConst() * rightArray[col].getFConst()); } } } break; case EOpVectorTimesMatrix: { if (getType().getBasicType() != EbtFloat) { infoSink.info.message(EPrefixInternalError, getLine(), "Constant Folding cannot be done for vector times matrix"); return nullptr; } const int matrixCols = rightNode->getType().getCols(); const int matrixRows = rightNode->getType().getRows(); resultArray = new TConstantUnion[matrixCols]; for (int matrixCol = 0; matrixCol < matrixCols; matrixCol++) { resultArray[matrixCol].setFConst(0.0f); for (int matrixRow = 0; matrixRow < matrixRows; matrixRow++) { resultArray[matrixCol].setFConst(resultArray[matrixCol].getFConst() + leftArray[matrixRow].getFConst() * rightArray[matrixCol * matrixRows + matrixRow].getFConst()); } } } break; case EOpLogicalAnd: { resultArray = new TConstantUnion[objectSize]; for (size_t i = 0; i < objectSize; i++) { resultArray[i] = leftArray[i] && rightArray[i]; } } break; case EOpLogicalOr: { resultArray = new TConstantUnion[objectSize]; for (size_t i = 0; i < objectSize; i++) { resultArray[i] = leftArray[i] || rightArray[i]; } } break; case EOpLogicalXor: { resultArray = new TConstantUnion[objectSize]; for (size_t i = 0; i < objectSize; i++) { switch (getType().getBasicType()) { case EbtBool: resultArray[i].setBConst(leftArray[i] != rightArray[i]); break; default: UNREACHABLE(); break; } } } break; case EOpBitwiseAnd: resultArray = new TConstantUnion[objectSize]; for (size_t i = 0; i < objectSize; i++) resultArray[i] = leftArray[i] & rightArray[i]; break; case EOpBitwiseXor: resultArray = new TConstantUnion[objectSize]; for (size_t i = 0; i < objectSize; i++) resultArray[i] = leftArray[i] ^ rightArray[i]; break; case EOpBitwiseOr: resultArray = new TConstantUnion[objectSize]; for (size_t i = 0; i < objectSize; i++) resultArray[i] = leftArray[i] | rightArray[i]; break; case EOpBitShiftLeft: resultArray = new TConstantUnion[objectSize]; for (size_t i = 0; i < objectSize; i++) resultArray[i] = leftArray[i] << rightArray[i]; break; case EOpBitShiftRight: resultArray = new TConstantUnion[objectSize]; for (size_t i = 0; i < objectSize; i++) resultArray[i] = leftArray[i] >> rightArray[i]; break; case EOpLessThan: ASSERT(objectSize == 1); resultArray = new TConstantUnion[1]; resultArray->setBConst(*leftArray < *rightArray); break; case EOpGreaterThan: ASSERT(objectSize == 1); resultArray = new TConstantUnion[1]; resultArray->setBConst(*leftArray > *rightArray); break; case EOpLessThanEqual: ASSERT(objectSize == 1); resultArray = new TConstantUnion[1]; resultArray->setBConst(!(*leftArray > *rightArray)); break; case EOpGreaterThanEqual: ASSERT(objectSize == 1); resultArray = new TConstantUnion[1]; resultArray->setBConst(!(*leftArray < *rightArray)); break; case EOpEqual: case EOpNotEqual: { resultArray = new TConstantUnion[1]; bool equal = true; if (getType().getBasicType() == EbtStruct) { equal = CompareStructure(getType(), rightArray, leftArray); } else { for (size_t i = 0; i < objectSize; i++) { if (leftArray[i] != rightArray[i]) { equal = false; break; // break out of for loop } } } if (op == EOpEqual) { resultArray->setBConst(equal); } else { resultArray->setBConst(!equal); } } break; default: infoSink.info.message( EPrefixInternalError, getLine(), "Invalid operator for constant folding"); return nullptr; } return resultArray; } // // The fold functions see if an operation on a constant can be done in place, // without generating run-time code. // // Returns the constant value to keep using or nullptr. // TConstantUnion *TIntermConstantUnion::foldUnaryWithDifferentReturnType(TOperator op, TInfoSink &infoSink) { // // Do operations where the return type has a different number of components compared to the operand type. // TConstantUnion *operandArray = getUnionArrayPointer(); if (!operandArray) return nullptr; size_t objectSize = getType().getObjectSize(); TConstantUnion *resultArray = nullptr; switch (op) { case EOpAny: if (getType().getBasicType() == EbtBool) { resultArray = new TConstantUnion(); resultArray->setBConst(false); for (size_t i = 0; i < objectSize; i++) { if (operandArray[i].getBConst()) { resultArray->setBConst(true); break; } } break; } else { infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } case EOpAll: if (getType().getBasicType() == EbtBool) { resultArray = new TConstantUnion(); resultArray->setBConst(true); for (size_t i = 0; i < objectSize; i++) { if (!operandArray[i].getBConst()) { resultArray->setBConst(false); break; } } break; } else { infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } case EOpLength: if (getType().getBasicType() == EbtFloat) { resultArray = new TConstantUnion(); resultArray->setFConst(VectorLength(operandArray, objectSize)); break; } else { infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } case EOpTranspose: if (getType().getBasicType() == EbtFloat) { resultArray = new TConstantUnion[objectSize]; angle::Matrix result = GetMatrix(operandArray, getType().getNominalSize(), getType().getSecondarySize()).transpose(); SetUnionArrayFromMatrix(result, resultArray); break; } else { infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } case EOpDeterminant: if (getType().getBasicType() == EbtFloat) { unsigned int size = getType().getNominalSize(); ASSERT(size >= 2 && size <= 4); resultArray = new TConstantUnion(); resultArray->setFConst(GetMatrix(operandArray, size).determinant()); break; } else { infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } case EOpInverse: if (getType().getBasicType() == EbtFloat) { unsigned int size = getType().getNominalSize(); ASSERT(size >= 2 && size <= 4); resultArray = new TConstantUnion[objectSize]; angle::Matrix result = GetMatrix(operandArray, size).inverse(); SetUnionArrayFromMatrix(result, resultArray); break; } else { infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } case EOpPackSnorm2x16: if (getType().getBasicType() == EbtFloat) { ASSERT(getType().getNominalSize() == 2); resultArray = new TConstantUnion(); resultArray->setUConst(gl::packSnorm2x16(operandArray[0].getFConst(), operandArray[1].getFConst())); break; } else { infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } case EOpUnpackSnorm2x16: if (getType().getBasicType() == EbtUInt) { resultArray = new TConstantUnion[2]; float f1, f2; gl::unpackSnorm2x16(operandArray[0].getUConst(), &f1, &f2); resultArray[0].setFConst(f1); resultArray[1].setFConst(f2); break; } else { infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } case EOpPackUnorm2x16: if (getType().getBasicType() == EbtFloat) { ASSERT(getType().getNominalSize() == 2); resultArray = new TConstantUnion(); resultArray->setUConst(gl::packUnorm2x16(operandArray[0].getFConst(), operandArray[1].getFConst())); break; } else { infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } case EOpUnpackUnorm2x16: if (getType().getBasicType() == EbtUInt) { resultArray = new TConstantUnion[2]; float f1, f2; gl::unpackUnorm2x16(operandArray[0].getUConst(), &f1, &f2); resultArray[0].setFConst(f1); resultArray[1].setFConst(f2); break; } else { infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } case EOpPackHalf2x16: if (getType().getBasicType() == EbtFloat) { ASSERT(getType().getNominalSize() == 2); resultArray = new TConstantUnion(); resultArray->setUConst(gl::packHalf2x16(operandArray[0].getFConst(), operandArray[1].getFConst())); break; } else { infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } case EOpUnpackHalf2x16: if (getType().getBasicType() == EbtUInt) { resultArray = new TConstantUnion[2]; float f1, f2; gl::unpackHalf2x16(operandArray[0].getUConst(), &f1, &f2); resultArray[0].setFConst(f1); resultArray[1].setFConst(f2); break; } else { infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } break; default: break; } return resultArray; } TConstantUnion *TIntermConstantUnion::foldUnaryWithSameReturnType(TOperator op, TInfoSink &infoSink) { // // Do unary operations where the return type is the same as operand type. // TConstantUnion *operandArray = getUnionArrayPointer(); if (!operandArray) return nullptr; size_t objectSize = getType().getObjectSize(); TConstantUnion *resultArray = new TConstantUnion[objectSize]; for (size_t i = 0; i < objectSize; i++) { switch(op) { case EOpNegative: switch (getType().getBasicType()) { case EbtFloat: resultArray[i].setFConst(-operandArray[i].getFConst()); break; case EbtInt: resultArray[i].setIConst(-operandArray[i].getIConst()); break; case EbtUInt: resultArray[i].setUConst(static_cast( -static_cast(operandArray[i].getUConst()))); break; default: infoSink.info.message( EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } break; case EOpPositive: switch (getType().getBasicType()) { case EbtFloat: resultArray[i].setFConst(operandArray[i].getFConst()); break; case EbtInt: resultArray[i].setIConst(operandArray[i].getIConst()); break; case EbtUInt: resultArray[i].setUConst(static_cast( static_cast(operandArray[i].getUConst()))); break; default: infoSink.info.message( EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } break; case EOpLogicalNot: // this code is written for possible future use, // will not get executed currently switch (getType().getBasicType()) { case EbtBool: resultArray[i].setBConst(!operandArray[i].getBConst()); break; default: infoSink.info.message( EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } break; case EOpBitwiseNot: switch (getType().getBasicType()) { case EbtInt: resultArray[i].setIConst(~operandArray[i].getIConst()); break; case EbtUInt: resultArray[i].setUConst(~operandArray[i].getUConst()); break; default: infoSink.info.message( EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } break; case EOpRadians: if (getType().getBasicType() == EbtFloat) { resultArray[i].setFConst(kDegreesToRadiansMultiplier * operandArray[i].getFConst()); break; } infoSink.info.message( EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; case EOpDegrees: if (getType().getBasicType() == EbtFloat) { resultArray[i].setFConst(kRadiansToDegreesMultiplier * operandArray[i].getFConst()); break; } infoSink.info.message( EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; case EOpSin: if (!foldFloatTypeUnary(operandArray[i], &sinf, infoSink, &resultArray[i])) return nullptr; break; case EOpCos: if (!foldFloatTypeUnary(operandArray[i], &cosf, infoSink, &resultArray[i])) return nullptr; break; case EOpTan: if (!foldFloatTypeUnary(operandArray[i], &tanf, infoSink, &resultArray[i])) return nullptr; break; case EOpAsin: // For asin(x), results are undefined if |x| > 1, we are choosing to set result to 0. if (getType().getBasicType() == EbtFloat && fabsf(operandArray[i].getFConst()) > 1.0f) UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &resultArray[i]); else if (!foldFloatTypeUnary(operandArray[i], &asinf, infoSink, &resultArray[i])) return nullptr; break; case EOpAcos: // For acos(x), results are undefined if |x| > 1, we are choosing to set result to 0. if (getType().getBasicType() == EbtFloat && fabsf(operandArray[i].getFConst()) > 1.0f) UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &resultArray[i]); else if (!foldFloatTypeUnary(operandArray[i], &acosf, infoSink, &resultArray[i])) return nullptr; break; case EOpAtan: if (!foldFloatTypeUnary(operandArray[i], &atanf, infoSink, &resultArray[i])) return nullptr; break; case EOpSinh: if (!foldFloatTypeUnary(operandArray[i], &sinhf, infoSink, &resultArray[i])) return nullptr; break; case EOpCosh: if (!foldFloatTypeUnary(operandArray[i], &coshf, infoSink, &resultArray[i])) return nullptr; break; case EOpTanh: if (!foldFloatTypeUnary(operandArray[i], &tanhf, infoSink, &resultArray[i])) return nullptr; break; case EOpAsinh: if (!foldFloatTypeUnary(operandArray[i], &asinhf, infoSink, &resultArray[i])) return nullptr; break; case EOpAcosh: // For acosh(x), results are undefined if x < 1, we are choosing to set result to 0. if (getType().getBasicType() == EbtFloat && operandArray[i].getFConst() < 1.0f) UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &resultArray[i]); else if (!foldFloatTypeUnary(operandArray[i], &acoshf, infoSink, &resultArray[i])) return nullptr; break; case EOpAtanh: // For atanh(x), results are undefined if |x| >= 1, we are choosing to set result to 0. if (getType().getBasicType() == EbtFloat && fabsf(operandArray[i].getFConst()) >= 1.0f) UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &resultArray[i]); else if (!foldFloatTypeUnary(operandArray[i], &atanhf, infoSink, &resultArray[i])) return nullptr; break; case EOpAbs: switch (getType().getBasicType()) { case EbtFloat: resultArray[i].setFConst(fabsf(operandArray[i].getFConst())); break; case EbtInt: resultArray[i].setIConst(abs(operandArray[i].getIConst())); break; default: infoSink.info.message( EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } break; case EOpSign: switch (getType().getBasicType()) { case EbtFloat: { float fConst = operandArray[i].getFConst(); float fResult = 0.0f; if (fConst > 0.0f) fResult = 1.0f; else if (fConst < 0.0f) fResult = -1.0f; resultArray[i].setFConst(fResult); } break; case EbtInt: { int iConst = operandArray[i].getIConst(); int iResult = 0; if (iConst > 0) iResult = 1; else if (iConst < 0) iResult = -1; resultArray[i].setIConst(iResult); } break; default: infoSink.info.message( EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; } break; case EOpFloor: if (!foldFloatTypeUnary(operandArray[i], &floorf, infoSink, &resultArray[i])) return nullptr; break; case EOpTrunc: if (!foldFloatTypeUnary(operandArray[i], &truncf, infoSink, &resultArray[i])) return nullptr; break; case EOpRound: if (!foldFloatTypeUnary(operandArray[i], &roundf, infoSink, &resultArray[i])) return nullptr; break; case EOpRoundEven: if (getType().getBasicType() == EbtFloat) { float x = operandArray[i].getFConst(); float result; float fractPart = modff(x, &result); if (fabsf(fractPart) == 0.5f) result = 2.0f * roundf(x / 2.0f); else result = roundf(x); resultArray[i].setFConst(result); break; } infoSink.info.message( EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; case EOpCeil: if (!foldFloatTypeUnary(operandArray[i], &ceilf, infoSink, &resultArray[i])) return nullptr; break; case EOpFract: if (getType().getBasicType() == EbtFloat) { float x = operandArray[i].getFConst(); resultArray[i].setFConst(x - floorf(x)); break; } infoSink.info.message( EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; case EOpIsNan: if (getType().getBasicType() == EbtFloat) { resultArray[i].setBConst(gl::isNaN(operandArray[0].getFConst())); break; } infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; case EOpIsInf: if (getType().getBasicType() == EbtFloat) { resultArray[i].setBConst(gl::isInf(operandArray[0].getFConst())); break; } infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; case EOpFloatBitsToInt: if (getType().getBasicType() == EbtFloat) { resultArray[i].setIConst(gl::bitCast(operandArray[0].getFConst())); break; } infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; case EOpFloatBitsToUint: if (getType().getBasicType() == EbtFloat) { resultArray[i].setUConst(gl::bitCast(operandArray[0].getFConst())); break; } infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; case EOpIntBitsToFloat: if (getType().getBasicType() == EbtInt) { resultArray[i].setFConst(gl::bitCast(operandArray[0].getIConst())); break; } infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; case EOpUintBitsToFloat: if (getType().getBasicType() == EbtUInt) { resultArray[i].setFConst(gl::bitCast(operandArray[0].getUConst())); break; } infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; case EOpExp: if (!foldFloatTypeUnary(operandArray[i], &expf, infoSink, &resultArray[i])) return nullptr; break; case EOpLog: // For log(x), results are undefined if x <= 0, we are choosing to set result to 0. if (getType().getBasicType() == EbtFloat && operandArray[i].getFConst() <= 0.0f) UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &resultArray[i]); else if (!foldFloatTypeUnary(operandArray[i], &logf, infoSink, &resultArray[i])) return nullptr; break; case EOpExp2: if (!foldFloatTypeUnary(operandArray[i], &exp2f, infoSink, &resultArray[i])) return nullptr; break; case EOpLog2: // For log2(x), results are undefined if x <= 0, we are choosing to set result to 0. // And log2f is not available on some plarforms like old android, so just using log(x)/log(2) here. if (getType().getBasicType() == EbtFloat && operandArray[i].getFConst() <= 0.0f) UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &resultArray[i]); else if (!foldFloatTypeUnary(operandArray[i], &logf, infoSink, &resultArray[i])) return nullptr; else resultArray[i].setFConst(resultArray[i].getFConst() / logf(2.0f)); break; case EOpSqrt: // For sqrt(x), results are undefined if x < 0, we are choosing to set result to 0. if (getType().getBasicType() == EbtFloat && operandArray[i].getFConst() < 0.0f) UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &resultArray[i]); else if (!foldFloatTypeUnary(operandArray[i], &sqrtf, infoSink, &resultArray[i])) return nullptr; break; case EOpInverseSqrt: // There is no stdlib built-in function equavalent for GLES built-in inversesqrt(), // so getting the square root first using builtin function sqrt() and then taking its inverse. // Also, for inversesqrt(x), results are undefined if x <= 0, we are choosing to set result to 0. if (getType().getBasicType() == EbtFloat && operandArray[i].getFConst() <= 0.0f) UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &resultArray[i]); else if (!foldFloatTypeUnary(operandArray[i], &sqrtf, infoSink, &resultArray[i])) return nullptr; else resultArray[i].setFConst(1.0f / resultArray[i].getFConst()); break; case EOpVectorLogicalNot: if (getType().getBasicType() == EbtBool) { resultArray[i].setBConst(!operandArray[i].getBConst()); break; } infoSink.info.message( EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; case EOpNormalize: if (getType().getBasicType() == EbtFloat) { float x = operandArray[i].getFConst(); float length = VectorLength(operandArray, objectSize); if (length) resultArray[i].setFConst(x / length); else UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &resultArray[i]); break; } infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; case EOpDFdx: case EOpDFdy: case EOpFwidth: if (getType().getBasicType() == EbtFloat) { // Derivatives of constant arguments should be 0. resultArray[i].setFConst(0.0f); break; } infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return nullptr; default: return nullptr; } } return resultArray; } bool TIntermConstantUnion::foldFloatTypeUnary(const TConstantUnion ¶meter, FloatTypeUnaryFunc builtinFunc, TInfoSink &infoSink, TConstantUnion *result) const { ASSERT(builtinFunc); if (getType().getBasicType() == EbtFloat) { result->setFConst(builtinFunc(parameter.getFConst())); return true; } infoSink.info.message( EPrefixInternalError, getLine(), "Unary operation not folded into constant"); return false; } // static TConstantUnion *TIntermConstantUnion::FoldAggregateBuiltIn(TIntermAggregate *aggregate, TInfoSink &infoSink) { TOperator op = aggregate->getOp(); TIntermSequence *sequence = aggregate->getSequence(); unsigned int paramsCount = static_cast(sequence->size()); std::vector unionArrays(paramsCount); std::vector objectSizes(paramsCount); size_t maxObjectSize = 0; TBasicType basicType = EbtVoid; TSourceLoc loc; for (unsigned int i = 0; i < paramsCount; i++) { TIntermConstantUnion *paramConstant = (*sequence)[i]->getAsConstantUnion(); ASSERT(paramConstant != nullptr); // Should be checked already. if (i == 0) { basicType = paramConstant->getType().getBasicType(); loc = paramConstant->getLine(); } unionArrays[i] = paramConstant->getUnionArrayPointer(); objectSizes[i] = paramConstant->getType().getObjectSize(); if (objectSizes[i] > maxObjectSize) maxObjectSize = objectSizes[i]; } if (!(*sequence)[0]->getAsTyped()->isMatrix()) { for (unsigned int i = 0; i < paramsCount; i++) if (objectSizes[i] != maxObjectSize) unionArrays[i] = Vectorize(*unionArrays[i], maxObjectSize); } TConstantUnion *resultArray = nullptr; if (paramsCount == 2) { // // Binary built-in // switch (op) { case EOpAtan: { if (basicType == EbtFloat) { resultArray = new TConstantUnion[maxObjectSize]; for (size_t i = 0; i < maxObjectSize; i++) { float y = unionArrays[0][i].getFConst(); float x = unionArrays[1][i].getFConst(); // Results are undefined if x and y are both 0. if (x == 0.0f && y == 0.0f) UndefinedConstantFoldingError(loc, op, basicType, infoSink, &resultArray[i]); else resultArray[i].setFConst(atan2f(y, x)); } } else UNREACHABLE(); } break; case EOpPow: { if (basicType == EbtFloat) { resultArray = new TConstantUnion[maxObjectSize]; for (size_t i = 0; i < maxObjectSize; i++) { float x = unionArrays[0][i].getFConst(); float y = unionArrays[1][i].getFConst(); // Results are undefined if x < 0. // Results are undefined if x = 0 and y <= 0. if (x < 0.0f) UndefinedConstantFoldingError(loc, op, basicType, infoSink, &resultArray[i]); else if (x == 0.0f && y <= 0.0f) UndefinedConstantFoldingError(loc, op, basicType, infoSink, &resultArray[i]); else resultArray[i].setFConst(powf(x, y)); } } else UNREACHABLE(); } break; case EOpMod: { if (basicType == EbtFloat) { resultArray = new TConstantUnion[maxObjectSize]; for (size_t i = 0; i < maxObjectSize; i++) { float x = unionArrays[0][i].getFConst(); float y = unionArrays[1][i].getFConst(); resultArray[i].setFConst(x - y * floorf(x / y)); } } else UNREACHABLE(); } break; case EOpMin: { resultArray = new TConstantUnion[maxObjectSize]; for (size_t i = 0; i < maxObjectSize; i++) { switch (basicType) { case EbtFloat: resultArray[i].setFConst(std::min(unionArrays[0][i].getFConst(), unionArrays[1][i].getFConst())); break; case EbtInt: resultArray[i].setIConst(std::min(unionArrays[0][i].getIConst(), unionArrays[1][i].getIConst())); break; case EbtUInt: resultArray[i].setUConst(std::min(unionArrays[0][i].getUConst(), unionArrays[1][i].getUConst())); break; default: UNREACHABLE(); break; } } } break; case EOpMax: { resultArray = new TConstantUnion[maxObjectSize]; for (size_t i = 0; i < maxObjectSize; i++) { switch (basicType) { case EbtFloat: resultArray[i].setFConst(std::max(unionArrays[0][i].getFConst(), unionArrays[1][i].getFConst())); break; case EbtInt: resultArray[i].setIConst(std::max(unionArrays[0][i].getIConst(), unionArrays[1][i].getIConst())); break; case EbtUInt: resultArray[i].setUConst(std::max(unionArrays[0][i].getUConst(), unionArrays[1][i].getUConst())); break; default: UNREACHABLE(); break; } } } break; case EOpStep: { if (basicType == EbtFloat) { resultArray = new TConstantUnion[maxObjectSize]; for (size_t i = 0; i < maxObjectSize; i++) resultArray[i].setFConst(unionArrays[1][i].getFConst() < unionArrays[0][i].getFConst() ? 0.0f : 1.0f); } else UNREACHABLE(); } break; case EOpLessThan: { resultArray = new TConstantUnion[maxObjectSize]; for (size_t i = 0; i < maxObjectSize; i++) { switch (basicType) { case EbtFloat: resultArray[i].setBConst(unionArrays[0][i].getFConst() < unionArrays[1][i].getFConst()); break; case EbtInt: resultArray[i].setBConst(unionArrays[0][i].getIConst() < unionArrays[1][i].getIConst()); break; case EbtUInt: resultArray[i].setBConst(unionArrays[0][i].getUConst() < unionArrays[1][i].getUConst()); break; default: UNREACHABLE(); break; } } } break; case EOpLessThanEqual: { resultArray = new TConstantUnion[maxObjectSize]; for (size_t i = 0; i < maxObjectSize; i++) { switch (basicType) { case EbtFloat: resultArray[i].setBConst(unionArrays[0][i].getFConst() <= unionArrays[1][i].getFConst()); break; case EbtInt: resultArray[i].setBConst(unionArrays[0][i].getIConst() <= unionArrays[1][i].getIConst()); break; case EbtUInt: resultArray[i].setBConst(unionArrays[0][i].getUConst() <= unionArrays[1][i].getUConst()); break; default: UNREACHABLE(); break; } } } break; case EOpGreaterThan: { resultArray = new TConstantUnion[maxObjectSize]; for (size_t i = 0; i < maxObjectSize; i++) { switch (basicType) { case EbtFloat: resultArray[i].setBConst(unionArrays[0][i].getFConst() > unionArrays[1][i].getFConst()); break; case EbtInt: resultArray[i].setBConst(unionArrays[0][i].getIConst() > unionArrays[1][i].getIConst()); break; case EbtUInt: resultArray[i].setBConst(unionArrays[0][i].getUConst() > unionArrays[1][i].getUConst()); break; default: UNREACHABLE(); break; } } } break; case EOpGreaterThanEqual: { resultArray = new TConstantUnion[maxObjectSize]; for (size_t i = 0; i < maxObjectSize; i++) { switch (basicType) { case EbtFloat: resultArray[i].setBConst(unionArrays[0][i].getFConst() >= unionArrays[1][i].getFConst()); break; case EbtInt: resultArray[i].setBConst(unionArrays[0][i].getIConst() >= unionArrays[1][i].getIConst()); break; case EbtUInt: resultArray[i].setBConst(unionArrays[0][i].getUConst() >= unionArrays[1][i].getUConst()); break; default: UNREACHABLE(); break; } } } break; case EOpVectorEqual: { resultArray = new TConstantUnion[maxObjectSize]; for (size_t i = 0; i < maxObjectSize; i++) { switch (basicType) { case EbtFloat: resultArray[i].setBConst(unionArrays[0][i].getFConst() == unionArrays[1][i].getFConst()); break; case EbtInt: resultArray[i].setBConst(unionArrays[0][i].getIConst() == unionArrays[1][i].getIConst()); break; case EbtUInt: resultArray[i].setBConst(unionArrays[0][i].getUConst() == unionArrays[1][i].getUConst()); break; case EbtBool: resultArray[i].setBConst(unionArrays[0][i].getBConst() == unionArrays[1][i].getBConst()); break; default: UNREACHABLE(); break; } } } break; case EOpVectorNotEqual: { resultArray = new TConstantUnion[maxObjectSize]; for (size_t i = 0; i < maxObjectSize; i++) { switch (basicType) { case EbtFloat: resultArray[i].setBConst(unionArrays[0][i].getFConst() != unionArrays[1][i].getFConst()); break; case EbtInt: resultArray[i].setBConst(unionArrays[0][i].getIConst() != unionArrays[1][i].getIConst()); break; case EbtUInt: resultArray[i].setBConst(unionArrays[0][i].getUConst() != unionArrays[1][i].getUConst()); break; case EbtBool: resultArray[i].setBConst(unionArrays[0][i].getBConst() != unionArrays[1][i].getBConst()); break; default: UNREACHABLE(); break; } } } break; case EOpDistance: if (basicType == EbtFloat) { TConstantUnion *distanceArray = new TConstantUnion[maxObjectSize]; resultArray = new TConstantUnion(); for (size_t i = 0; i < maxObjectSize; i++) { float x = unionArrays[0][i].getFConst(); float y = unionArrays[1][i].getFConst(); distanceArray[i].setFConst(x - y); } resultArray->setFConst(VectorLength(distanceArray, maxObjectSize)); } else UNREACHABLE(); break; case EOpDot: if (basicType == EbtFloat) { resultArray = new TConstantUnion(); resultArray->setFConst(VectorDotProduct(unionArrays[0], unionArrays[1], maxObjectSize)); } else UNREACHABLE(); break; case EOpCross: if (basicType == EbtFloat && maxObjectSize == 3) { resultArray = new TConstantUnion[maxObjectSize]; float x0 = unionArrays[0][0].getFConst(); float x1 = unionArrays[0][1].getFConst(); float x2 = unionArrays[0][2].getFConst(); float y0 = unionArrays[1][0].getFConst(); float y1 = unionArrays[1][1].getFConst(); float y2 = unionArrays[1][2].getFConst(); resultArray[0].setFConst(x1 * y2 - y1 * x2); resultArray[1].setFConst(x2 * y0 - y2 * x0); resultArray[2].setFConst(x0 * y1 - y0 * x1); } else UNREACHABLE(); break; case EOpReflect: if (basicType == EbtFloat) { // genType reflect (genType I, genType N) : // For the incident vector I and surface orientation N, returns the reflection direction: // I - 2 * dot(N, I) * N. resultArray = new TConstantUnion[maxObjectSize]; float dotProduct = VectorDotProduct(unionArrays[1], unionArrays[0], maxObjectSize); for (size_t i = 0; i < maxObjectSize; i++) { float result = unionArrays[0][i].getFConst() - 2.0f * dotProduct * unionArrays[1][i].getFConst(); resultArray[i].setFConst(result); } } else UNREACHABLE(); break; case EOpMul: if (basicType == EbtFloat && (*sequence)[0]->getAsTyped()->isMatrix() && (*sequence)[1]->getAsTyped()->isMatrix()) { // Perform component-wise matrix multiplication. resultArray = new TConstantUnion[maxObjectSize]; int size = (*sequence)[0]->getAsTyped()->getNominalSize(); angle::Matrix result = GetMatrix(unionArrays[0], size).compMult(GetMatrix(unionArrays[1], size)); SetUnionArrayFromMatrix(result, resultArray); } else UNREACHABLE(); break; case EOpOuterProduct: if (basicType == EbtFloat) { size_t numRows = (*sequence)[0]->getAsTyped()->getType().getObjectSize(); size_t numCols = (*sequence)[1]->getAsTyped()->getType().getObjectSize(); resultArray = new TConstantUnion[numRows * numCols]; angle::Matrix result = GetMatrix(unionArrays[0], 1, static_cast(numCols)) .outerProduct(GetMatrix(unionArrays[1], static_cast(numRows), 1)); SetUnionArrayFromMatrix(result, resultArray); } else UNREACHABLE(); break; default: UNREACHABLE(); // TODO: Add constant folding support for other built-in operations that take 2 parameters and not handled above. return nullptr; } } else if (paramsCount == 3) { // // Ternary built-in // switch (op) { case EOpClamp: { resultArray = new TConstantUnion[maxObjectSize]; for (size_t i = 0; i < maxObjectSize; i++) { switch (basicType) { case EbtFloat: { float x = unionArrays[0][i].getFConst(); float min = unionArrays[1][i].getFConst(); float max = unionArrays[2][i].getFConst(); // Results are undefined if min > max. if (min > max) UndefinedConstantFoldingError(loc, op, basicType, infoSink, &resultArray[i]); else resultArray[i].setFConst(gl::clamp(x, min, max)); } break; case EbtInt: { int x = unionArrays[0][i].getIConst(); int min = unionArrays[1][i].getIConst(); int max = unionArrays[2][i].getIConst(); // Results are undefined if min > max. if (min > max) UndefinedConstantFoldingError(loc, op, basicType, infoSink, &resultArray[i]); else resultArray[i].setIConst(gl::clamp(x, min, max)); } break; case EbtUInt: { unsigned int x = unionArrays[0][i].getUConst(); unsigned int min = unionArrays[1][i].getUConst(); unsigned int max = unionArrays[2][i].getUConst(); // Results are undefined if min > max. if (min > max) UndefinedConstantFoldingError(loc, op, basicType, infoSink, &resultArray[i]); else resultArray[i].setUConst(gl::clamp(x, min, max)); } break; default: UNREACHABLE(); break; } } } break; case EOpMix: { if (basicType == EbtFloat) { resultArray = new TConstantUnion[maxObjectSize]; for (size_t i = 0; i < maxObjectSize; i++) { float x = unionArrays[0][i].getFConst(); float y = unionArrays[1][i].getFConst(); TBasicType type = (*sequence)[2]->getAsTyped()->getType().getBasicType(); if (type == EbtFloat) { // Returns the linear blend of x and y, i.e., x * (1 - a) + y * a. float a = unionArrays[2][i].getFConst(); resultArray[i].setFConst(x * (1.0f - a) + y * a); } else // 3rd parameter is EbtBool { ASSERT(type == EbtBool); // Selects which vector each returned component comes from. // For a component of a that is false, the corresponding component of x is returned. // For a component of a that is true, the corresponding component of y is returned. bool a = unionArrays[2][i].getBConst(); resultArray[i].setFConst(a ? y : x); } } } else UNREACHABLE(); } break; case EOpSmoothStep: { if (basicType == EbtFloat) { resultArray = new TConstantUnion[maxObjectSize]; for (size_t i = 0; i < maxObjectSize; i++) { float edge0 = unionArrays[0][i].getFConst(); float edge1 = unionArrays[1][i].getFConst(); float x = unionArrays[2][i].getFConst(); // Results are undefined if edge0 >= edge1. if (edge0 >= edge1) { UndefinedConstantFoldingError(loc, op, basicType, infoSink, &resultArray[i]); } else { // Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth // Hermite interpolation between 0 and 1 when edge0 < x < edge1. float t = gl::clamp((x - edge0) / (edge1 - edge0), 0.0f, 1.0f); resultArray[i].setFConst(t * t * (3.0f - 2.0f * t)); } } } else UNREACHABLE(); } break; case EOpFaceForward: if (basicType == EbtFloat) { // genType faceforward(genType N, genType I, genType Nref) : // If dot(Nref, I) < 0 return N, otherwise return -N. resultArray = new TConstantUnion[maxObjectSize]; float dotProduct = VectorDotProduct(unionArrays[2], unionArrays[1], maxObjectSize); for (size_t i = 0; i < maxObjectSize; i++) { if (dotProduct < 0) resultArray[i].setFConst(unionArrays[0][i].getFConst()); else resultArray[i].setFConst(-unionArrays[0][i].getFConst()); } } else UNREACHABLE(); break; case EOpRefract: if (basicType == EbtFloat) { // genType refract(genType I, genType N, float eta) : // For the incident vector I and surface normal N, and the ratio of indices of refraction eta, // return the refraction vector. The result is computed by // k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I)) // if (k < 0.0) // return genType(0.0) // else // return eta * I - (eta * dot(N, I) + sqrt(k)) * N resultArray = new TConstantUnion[maxObjectSize]; float dotProduct = VectorDotProduct(unionArrays[1], unionArrays[0], maxObjectSize); for (size_t i = 0; i < maxObjectSize; i++) { float eta = unionArrays[2][i].getFConst(); float k = 1.0f - eta * eta * (1.0f - dotProduct * dotProduct); if (k < 0.0f) resultArray[i].setFConst(0.0f); else resultArray[i].setFConst(eta * unionArrays[0][i].getFConst() - (eta * dotProduct + sqrtf(k)) * unionArrays[1][i].getFConst()); } } else UNREACHABLE(); break; default: UNREACHABLE(); // TODO: Add constant folding support for other built-in operations that take 3 parameters and not handled above. return nullptr; } } return resultArray; } // static TString TIntermTraverser::hash(const TString &name, ShHashFunction64 hashFunction) { if (hashFunction == NULL || name.empty()) return name; khronos_uint64_t number = (*hashFunction)(name.c_str(), name.length()); TStringStream stream; stream << HASHED_NAME_PREFIX << std::hex << number; TString hashedName = stream.str(); return hashedName; } void TIntermTraverser::updateTree() { for (size_t ii = 0; ii < mInsertions.size(); ++ii) { const NodeInsertMultipleEntry &insertion = mInsertions[ii]; ASSERT(insertion.parent); bool inserted = insertion.parent->insertChildNodes(insertion.position, insertion.insertions); ASSERT(inserted); UNUSED_ASSERTION_VARIABLE(inserted); } for (size_t ii = 0; ii < mReplacements.size(); ++ii) { const NodeUpdateEntry &replacement = mReplacements[ii]; ASSERT(replacement.parent); bool replaced = replacement.parent->replaceChildNode( replacement.original, replacement.replacement); ASSERT(replaced); UNUSED_ASSERTION_VARIABLE(replaced); if (!replacement.originalBecomesChildOfReplacement) { // In AST traversing, a parent is visited before its children. // After we replace a node, if its immediate child is to // be replaced, we need to make sure we don't update the replaced // node; instead, we update the replacement node. for (size_t jj = ii + 1; jj < mReplacements.size(); ++jj) { NodeUpdateEntry &replacement2 = mReplacements[jj]; if (replacement2.parent == replacement.original) replacement2.parent = replacement.replacement; } } } for (size_t ii = 0; ii < mMultiReplacements.size(); ++ii) { const NodeReplaceWithMultipleEntry &replacement = mMultiReplacements[ii]; ASSERT(replacement.parent); bool replaced = replacement.parent->replaceChildNodeWithMultiple( replacement.original, replacement.replacements); ASSERT(replaced); UNUSED_ASSERTION_VARIABLE(replaced); } mInsertions.clear(); mReplacements.clear(); mMultiReplacements.clear(); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/IntermNode.h000066400000000000000000000731411321746453100271470ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // // Definition of the in-memory high-level intermediate representation // of shaders. This is a tree that parser creates. // // Nodes in the tree are defined as a hierarchy of classes derived from // TIntermNode. Each is a node in a tree. There is no preset branching factor; // each node can have it's own type of list of children. // #ifndef COMPILER_TRANSLATOR_INTERMNODE_H_ #define COMPILER_TRANSLATOR_INTERMNODE_H_ #include "GLSLANG/ShaderLang.h" #include #include #include "common/angleutils.h" #include "compiler/translator/Common.h" #include "compiler/translator/ConstantUnion.h" #include "compiler/translator/Operator.h" #include "compiler/translator/Types.h" class TIntermTraverser; class TIntermAggregate; class TIntermBinary; class TIntermUnary; class TIntermConstantUnion; class TIntermSelection; class TIntermSwitch; class TIntermCase; class TIntermTyped; class TIntermSymbol; class TIntermLoop; class TInfoSink; class TInfoSinkBase; class TIntermRaw; class TSymbolTable; // Encapsulate an identifier string and track whether it is coming from the original shader code // (not internal) or from ANGLE (internal). Usually internal names shouldn't be decorated or hashed. class TName { public: POOL_ALLOCATOR_NEW_DELETE(); explicit TName(const TString &name) : mName(name), mIsInternal(false) {} TName() : mName(), mIsInternal(false) {} const TString &getString() const { return mName; } void setString(const TString &string) { mName = string; } bool isInternal() const { return mIsInternal; } void setInternal(bool isInternal) { mIsInternal = isInternal; } private: TString mName; bool mIsInternal; }; // // Base class for the tree nodes // class TIntermNode { public: POOL_ALLOCATOR_NEW_DELETE(); TIntermNode() { // TODO: Move this to TSourceLoc constructor // after getting rid of TPublicType. mLine.first_file = mLine.last_file = 0; mLine.first_line = mLine.last_line = 0; } virtual ~TIntermNode() { } const TSourceLoc &getLine() const { return mLine; } void setLine(const TSourceLoc &l) { mLine = l; } virtual void traverse(TIntermTraverser *) = 0; virtual TIntermTyped *getAsTyped() { return 0; } virtual TIntermConstantUnion *getAsConstantUnion() { return 0; } virtual TIntermAggregate *getAsAggregate() { return 0; } virtual TIntermBinary *getAsBinaryNode() { return 0; } virtual TIntermUnary *getAsUnaryNode() { return 0; } virtual TIntermSelection *getAsSelectionNode() { return 0; } virtual TIntermSwitch *getAsSwitchNode() { return 0; } virtual TIntermCase *getAsCaseNode() { return 0; } virtual TIntermSymbol *getAsSymbolNode() { return 0; } virtual TIntermLoop *getAsLoopNode() { return 0; } virtual TIntermRaw *getAsRawNode() { return 0; } // Replace a child node. Return true if |original| is a child // node and it is replaced; otherwise, return false. virtual bool replaceChildNode( TIntermNode *original, TIntermNode *replacement) = 0; protected: TSourceLoc mLine; }; // // This is just to help yacc. // struct TIntermNodePair { TIntermNode *node1; TIntermNode *node2; }; // // Intermediate class for nodes that have a type. // class TIntermTyped : public TIntermNode { public: TIntermTyped(const TType &t) : mType(t) { } TIntermTyped *getAsTyped() override { return this; } virtual bool hasSideEffects() const = 0; void setType(const TType &t) { mType = t; } void setTypePreservePrecision(const TType &t); const TType &getType() const { return mType; } TType *getTypePointer() { return &mType; } TBasicType getBasicType() const { return mType.getBasicType(); } TQualifier getQualifier() const { return mType.getQualifier(); } TPrecision getPrecision() const { return mType.getPrecision(); } int getCols() const { return mType.getCols(); } int getRows() const { return mType.getRows(); } int getNominalSize() const { return mType.getNominalSize(); } int getSecondarySize() const { return mType.getSecondarySize(); } bool isInterfaceBlock() const { return mType.isInterfaceBlock(); } bool isMatrix() const { return mType.isMatrix(); } bool isArray() const { return mType.isArray(); } bool isVector() const { return mType.isVector(); } bool isScalar() const { return mType.isScalar(); } bool isScalarInt() const { return mType.isScalarInt(); } const char *getBasicString() const { return mType.getBasicString(); } TString getCompleteString() const { return mType.getCompleteString(); } int getArraySize() const { return mType.getArraySize(); } protected: TType mType; }; // // Handle for, do-while, and while loops. // enum TLoopType { ELoopFor, ELoopWhile, ELoopDoWhile }; class TIntermLoop : public TIntermNode { public: TIntermLoop(TLoopType type, TIntermNode *init, TIntermTyped *cond, TIntermTyped *expr, TIntermNode *body) : mType(type), mInit(init), mCond(cond), mExpr(expr), mBody(body), mUnrollFlag(false) { } TIntermLoop *getAsLoopNode() override { return this; } void traverse(TIntermTraverser *it) override; bool replaceChildNode( TIntermNode *original, TIntermNode *replacement) override; TLoopType getType() const { return mType; } TIntermNode *getInit() { return mInit; } TIntermTyped *getCondition() { return mCond; } TIntermTyped *getExpression() { return mExpr; } TIntermNode *getBody() { return mBody; } void setUnrollFlag(bool flag) { mUnrollFlag = flag; } bool getUnrollFlag() const { return mUnrollFlag; } protected: TLoopType mType; TIntermNode *mInit; // for-loop initialization TIntermTyped *mCond; // loop exit condition TIntermTyped *mExpr; // for-loop expression TIntermNode *mBody; // loop body bool mUnrollFlag; // Whether the loop should be unrolled or not. }; // // Handle break, continue, return, and kill. // class TIntermBranch : public TIntermNode { public: TIntermBranch(TOperator op, TIntermTyped *e) : mFlowOp(op), mExpression(e) { } void traverse(TIntermTraverser *it) override; bool replaceChildNode( TIntermNode *original, TIntermNode *replacement) override; TOperator getFlowOp() { return mFlowOp; } TIntermTyped* getExpression() { return mExpression; } protected: TOperator mFlowOp; TIntermTyped *mExpression; // non-zero except for "return exp;" statements }; // // Nodes that correspond to symbols or constants in the source code. // class TIntermSymbol : public TIntermTyped { public: // if symbol is initialized as symbol(sym), the memory comes from the poolallocator of sym. // If sym comes from per process globalpoolallocator, then it causes increased memory usage // per compile it is essential to use "symbol = sym" to assign to symbol TIntermSymbol(int id, const TString &symbol, const TType &type) : TIntermTyped(type), mId(id), mSymbol(symbol) { } bool hasSideEffects() const override { return false; } int getId() const { return mId; } const TString &getSymbol() const { return mSymbol.getString(); } const TName &getName() const { return mSymbol; } void setId(int newId) { mId = newId; } void setInternal(bool internal) { mSymbol.setInternal(internal); } void traverse(TIntermTraverser *it) override; TIntermSymbol *getAsSymbolNode() override { return this; } bool replaceChildNode(TIntermNode *, TIntermNode *) override { return false; } protected: int mId; TName mSymbol; }; // A Raw node stores raw code, that the translator will insert verbatim // into the output stream. Useful for transformation operations that make // complex code that might not fit naturally into the GLSL model. class TIntermRaw : public TIntermTyped { public: TIntermRaw(const TType &type, const TString &rawText) : TIntermTyped(type), mRawText(rawText) { } bool hasSideEffects() const override { return false; } TString getRawText() const { return mRawText; } void traverse(TIntermTraverser *it) override; TIntermRaw *getAsRawNode() override { return this; } bool replaceChildNode(TIntermNode *, TIntermNode *) override { return false; } protected: TString mRawText; }; class TIntermConstantUnion : public TIntermTyped { public: TIntermConstantUnion(TConstantUnion *unionPointer, const TType &type) : TIntermTyped(type), mUnionArrayPointer(unionPointer) { } bool hasSideEffects() const override { return false; } const TConstantUnion *getUnionArrayPointer() const { return mUnionArrayPointer; } TConstantUnion *getUnionArrayPointer() { return mUnionArrayPointer; } int getIConst(size_t index) const { return mUnionArrayPointer ? mUnionArrayPointer[index].getIConst() : 0; } unsigned int getUConst(size_t index) const { return mUnionArrayPointer ? mUnionArrayPointer[index].getUConst() : 0; } float getFConst(size_t index) const { return mUnionArrayPointer ? mUnionArrayPointer[index].getFConst() : 0.0f; } bool getBConst(size_t index) const { return mUnionArrayPointer ? mUnionArrayPointer[index].getBConst() : false; } void replaceConstantUnion(TConstantUnion *safeConstantUnion) { // Previous union pointer freed on pool deallocation. mUnionArrayPointer = safeConstantUnion; } TIntermConstantUnion *getAsConstantUnion() override { return this; } void traverse(TIntermTraverser *it) override; bool replaceChildNode(TIntermNode *, TIntermNode *) override { return false; } TConstantUnion *foldBinary(TOperator op, TIntermConstantUnion *rightNode, TInfoSink &infoSink); TConstantUnion *foldUnaryWithDifferentReturnType(TOperator op, TInfoSink &infoSink); TConstantUnion *foldUnaryWithSameReturnType(TOperator op, TInfoSink &infoSink); static TConstantUnion *FoldAggregateBuiltIn(TIntermAggregate *aggregate, TInfoSink &infoSink); protected: TConstantUnion *mUnionArrayPointer; private: typedef float(*FloatTypeUnaryFunc) (float); bool foldFloatTypeUnary(const TConstantUnion ¶meter, FloatTypeUnaryFunc builtinFunc, TInfoSink &infoSink, TConstantUnion *result) const; }; // // Intermediate class for node types that hold operators. // class TIntermOperator : public TIntermTyped { public: TOperator getOp() const { return mOp; } void setOp(TOperator op) { mOp = op; } bool isAssignment() const; bool isMultiplication() const; bool isConstructor() const; bool hasSideEffects() const override { return isAssignment(); } protected: TIntermOperator(TOperator op) : TIntermTyped(TType(EbtFloat, EbpUndefined)), mOp(op) {} TIntermOperator(TOperator op, const TType &type) : TIntermTyped(type), mOp(op) {} TOperator mOp; }; // // Nodes for all the basic binary math operators. // class TIntermBinary : public TIntermOperator { public: TIntermBinary(TOperator op) : TIntermOperator(op) {} TIntermBinary *getAsBinaryNode() override { return this; }; void traverse(TIntermTraverser *it) override; bool replaceChildNode( TIntermNode *original, TIntermNode *replacement) override; bool hasSideEffects() const override { return isAssignment() || mLeft->hasSideEffects() || mRight->hasSideEffects(); } void setLeft(TIntermTyped *node) { mLeft = node; } void setRight(TIntermTyped *node) { mRight = node; } TIntermTyped *getLeft() const { return mLeft; } TIntermTyped *getRight() const { return mRight; } bool promote(TInfoSink &); TIntermTyped *fold(TInfoSink &infoSink); protected: TIntermTyped* mLeft; TIntermTyped* mRight; }; // // Nodes for unary math operators. // class TIntermUnary : public TIntermOperator { public: TIntermUnary(TOperator op, const TType &type) : TIntermOperator(op, type), mOperand(NULL), mUseEmulatedFunction(false) {} TIntermUnary(TOperator op) : TIntermOperator(op), mOperand(NULL), mUseEmulatedFunction(false) {} void traverse(TIntermTraverser *it) override; TIntermUnary *getAsUnaryNode() override { return this; } bool replaceChildNode( TIntermNode *original, TIntermNode *replacement) override; bool hasSideEffects() const override { return isAssignment() || mOperand->hasSideEffects(); } void setOperand(TIntermTyped *operand) { mOperand = operand; } TIntermTyped *getOperand() { return mOperand; } void promote(const TType *funcReturnType); TIntermTyped *fold(TInfoSink &infoSink); void setUseEmulatedFunction() { mUseEmulatedFunction = true; } bool getUseEmulatedFunction() { return mUseEmulatedFunction; } protected: TIntermTyped *mOperand; // If set to true, replace the built-in function call with an emulated one // to work around driver bugs. bool mUseEmulatedFunction; }; typedef TVector TIntermSequence; typedef TVector TQualifierList; // // Nodes that operate on an arbitrary sized set of children. // class TIntermAggregate : public TIntermOperator { public: TIntermAggregate() : TIntermOperator(EOpNull), mUserDefined(false), mUseEmulatedFunction(false), mGotPrecisionFromChildren(false) { } TIntermAggregate(TOperator op) : TIntermOperator(op), mUseEmulatedFunction(false), mGotPrecisionFromChildren(false) { } ~TIntermAggregate() { } TIntermAggregate *getAsAggregate() override { return this; } void traverse(TIntermTraverser *it) override; bool replaceChildNode( TIntermNode *original, TIntermNode *replacement) override; bool replaceChildNodeWithMultiple(TIntermNode *original, TIntermSequence replacements); bool insertChildNodes(TIntermSequence::size_type position, TIntermSequence insertions); // Conservatively assume function calls and other aggregate operators have side-effects bool hasSideEffects() const override { return true; } TIntermTyped *fold(TInfoSink &infoSink); TIntermSequence *getSequence() { return &mSequence; } void setNameObj(const TName &name) { mName = name; } const TName &getNameObj() const { return mName; } void setName(const TString &name) { mName.setString(name); } const TString &getName() const { return mName.getString(); } void setUserDefined() { mUserDefined = true; } bool isUserDefined() const { return mUserDefined; } void setOptimize(bool optimize) { mOptimize = optimize; } bool getOptimize() const { return mOptimize; } void setDebug(bool debug) { mDebug = debug; } bool getDebug() const { return mDebug; } void setFunctionId(int functionId) { mFunctionId = functionId; } int getFunctionId() const { return mFunctionId; } void setUseEmulatedFunction() { mUseEmulatedFunction = true; } bool getUseEmulatedFunction() { return mUseEmulatedFunction; } void setPrecisionFromChildren(); void setBuiltInFunctionPrecision(); // Returns true if changing parameter precision may affect the return value. bool gotPrecisionFromChildren() const { return mGotPrecisionFromChildren; } protected: TIntermAggregate(const TIntermAggregate &); // disallow copy constructor TIntermAggregate &operator=(const TIntermAggregate &); // disallow assignment operator TIntermSequence mSequence; TName mName; bool mUserDefined; // used for user defined function names int mFunctionId; bool mOptimize; bool mDebug; // If set to true, replace the built-in function call with an emulated one // to work around driver bugs. bool mUseEmulatedFunction; bool mGotPrecisionFromChildren; }; // // For if tests. // class TIntermSelection : public TIntermTyped { public: TIntermSelection(TIntermTyped *cond, TIntermNode *trueB, TIntermNode *falseB) : TIntermTyped(TType(EbtVoid, EbpUndefined)), mCondition(cond), mTrueBlock(trueB), mFalseBlock(falseB) {} TIntermSelection(TIntermTyped *cond, TIntermNode *trueB, TIntermNode *falseB, const TType &type) : TIntermTyped(type), mCondition(cond), mTrueBlock(trueB), mFalseBlock(falseB) {} void traverse(TIntermTraverser *it) override; bool replaceChildNode( TIntermNode *original, TIntermNode *replacement) override; // Conservatively assume selections have side-effects bool hasSideEffects() const override { return true; } bool usesTernaryOperator() const { return getBasicType() != EbtVoid; } TIntermNode *getCondition() const { return mCondition; } TIntermNode *getTrueBlock() const { return mTrueBlock; } TIntermNode *getFalseBlock() const { return mFalseBlock; } TIntermSelection *getAsSelectionNode() override { return this; } protected: TIntermTyped *mCondition; TIntermNode *mTrueBlock; TIntermNode *mFalseBlock; }; // // Switch statement. // class TIntermSwitch : public TIntermNode { public: TIntermSwitch(TIntermTyped *init, TIntermAggregate *statementList) : TIntermNode(), mInit(init), mStatementList(statementList) { } void traverse(TIntermTraverser *it) override; bool replaceChildNode( TIntermNode *original, TIntermNode *replacement) override; TIntermSwitch *getAsSwitchNode() override { return this; } TIntermTyped *getInit() { return mInit; } TIntermAggregate *getStatementList() { return mStatementList; } void setStatementList(TIntermAggregate *statementList) { mStatementList = statementList; } protected: TIntermTyped *mInit; TIntermAggregate *mStatementList; }; // // Case label. // class TIntermCase : public TIntermNode { public: TIntermCase(TIntermTyped *condition) : TIntermNode(), mCondition(condition) { } void traverse(TIntermTraverser *it) override; bool replaceChildNode( TIntermNode *original, TIntermNode *replacement) override; TIntermCase *getAsCaseNode() override { return this; } bool hasCondition() const { return mCondition != nullptr; } TIntermTyped *getCondition() const { return mCondition; } protected: TIntermTyped *mCondition; }; enum Visit { PreVisit, InVisit, PostVisit }; // // For traversing the tree. User should derive from this class overriding the visit functions, // and then pass an object of the subclass to a traverse method of a node. // // The traverse*() functions may also be overridden do other bookkeeping on the tree to provide // contextual information to the visit functions, such as whether the node is the target of an // assignment. // // When using this, just fill in the methods for nodes you want visited. // Return false from a pre-visit to skip visiting that node's subtree. // class TIntermTraverser : angle::NonCopyable { public: POOL_ALLOCATOR_NEW_DELETE(); TIntermTraverser(bool preVisit, bool inVisit, bool postVisit) : preVisit(preVisit), inVisit(inVisit), postVisit(postVisit), mDepth(0), mMaxDepth(0), mTemporaryIndex(nullptr) { } virtual ~TIntermTraverser() {} virtual void visitSymbol(TIntermSymbol *node) {} virtual void visitRaw(TIntermRaw *node) {} virtual void visitConstantUnion(TIntermConstantUnion *node) {} virtual bool visitBinary(Visit visit, TIntermBinary *node) { return true; } virtual bool visitUnary(Visit visit, TIntermUnary *node) { return true; } virtual bool visitSelection(Visit visit, TIntermSelection *node) { return true; } virtual bool visitSwitch(Visit visit, TIntermSwitch *node) { return true; } virtual bool visitCase(Visit visit, TIntermCase *node) { return true; } virtual bool visitAggregate(Visit visit, TIntermAggregate *node) { return true; } virtual bool visitLoop(Visit visit, TIntermLoop *node) { return true; } virtual bool visitBranch(Visit visit, TIntermBranch *node) { return true; } // The traverse functions contain logic for iterating over the children of the node // and calling the visit functions in the appropriate places. They also track some // context that may be used by the visit functions. virtual void traverseSymbol(TIntermSymbol *node); virtual void traverseRaw(TIntermRaw *node); virtual void traverseConstantUnion(TIntermConstantUnion *node); virtual void traverseBinary(TIntermBinary *node); virtual void traverseUnary(TIntermUnary *node); virtual void traverseSelection(TIntermSelection *node); virtual void traverseSwitch(TIntermSwitch *node); virtual void traverseCase(TIntermCase *node); virtual void traverseAggregate(TIntermAggregate *node); virtual void traverseLoop(TIntermLoop *node); virtual void traverseBranch(TIntermBranch *node); int getMaxDepth() const { return mMaxDepth; } // Return the original name if hash function pointer is NULL; // otherwise return the hashed name. static TString hash(const TString &name, ShHashFunction64 hashFunction); // If traversers need to replace nodes, they can add the replacements in // mReplacements/mMultiReplacements during traversal and the user of the traverser should call // this function after traversal to perform them. void updateTree(); // Start creating temporary symbols from the given temporary symbol index + 1. void useTemporaryIndex(unsigned int *temporaryIndex); protected: void incrementDepth(TIntermNode *current) { mDepth++; mMaxDepth = std::max(mMaxDepth, mDepth); mPath.push_back(current); } void decrementDepth() { mDepth--; mPath.pop_back(); } TIntermNode *getParentNode() { return mPath.size() == 0 ? NULL : mPath.back(); } void pushParentBlock(TIntermAggregate *node); void incrementParentBlockPos(); void popParentBlock(); bool parentNodeIsBlock() { return !mParentBlockStack.empty() && getParentNode() == mParentBlockStack.back().node; } const bool preVisit; const bool inVisit; const bool postVisit; int mDepth; int mMaxDepth; // All the nodes from root to the current node's parent during traversing. TVector mPath; // To replace a single node with another on the parent node struct NodeUpdateEntry { NodeUpdateEntry(TIntermNode *_parent, TIntermNode *_original, TIntermNode *_replacement, bool _originalBecomesChildOfReplacement) : parent(_parent), original(_original), replacement(_replacement), originalBecomesChildOfReplacement(_originalBecomesChildOfReplacement) {} TIntermNode *parent; TIntermNode *original; TIntermNode *replacement; bool originalBecomesChildOfReplacement; }; // To replace a single node with multiple nodes on the parent aggregate node struct NodeReplaceWithMultipleEntry { NodeReplaceWithMultipleEntry(TIntermAggregate *_parent, TIntermNode *_original, TIntermSequence _replacements) : parent(_parent), original(_original), replacements(_replacements) { } TIntermAggregate *parent; TIntermNode *original; TIntermSequence replacements; }; // To insert multiple nodes on the parent aggregate node struct NodeInsertMultipleEntry { NodeInsertMultipleEntry(TIntermAggregate *_parent, TIntermSequence::size_type _position, TIntermSequence _insertions) : parent(_parent), position(_position), insertions(_insertions) { } TIntermAggregate *parent; TIntermSequence::size_type position; TIntermSequence insertions; }; // During traversing, save all the changes that need to happen into // mReplacements/mMultiReplacements, then do them by calling updateTree(). // Multi replacements are processed after single replacements. std::vector mReplacements; std::vector mMultiReplacements; std::vector mInsertions; // Helper to insert statements in the parent block (sequence) of the node currently being traversed. // The statements will be inserted before the node being traversed once updateTree is called. // Should only be called during PreVisit or PostVisit from sequence nodes. // Note that inserting more than one set of nodes to the same parent node on a single updateTree call is not // supported. void insertStatementsInParentBlock(const TIntermSequence &insertions); // Helper to create a temporary symbol node with the given qualifier. TIntermSymbol *createTempSymbol(const TType &type, TQualifier qualifier); // Helper to create a temporary symbol node. TIntermSymbol *createTempSymbol(const TType &type); // Create a node that declares but doesn't initialize a temporary symbol. TIntermAggregate *createTempDeclaration(const TType &type); // Create a node that initializes the current temporary symbol with initializer having the given qualifier. TIntermAggregate *createTempInitDeclaration(TIntermTyped *initializer, TQualifier qualifier); // Create a node that initializes the current temporary symbol with initializer. TIntermAggregate *createTempInitDeclaration(TIntermTyped *initializer); // Create a node that assigns rightNode to the current temporary symbol. TIntermBinary *createTempAssignment(TIntermTyped *rightNode); // Increment temporary symbol index. void nextTemporaryIndex(); private: struct ParentBlock { ParentBlock(TIntermAggregate *nodeIn, TIntermSequence::size_type posIn) : node(nodeIn), pos(posIn) { } TIntermAggregate *node; TIntermSequence::size_type pos; }; // All the code blocks from the root to the current node's parent during traversal. std::vector mParentBlockStack; unsigned int *mTemporaryIndex; }; // Traverser parent class that tracks where a node is a destination of a write operation and so is // required to be an l-value. class TLValueTrackingTraverser : public TIntermTraverser { public: TLValueTrackingTraverser(bool preVisit, bool inVisit, bool postVisit, const TSymbolTable &symbolTable, int shaderVersion) : TIntermTraverser(preVisit, inVisit, postVisit), mOperatorRequiresLValue(false), mInFunctionCallOutParameter(false), mSymbolTable(symbolTable), mShaderVersion(shaderVersion) { } virtual ~TLValueTrackingTraverser() {} void traverseBinary(TIntermBinary *node) override; void traverseUnary(TIntermUnary *node) override; void traverseAggregate(TIntermAggregate *node) override; protected: bool isLValueRequiredHere() const { return mOperatorRequiresLValue || mInFunctionCallOutParameter; } // Return true if the prototype or definition of the function being called has been encountered // during traversal. bool isInFunctionMap(const TIntermAggregate *callNode) const; private: // Track whether an l-value is required in the node that is currently being traversed by the // surrounding operator. // Use isLValueRequiredHere to check all conditions which require an l-value. void setOperatorRequiresLValue(bool lValueRequired) { mOperatorRequiresLValue = lValueRequired; } bool operatorRequiresLValue() const { return mOperatorRequiresLValue; } // Add a function encountered during traversal to the function map. void addToFunctionMap(const TString &name, TIntermSequence *paramSequence); // Return the parameters sequence from the function definition or prototype. TIntermSequence *getFunctionParameters(const TIntermAggregate *callNode); // Track whether an l-value is required inside a function call. void setInFunctionCallOutParameter(bool inOutParameter); bool isInFunctionCallOutParameter() const; bool mOperatorRequiresLValue; bool mInFunctionCallOutParameter; struct TStringComparator { bool operator()(const TString &a, const TString &b) const { return a.compare(b) < 0; } }; // Map from mangled function names to their parameter sequences TMap mFunctionMap; const TSymbolTable &mSymbolTable; const int mShaderVersion; }; // // For traversing the tree, and computing max depth. // Takes a maximum depth limit to prevent stack overflow. // class TMaxDepthTraverser : public TIntermTraverser { public: POOL_ALLOCATOR_NEW_DELETE(); TMaxDepthTraverser(int depthLimit) : TIntermTraverser(true, true, false), mDepthLimit(depthLimit) { } bool visitBinary(Visit, TIntermBinary *) override { return depthCheck(); } bool visitUnary(Visit, TIntermUnary *) override { return depthCheck(); } bool visitSelection(Visit, TIntermSelection *) override { return depthCheck(); } bool visitAggregate(Visit, TIntermAggregate *) override { return depthCheck(); } bool visitLoop(Visit, TIntermLoop *) override { return depthCheck(); } bool visitBranch(Visit, TIntermBranch *) override { return depthCheck(); } protected: bool depthCheck() const { return mMaxDepth < mDepthLimit; } int mDepthLimit; }; #endif // COMPILER_TRANSLATOR_INTERMNODE_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/IntermTraverse.cpp000066400000000000000000000421251321746453100304060ustar00rootroot00000000000000// // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/IntermNode.h" #include "compiler/translator/InfoSink.h" #include "compiler/translator/SymbolTable.h" void TIntermSymbol::traverse(TIntermTraverser *it) { it->traverseSymbol(this); } void TIntermRaw::traverse(TIntermTraverser *it) { it->traverseRaw(this); } void TIntermConstantUnion::traverse(TIntermTraverser *it) { it->traverseConstantUnion(this); } void TIntermBinary::traverse(TIntermTraverser *it) { it->traverseBinary(this); } void TIntermUnary::traverse(TIntermTraverser *it) { it->traverseUnary(this); } void TIntermSelection::traverse(TIntermTraverser *it) { it->traverseSelection(this); } void TIntermSwitch::traverse(TIntermTraverser *it) { it->traverseSwitch(this); } void TIntermCase::traverse(TIntermTraverser *it) { it->traverseCase(this); } void TIntermAggregate::traverse(TIntermTraverser *it) { it->traverseAggregate(this); } void TIntermLoop::traverse(TIntermTraverser *it) { it->traverseLoop(this); } void TIntermBranch::traverse(TIntermTraverser *it) { it->traverseBranch(this); } void TIntermTraverser::pushParentBlock(TIntermAggregate *node) { mParentBlockStack.push_back(ParentBlock(node, 0)); } void TIntermTraverser::incrementParentBlockPos() { ++mParentBlockStack.back().pos; } void TIntermTraverser::popParentBlock() { ASSERT(!mParentBlockStack.empty()); mParentBlockStack.pop_back(); } void TIntermTraverser::insertStatementsInParentBlock(const TIntermSequence &insertions) { ASSERT(!mParentBlockStack.empty()); NodeInsertMultipleEntry insert(mParentBlockStack.back().node, mParentBlockStack.back().pos, insertions); mInsertions.push_back(insert); } TIntermSymbol *TIntermTraverser::createTempSymbol(const TType &type, TQualifier qualifier) { // Each traversal uses at most one temporary variable, so the index stays the same within a single traversal. TInfoSinkBase symbolNameOut; ASSERT(mTemporaryIndex != nullptr); symbolNameOut << "s" << (*mTemporaryIndex); TString symbolName = symbolNameOut.c_str(); TIntermSymbol *node = new TIntermSymbol(0, symbolName, type); node->setInternal(true); node->getTypePointer()->setQualifier(qualifier); return node; } TIntermSymbol *TIntermTraverser::createTempSymbol(const TType &type) { return createTempSymbol(type, EvqTemporary); } TIntermAggregate *TIntermTraverser::createTempDeclaration(const TType &type) { TIntermAggregate *tempDeclaration = new TIntermAggregate(EOpDeclaration); tempDeclaration->getSequence()->push_back(createTempSymbol(type)); return tempDeclaration; } TIntermAggregate *TIntermTraverser::createTempInitDeclaration(TIntermTyped *initializer, TQualifier qualifier) { ASSERT(initializer != nullptr); TIntermSymbol *tempSymbol = createTempSymbol(initializer->getType(), qualifier); TIntermAggregate *tempDeclaration = new TIntermAggregate(EOpDeclaration); TIntermBinary *tempInit = new TIntermBinary(EOpInitialize); tempInit->setLeft(tempSymbol); tempInit->setRight(initializer); tempInit->setType(tempSymbol->getType()); tempDeclaration->getSequence()->push_back(tempInit); return tempDeclaration; } TIntermAggregate *TIntermTraverser::createTempInitDeclaration(TIntermTyped *initializer) { return createTempInitDeclaration(initializer, EvqTemporary); } TIntermBinary *TIntermTraverser::createTempAssignment(TIntermTyped *rightNode) { ASSERT(rightNode != nullptr); TIntermSymbol *tempSymbol = createTempSymbol(rightNode->getType()); TIntermBinary *assignment = new TIntermBinary(EOpAssign); assignment->setLeft(tempSymbol); assignment->setRight(rightNode); assignment->setType(tempSymbol->getType()); return assignment; } void TIntermTraverser::useTemporaryIndex(unsigned int *temporaryIndex) { mTemporaryIndex = temporaryIndex; } void TIntermTraverser::nextTemporaryIndex() { ASSERT(mTemporaryIndex != nullptr); ++(*mTemporaryIndex); } void TLValueTrackingTraverser::addToFunctionMap(const TString &name, TIntermSequence *paramSequence) { mFunctionMap[name] = paramSequence; } bool TLValueTrackingTraverser::isInFunctionMap(const TIntermAggregate *callNode) const { ASSERT(callNode->getOp() == EOpFunctionCall); return (mFunctionMap.find(callNode->getName()) != mFunctionMap.end()); } TIntermSequence *TLValueTrackingTraverser::getFunctionParameters(const TIntermAggregate *callNode) { ASSERT(isInFunctionMap(callNode)); return mFunctionMap[callNode->getName()]; } void TLValueTrackingTraverser::setInFunctionCallOutParameter(bool inOutParameter) { mInFunctionCallOutParameter = inOutParameter; } bool TLValueTrackingTraverser::isInFunctionCallOutParameter() const { return mInFunctionCallOutParameter; } // // Traverse the intermediate representation tree, and // call a node type specific function for each node. // Done recursively through the member function Traverse(). // Node types can be skipped if their function to call is 0, // but their subtree will still be traversed. // Nodes with children can have their whole subtree skipped // if preVisit is turned on and the type specific function // returns false. // // // Traversal functions for terminals are straighforward.... // void TIntermTraverser::traverseSymbol(TIntermSymbol *node) { visitSymbol(node); } void TIntermTraverser::traverseConstantUnion(TIntermConstantUnion *node) { visitConstantUnion(node); } // // Traverse a binary node. // void TIntermTraverser::traverseBinary(TIntermBinary *node) { bool visit = true; // // visit the node before children if pre-visiting. // if (preVisit) visit = visitBinary(PreVisit, node); // // Visit the children, in the right order. // if (visit) { incrementDepth(node); if (node->getLeft()) node->getLeft()->traverse(this); if (inVisit) visit = visitBinary(InVisit, node); if (visit && node->getRight()) node->getRight()->traverse(this); decrementDepth(); } // // Visit the node after the children, if requested and the traversal // hasn't been cancelled yet. // if (visit && postVisit) visitBinary(PostVisit, node); } void TLValueTrackingTraverser::traverseBinary(TIntermBinary *node) { bool visit = true; // // visit the node before children if pre-visiting. // if (preVisit) visit = visitBinary(PreVisit, node); // // Visit the children, in the right order. // if (visit) { incrementDepth(node); // Some binary operations like indexing can be inside an expression which must be an // l-value. bool parentOperatorRequiresLValue = operatorRequiresLValue(); bool parentInFunctionCallOutParameter = isInFunctionCallOutParameter(); if (node->isAssignment()) { ASSERT(!isLValueRequiredHere()); setOperatorRequiresLValue(true); } if (node->getLeft()) node->getLeft()->traverse(this); if (inVisit) visit = visitBinary(InVisit, node); if (node->isAssignment()) setOperatorRequiresLValue(false); // Index is not required to be an l-value even when the surrounding expression is required // to be an l-value. TOperator op = node->getOp(); if (op == EOpIndexDirect || op == EOpIndexDirectInterfaceBlock || op == EOpIndexDirectStruct || op == EOpIndexIndirect) { setOperatorRequiresLValue(false); setInFunctionCallOutParameter(false); } if (visit && node->getRight()) node->getRight()->traverse(this); setOperatorRequiresLValue(parentOperatorRequiresLValue); setInFunctionCallOutParameter(parentInFunctionCallOutParameter); decrementDepth(); } // // Visit the node after the children, if requested and the traversal // hasn't been cancelled yet. // if (visit && postVisit) visitBinary(PostVisit, node); } // // Traverse a unary node. Same comments in binary node apply here. // void TIntermTraverser::traverseUnary(TIntermUnary *node) { bool visit = true; if (preVisit) visit = visitUnary(PreVisit, node); if (visit) { incrementDepth(node); node->getOperand()->traverse(this); decrementDepth(); } if (visit && postVisit) visitUnary(PostVisit, node); } void TLValueTrackingTraverser::traverseUnary(TIntermUnary *node) { bool visit = true; if (preVisit) visit = visitUnary(PreVisit, node); if (visit) { incrementDepth(node); ASSERT(!operatorRequiresLValue()); switch (node->getOp()) { case EOpPostIncrement: case EOpPostDecrement: case EOpPreIncrement: case EOpPreDecrement: setOperatorRequiresLValue(true); break; default: break; } node->getOperand()->traverse(this); setOperatorRequiresLValue(false); decrementDepth(); } if (visit && postVisit) visitUnary(PostVisit, node); } // // Traverse an aggregate node. Same comments in binary node apply here. // void TIntermTraverser::traverseAggregate(TIntermAggregate *node) { bool visit = true; TIntermSequence *sequence = node->getSequence(); if (preVisit) visit = visitAggregate(PreVisit, node); if (visit) { incrementDepth(node); if (node->getOp() == EOpSequence) pushParentBlock(node); for (auto *child : *sequence) { child->traverse(this); if (visit && inVisit) { if (child != sequence->back()) visit = visitAggregate(InVisit, node); } if (node->getOp() == EOpSequence) incrementParentBlockPos(); } if (node->getOp() == EOpSequence) popParentBlock(); decrementDepth(); } if (visit && postVisit) visitAggregate(PostVisit, node); } void TLValueTrackingTraverser::traverseAggregate(TIntermAggregate *node) { bool visit = true; TIntermSequence *sequence = node->getSequence(); switch (node->getOp()) { case EOpFunction: { TIntermAggregate *params = sequence->front()->getAsAggregate(); ASSERT(params != nullptr); ASSERT(params->getOp() == EOpParameters); addToFunctionMap(node->getName(), params->getSequence()); break; } case EOpPrototype: addToFunctionMap(node->getName(), sequence); break; default: break; } if (preVisit) visit = visitAggregate(PreVisit, node); if (visit) { bool inFunctionMap = false; if (node->getOp() == EOpFunctionCall) { inFunctionMap = isInFunctionMap(node); if (!inFunctionMap) { // The function is not user-defined - it is likely built-in texture function. // Assume that those do not have out parameters. setInFunctionCallOutParameter(false); } } incrementDepth(node); if (inFunctionMap) { TIntermSequence *params = getFunctionParameters(node); TIntermSequence::iterator paramIter = params->begin(); for (auto *child : *sequence) { ASSERT(paramIter != params->end()); TQualifier qualifier = (*paramIter)->getAsTyped()->getQualifier(); setInFunctionCallOutParameter(qualifier == EvqOut || qualifier == EvqInOut); child->traverse(this); if (visit && inVisit) { if (child != sequence->back()) visit = visitAggregate(InVisit, node); } ++paramIter; } setInFunctionCallOutParameter(false); } else { if (node->getOp() == EOpSequence) pushParentBlock(node); // Find the built-in function corresponding to this op so that we can determine the // in/out qualifiers of its parameters. TFunction *builtInFunc = nullptr; TString opString = GetOperatorString(node->getOp()); if (!node->isConstructor() && !opString.empty()) { // The return type doesn't affect the mangled name of the function, which is used // to look it up from the symbol table. TType dummyReturnType; TFunction call(&opString, &dummyReturnType, node->getOp()); for (auto *child : *sequence) { TType *paramType = child->getAsTyped()->getTypePointer(); TConstParameter p(paramType); call.addParameter(p); } TSymbol *sym = mSymbolTable.findBuiltIn(call.getMangledName(), mShaderVersion); if (sym != nullptr && sym->isFunction()) { builtInFunc = static_cast(sym); ASSERT(builtInFunc->getParamCount() == sequence->size()); } } size_t paramIndex = 0; for (auto *child : *sequence) { TQualifier qualifier = EvqIn; if (builtInFunc != nullptr) qualifier = builtInFunc->getParam(paramIndex).type->getQualifier(); setInFunctionCallOutParameter(qualifier == EvqOut || qualifier == EvqInOut); child->traverse(this); if (visit && inVisit) { if (child != sequence->back()) visit = visitAggregate(InVisit, node); } if (node->getOp() == EOpSequence) incrementParentBlockPos(); ++paramIndex; } setInFunctionCallOutParameter(false); if (node->getOp() == EOpSequence) popParentBlock(); } decrementDepth(); } if (visit && postVisit) visitAggregate(PostVisit, node); } // // Traverse a selection node. Same comments in binary node apply here. // void TIntermTraverser::traverseSelection(TIntermSelection *node) { bool visit = true; if (preVisit) visit = visitSelection(PreVisit, node); if (visit) { incrementDepth(node); node->getCondition()->traverse(this); if (node->getTrueBlock()) node->getTrueBlock()->traverse(this); if (node->getFalseBlock()) node->getFalseBlock()->traverse(this); decrementDepth(); } if (visit && postVisit) visitSelection(PostVisit, node); } // // Traverse a switch node. Same comments in binary node apply here. // void TIntermTraverser::traverseSwitch(TIntermSwitch *node) { bool visit = true; if (preVisit) visit = visitSwitch(PreVisit, node); if (visit) { incrementDepth(node); node->getInit()->traverse(this); if (inVisit) visit = visitSwitch(InVisit, node); if (visit && node->getStatementList()) node->getStatementList()->traverse(this); decrementDepth(); } if (visit && postVisit) visitSwitch(PostVisit, node); } // // Traverse a case node. Same comments in binary node apply here. // void TIntermTraverser::traverseCase(TIntermCase *node) { bool visit = true; if (preVisit) visit = visitCase(PreVisit, node); if (visit && node->getCondition()) node->getCondition()->traverse(this); if (visit && postVisit) visitCase(PostVisit, node); } // // Traverse a loop node. Same comments in binary node apply here. // void TIntermTraverser::traverseLoop(TIntermLoop *node) { bool visit = true; if (preVisit) visit = visitLoop(PreVisit, node); if (visit) { incrementDepth(node); if (node->getInit()) node->getInit()->traverse(this); if (node->getCondition()) node->getCondition()->traverse(this); if (node->getBody()) node->getBody()->traverse(this); if (node->getExpression()) node->getExpression()->traverse(this); decrementDepth(); } if (visit && postVisit) visitLoop(PostVisit, node); } // // Traverse a branch node. Same comments in binary node apply here. // void TIntermTraverser::traverseBranch(TIntermBranch *node) { bool visit = true; if (preVisit) visit = visitBranch(PreVisit, node); if (visit && node->getExpression()) { incrementDepth(node); node->getExpression()->traverse(this); decrementDepth(); } if (visit && postVisit) visitBranch(PostVisit, node); } void TIntermTraverser::traverseRaw(TIntermRaw *node) { visitRaw(node); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/Intermediate.cpp000066400000000000000000000314101321746453100300410ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // // Build the intermediate representation. // #include #include #include #include "compiler/translator/Intermediate.h" #include "compiler/translator/SymbolTable.h" //////////////////////////////////////////////////////////////////////////// // // First set of functions are to help build the intermediate representation. // These functions are not member functions of the nodes. // They are called from parser productions. // ///////////////////////////////////////////////////////////////////////////// // // Add a terminal node for an identifier in an expression. // // Returns the added node. // TIntermSymbol *TIntermediate::addSymbol( int id, const TString &name, const TType &type, const TSourceLoc &line) { TIntermSymbol *node = new TIntermSymbol(id, name, type); node->setLine(line); return node; } // // Connect two nodes with a new parent that does a binary operation on the nodes. // // Returns the added node. // TIntermTyped *TIntermediate::addBinaryMath( TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &line) { // // Need a new node holding things together then. Make // one and promote it to the right type. // TIntermBinary *node = new TIntermBinary(op); node->setLine(line); node->setLeft(left); node->setRight(right); if (!node->promote(mInfoSink)) return NULL; // See if we can fold constants. TIntermTyped *foldedNode = node->fold(mInfoSink); if (foldedNode) return foldedNode; return node; } // // Connect two nodes through an assignment. // // Returns the added node. // TIntermTyped *TIntermediate::addAssign( TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &line) { if (left->getType().getStruct() || right->getType().getStruct()) { if (left->getType() != right->getType()) { return NULL; } } TIntermBinary *node = new TIntermBinary(op); node->setLine(line); node->setLeft(left); node->setRight(right); if (!node->promote(mInfoSink)) return NULL; return node; } // // Connect two nodes through an index operator, where the left node is the base // of an array or struct, and the right node is a direct or indirect offset. // // Returns the added node. // The caller should set the type of the returned node. // TIntermTyped *TIntermediate::addIndex( TOperator op, TIntermTyped *base, TIntermTyped *index, const TSourceLoc &line) { TIntermBinary *node = new TIntermBinary(op); node->setLine(line); node->setLeft(base); node->setRight(index); // caller should set the type return node; } // // Add one node as the parent of another that it operates on. // // Returns the added node. // TIntermTyped *TIntermediate::addUnaryMath( TOperator op, TIntermTyped *child, const TSourceLoc &line, const TType *funcReturnType) { // // Make a new node for the operator. // TIntermUnary *node = new TIntermUnary(op); node->setLine(line); node->setOperand(child); node->promote(funcReturnType); TIntermTyped *foldedNode = node->fold(mInfoSink); if (foldedNode) return foldedNode; return node; } // // This is the safe way to change the operator on an aggregate, as it // does lots of error checking and fixing. Especially for establishing // a function call's operation on it's set of parameters. Sequences // of instructions are also aggregates, but they just direnctly set // their operator to EOpSequence. // // Returns an aggregate node, which could be the one passed in if // it was already an aggregate but no operator was set. // TIntermAggregate *TIntermediate::setAggregateOperator( TIntermNode *node, TOperator op, const TSourceLoc &line) { TIntermAggregate *aggNode; // // Make sure we have an aggregate. If not turn it into one. // if (node) { aggNode = node->getAsAggregate(); if (aggNode == NULL || aggNode->getOp() != EOpNull) { // // Make an aggregate containing this node. // aggNode = new TIntermAggregate(); aggNode->getSequence()->push_back(node); } } else { aggNode = new TIntermAggregate(); } // // Set the operator. // aggNode->setOp(op); aggNode->setLine(line); return aggNode; } // // Safe way to combine two nodes into an aggregate. Works with null pointers, // a node that's not a aggregate yet, etc. // // Returns the resulting aggregate, unless 0 was passed in for // both existing nodes. // TIntermAggregate *TIntermediate::growAggregate( TIntermNode *left, TIntermNode *right, const TSourceLoc &line) { if (left == NULL && right == NULL) return NULL; TIntermAggregate *aggNode = NULL; if (left) aggNode = left->getAsAggregate(); if (!aggNode || aggNode->getOp() != EOpNull) { aggNode = new TIntermAggregate; if (left) aggNode->getSequence()->push_back(left); } if (right) aggNode->getSequence()->push_back(right); aggNode->setLine(line); return aggNode; } // // Turn an existing node into an aggregate. // // Returns an aggregate, unless NULL was passed in for the existing node. // TIntermAggregate *TIntermediate::makeAggregate( TIntermNode *node, const TSourceLoc &line) { if (node == NULL) return NULL; TIntermAggregate *aggNode = new TIntermAggregate; aggNode->getSequence()->push_back(node); aggNode->setLine(line); return aggNode; } // If the input node is nullptr, return nullptr. // If the input node is a sequence (block) node, return it. // If the input node is not a sequence node, put it inside a sequence node and return that. TIntermAggregate *TIntermediate::ensureSequence(TIntermNode *node) { if (node == nullptr) return nullptr; TIntermAggregate *aggNode = node->getAsAggregate(); if (aggNode != nullptr && aggNode->getOp() == EOpSequence) return aggNode; aggNode = makeAggregate(node, node->getLine()); aggNode->setOp(EOpSequence); return aggNode; } // // For "if" test nodes. There are three children; a condition, // a true path, and a false path. The two paths are in the // nodePair. // // Returns the selection node created. // TIntermNode *TIntermediate::addSelection( TIntermTyped *cond, TIntermNodePair nodePair, const TSourceLoc &line) { // // For compile time constant selections, prune the code and // test now. // if (cond->getAsTyped() && cond->getAsTyped()->getAsConstantUnion()) { if (cond->getAsConstantUnion()->getBConst(0) == true) { return nodePair.node1 ? setAggregateOperator( nodePair.node1, EOpSequence, nodePair.node1->getLine()) : NULL; } else { return nodePair.node2 ? setAggregateOperator( nodePair.node2, EOpSequence, nodePair.node2->getLine()) : NULL; } } TIntermSelection *node = new TIntermSelection( cond, ensureSequence(nodePair.node1), ensureSequence(nodePair.node2)); node->setLine(line); return node; } TIntermTyped *TIntermediate::addComma( TIntermTyped *left, TIntermTyped *right, const TSourceLoc &line) { if (left->getType().getQualifier() == EvqConst && right->getType().getQualifier() == EvqConst) { return right; } else { TIntermTyped *commaAggregate = growAggregate(left, right, line); commaAggregate->getAsAggregate()->setOp(EOpComma); commaAggregate->setType(right->getType()); commaAggregate->getTypePointer()->setQualifier(EvqTemporary); return commaAggregate; } } // // For "?:" test nodes. There are three children; a condition, // a true path, and a false path. The two paths are specified // as separate parameters. // // Returns the selection node created, or one of trueBlock and falseBlock if the expression could be folded. // TIntermTyped *TIntermediate::addSelection(TIntermTyped *cond, TIntermTyped *trueBlock, TIntermTyped *falseBlock, const TSourceLoc &line) { // Right now it's safe to fold ternary operators only when all operands // are constant. If only the condition is constant, it's theoretically // possible to fold the ternary operator, but that requires making sure // that the node returned from here won't be treated as a constant // expression in case the node that gets eliminated was not a constant // expression. if (cond->getAsConstantUnion() && trueBlock->getAsConstantUnion() && falseBlock->getAsConstantUnion()) { if (cond->getAsConstantUnion()->getBConst(0)) return trueBlock; else return falseBlock; } // // Make a selection node. // TIntermSelection *node = new TIntermSelection(cond, trueBlock, falseBlock, trueBlock->getType()); node->getTypePointer()->setQualifier(EvqTemporary); node->setLine(line); return node; } TIntermSwitch *TIntermediate::addSwitch( TIntermTyped *init, TIntermAggregate *statementList, const TSourceLoc &line) { TIntermSwitch *node = new TIntermSwitch(init, statementList); node->setLine(line); return node; } TIntermCase *TIntermediate::addCase( TIntermTyped *condition, const TSourceLoc &line) { TIntermCase *node = new TIntermCase(condition); node->setLine(line); return node; } // // Constant terminal nodes. Has a union that contains bool, float or int constants // // Returns the constant union node created. // TIntermConstantUnion *TIntermediate::addConstantUnion( TConstantUnion *constantUnion, const TType &type, const TSourceLoc &line) { TIntermConstantUnion *node = new TIntermConstantUnion(constantUnion, type); node->setLine(line); return node; } TIntermTyped *TIntermediate::addSwizzle( TVectorFields &fields, const TSourceLoc &line) { TIntermAggregate *node = new TIntermAggregate(EOpSequence); node->setLine(line); TIntermConstantUnion *constIntNode; TIntermSequence *sequenceVector = node->getSequence(); TConstantUnion *unionArray; for (int i = 0; i < fields.num; i++) { unionArray = new TConstantUnion[1]; unionArray->setIConst(fields.offsets[i]); constIntNode = addConstantUnion( unionArray, TType(EbtInt, EbpUndefined, EvqConst), line); sequenceVector->push_back(constIntNode); } return node; } // // Create loop nodes. // TIntermNode *TIntermediate::addLoop( TLoopType type, TIntermNode *init, TIntermTyped *cond, TIntermTyped *expr, TIntermNode *body, const TSourceLoc &line) { TIntermNode *node = new TIntermLoop(type, init, cond, expr, ensureSequence(body)); node->setLine(line); return node; } // // Add branches. // TIntermBranch* TIntermediate::addBranch( TOperator branchOp, const TSourceLoc &line) { return addBranch(branchOp, 0, line); } TIntermBranch* TIntermediate::addBranch( TOperator branchOp, TIntermTyped *expression, const TSourceLoc &line) { TIntermBranch *node = new TIntermBranch(branchOp, expression); node->setLine(line); return node; } // // This is to be executed once the final root is put on top by the parsing // process. // TIntermAggregate *TIntermediate::postProcess(TIntermNode *root) { if (root == nullptr) return nullptr; // // Finish off the top level sequence, if any // TIntermAggregate *aggRoot = root->getAsAggregate(); if (aggRoot != nullptr && aggRoot->getOp() == EOpNull) { aggRoot->setOp(EOpSequence); } else if (aggRoot == nullptr || aggRoot->getOp() != EOpSequence) { aggRoot = new TIntermAggregate(EOpSequence); aggRoot->setLine(root->getLine()); aggRoot->getSequence()->push_back(root); } return aggRoot; } TIntermTyped *TIntermediate::foldAggregateBuiltIn(TIntermAggregate *aggregate) { switch (aggregate->getOp()) { case EOpAtan: case EOpPow: case EOpMod: case EOpMin: case EOpMax: case EOpClamp: case EOpMix: case EOpStep: case EOpSmoothStep: case EOpMul: case EOpOuterProduct: case EOpLessThan: case EOpLessThanEqual: case EOpGreaterThan: case EOpGreaterThanEqual: case EOpVectorEqual: case EOpVectorNotEqual: case EOpDistance: case EOpDot: case EOpCross: case EOpFaceForward: case EOpReflect: case EOpRefract: return aggregate->fold(mInfoSink); default: // Constant folding not supported for the built-in. return nullptr; } return nullptr; } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/Intermediate.h000066400000000000000000000056511321746453100275160ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_INTERMEDIATE_H_ #define COMPILER_TRANSLATOR_INTERMEDIATE_H_ #include "compiler/translator/IntermNode.h" struct TVectorFields { int offsets[4]; int num; }; // // Set of helper functions to help parse and build the tree. // class TInfoSink; class TIntermediate { public: POOL_ALLOCATOR_NEW_DELETE(); TIntermediate(TInfoSink &i) : mInfoSink(i) { } TIntermSymbol *addSymbol( int id, const TString &, const TType &, const TSourceLoc &); TIntermTyped *addBinaryMath( TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &); TIntermTyped *addAssign( TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &); TIntermTyped *addIndex( TOperator op, TIntermTyped *base, TIntermTyped *index, const TSourceLoc &); TIntermTyped *addUnaryMath( TOperator op, TIntermTyped *child, const TSourceLoc &line, const TType *funcReturnType); TIntermAggregate *growAggregate( TIntermNode *left, TIntermNode *right, const TSourceLoc &); TIntermAggregate *makeAggregate(TIntermNode *node, const TSourceLoc &); TIntermAggregate *ensureSequence(TIntermNode *node); TIntermAggregate *setAggregateOperator(TIntermNode *, TOperator, const TSourceLoc &); TIntermNode *addSelection(TIntermTyped *cond, TIntermNodePair code, const TSourceLoc &); TIntermTyped *addSelection(TIntermTyped *cond, TIntermTyped *trueBlock, TIntermTyped *falseBlock, const TSourceLoc &line); TIntermSwitch *addSwitch( TIntermTyped *init, TIntermAggregate *statementList, const TSourceLoc &line); TIntermCase *addCase( TIntermTyped *condition, const TSourceLoc &line); TIntermTyped *addComma( TIntermTyped *left, TIntermTyped *right, const TSourceLoc &); TIntermConstantUnion *addConstantUnion( TConstantUnion *constantUnion, const TType &type, const TSourceLoc &line); // TODO(zmo): Get rid of default value. bool parseConstTree(const TSourceLoc &, TIntermNode *, TConstantUnion *, TOperator, TType, bool singleConstantParam = false); TIntermNode *addLoop(TLoopType, TIntermNode *, TIntermTyped *, TIntermTyped *, TIntermNode *, const TSourceLoc &); TIntermBranch *addBranch(TOperator, const TSourceLoc &); TIntermBranch *addBranch(TOperator, TIntermTyped *, const TSourceLoc &); TIntermTyped *addSwizzle(TVectorFields &, const TSourceLoc &); TIntermAggregate *postProcess(TIntermNode *root); TIntermTyped *foldAggregateBuiltIn(TIntermAggregate *aggregate); private: void operator=(TIntermediate &); // prevent assignments TInfoSink & mInfoSink; }; #endif // COMPILER_TRANSLATOR_INTERMEDIATE_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/LoopInfo.cpp000066400000000000000000000117321321746453100271610ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/LoopInfo.h" namespace { int EvaluateIntConstant(TIntermConstantUnion *node) { ASSERT(node && node->getUnionArrayPointer()); return node->getIConst(0); } int GetLoopIntIncrement(TIntermLoop *node) { TIntermNode *expr = node->getExpression(); // for expression has one of the following forms: // loop_index++ // loop_index-- // loop_index += constant_expression // loop_index -= constant_expression // ++loop_index // --loop_index // The last two forms are not specified in the spec, but I am assuming // its an oversight. TIntermUnary *unOp = expr->getAsUnaryNode(); TIntermBinary *binOp = unOp ? NULL : expr->getAsBinaryNode(); TOperator op = EOpNull; TIntermConstantUnion *incrementNode = NULL; if (unOp) { op = unOp->getOp(); } else if (binOp) { op = binOp->getOp(); ASSERT(binOp->getRight()); incrementNode = binOp->getRight()->getAsConstantUnion(); ASSERT(incrementNode); } int increment = 0; // The operator is one of: ++ -- += -=. switch (op) { case EOpPostIncrement: case EOpPreIncrement: ASSERT(unOp && !binOp); increment = 1; break; case EOpPostDecrement: case EOpPreDecrement: ASSERT(unOp && !binOp); increment = -1; break; case EOpAddAssign: ASSERT(!unOp && binOp); increment = EvaluateIntConstant(incrementNode); break; case EOpSubAssign: ASSERT(!unOp && binOp); increment = - EvaluateIntConstant(incrementNode); break; default: UNREACHABLE(); } return increment; } } // namespace anonymous TLoopIndexInfo::TLoopIndexInfo() : mId(-1), mType(EbtVoid), mInitValue(0), mStopValue(0), mIncrementValue(0), mOp(EOpNull), mCurrentValue(0) { } void TLoopIndexInfo::fillInfo(TIntermLoop *node) { if (node == NULL) return; // Here we assume all the operations are valid, because the loop node is // already validated in ValidateLimitations. TIntermSequence *declSeq = node->getInit()->getAsAggregate()->getSequence(); TIntermBinary *declInit = (*declSeq)[0]->getAsBinaryNode(); TIntermSymbol *symbol = declInit->getLeft()->getAsSymbolNode(); mId = symbol->getId(); mType = symbol->getBasicType(); if (mType == EbtInt) { TIntermConstantUnion* initNode = declInit->getRight()->getAsConstantUnion(); mInitValue = EvaluateIntConstant(initNode); mCurrentValue = mInitValue; mIncrementValue = GetLoopIntIncrement(node); TIntermBinary* binOp = node->getCondition()->getAsBinaryNode(); mStopValue = EvaluateIntConstant( binOp->getRight()->getAsConstantUnion()); mOp = binOp->getOp(); } } bool TLoopIndexInfo::satisfiesLoopCondition() const { // Relational operator is one of: > >= < <= == or !=. switch (mOp) { case EOpEqual: return (mCurrentValue == mStopValue); case EOpNotEqual: return (mCurrentValue != mStopValue); case EOpLessThan: return (mCurrentValue < mStopValue); case EOpGreaterThan: return (mCurrentValue > mStopValue); case EOpLessThanEqual: return (mCurrentValue <= mStopValue); case EOpGreaterThanEqual: return (mCurrentValue >= mStopValue); default: UNREACHABLE(); return false; } } TLoopInfo::TLoopInfo() : loop(NULL) { } TLoopInfo::TLoopInfo(TIntermLoop *node) : loop(node) { index.fillInfo(node); } TIntermLoop *TLoopStack::findLoop(TIntermSymbol *symbol) { if (!symbol) return NULL; for (iterator iter = begin(); iter != end(); ++iter) { if (iter->index.getId() == symbol->getId()) return iter->loop; } return NULL; } TLoopIndexInfo *TLoopStack::getIndexInfo(TIntermSymbol *symbol) { if (!symbol) return NULL; for (iterator iter = begin(); iter != end(); ++iter) { if (iter->index.getId() == symbol->getId()) return &(iter->index); } return NULL; } void TLoopStack::step() { ASSERT(!empty()); rbegin()->index.step(); } bool TLoopStack::satisfiesLoopCondition() { ASSERT(!empty()); return rbegin()->index.satisfiesLoopCondition(); } bool TLoopStack::needsToReplaceSymbolWithValue(TIntermSymbol *symbol) { TIntermLoop *loop = findLoop(symbol); return loop && loop->getUnrollFlag(); } int TLoopStack::getLoopIndexValue(TIntermSymbol *symbol) { TLoopIndexInfo *info = getIndexInfo(symbol); ASSERT(info); return info->getCurrentValue(); } void TLoopStack::push(TIntermLoop *loop) { TLoopInfo info(loop); push_back(info); } void TLoopStack::pop() { pop_back(); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/LoopInfo.h000066400000000000000000000041631321746453100266260ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_LOOPINFO_H_ #define COMPILER_TRANSLATOR_LOOPINFO_H_ #include "compiler/translator/IntermNode.h" class TLoopIndexInfo { public: TLoopIndexInfo(); // If type is EbtInt, fill all fields of the structure with info // extracted from a loop node. // If type is not EbtInt, only fill id and type. void fillInfo(TIntermLoop *node); int getId() const { return mId; } void setId(int id) { mId = id; } TBasicType getType() const { return mType; } void setType(TBasicType type) { mType = type; } int getCurrentValue() const { return mCurrentValue; } void step() { mCurrentValue += mIncrementValue; } // Check if the current value satisfies the loop condition. bool satisfiesLoopCondition() const; private: int mId; TBasicType mType; // Either EbtInt or EbtFloat // Below fields are only valid if the index's type is int. int mInitValue; int mStopValue; int mIncrementValue; TOperator mOp; int mCurrentValue; }; struct TLoopInfo { TLoopIndexInfo index; TIntermLoop *loop; TLoopInfo(); TLoopInfo(TIntermLoop *node); }; class TLoopStack : public TVector { public: // Search loop stack for a loop whose index matches the input symbol. TIntermLoop *findLoop(TIntermSymbol *symbol); // Find the loop index info in the loop stack by the input symbol. TLoopIndexInfo *getIndexInfo(TIntermSymbol *symbol); // Update the currentValue for the next loop iteration. void step(); // Return false if loop condition is no longer satisfied. bool satisfiesLoopCondition(); // Check if the symbol is the index of a loop that's unrolled. bool needsToReplaceSymbolWithValue(TIntermSymbol *symbol); // Return the current value of a given loop index symbol. int getLoopIndexValue(TIntermSymbol *symbol); void push(TIntermLoop *info); void pop(); }; #endif // COMPILER_TRANSLATOR_LOOPINFO_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/MMap.h000066400000000000000000000024731321746453100257350ustar00rootroot00000000000000// // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_MMAP_H_ #define COMPILER_TRANSLATOR_MMAP_H_ // // Encapsulate memory mapped files // class TMMap { public: TMMap(const char* fileName) : fSize(-1), // -1 is the error value returned by GetFileSize() fp(NULL), fBuff(0) // 0 is the error value returned by MapViewOfFile() { if ((fp = fopen(fileName, "r")) == NULL) return; char c = getc(fp); fSize = 0; while (c != EOF) { fSize++; c = getc(fp); } if (c == EOF) fSize++; rewind(fp); fBuff = (char*)malloc(sizeof(char) * fSize); int count = 0; c = getc(fp); while (c != EOF) { fBuff[count++] = c; c = getc(fp); } fBuff[count++] = c; } char* getData() { return fBuff; } int getSize() { return fSize; } ~TMMap() { if (fp != NULL) fclose(fp); } private: int fSize; // size of file to map in FILE *fp; char* fBuff; // the actual data; }; #endif // COMPILER_TRANSLATOR_MMAP_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/NodeSearch.h000066400000000000000000000022761321746453100271170ustar00rootroot00000000000000// // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // NodeSearch.h: Utilities for searching translator node graphs // #ifndef COMPILER_TRANSLATOR_NODESEARCH_H_ #define COMPILER_TRANSLATOR_NODESEARCH_H_ #include "compiler/translator/IntermNode.h" namespace sh { template class NodeSearchTraverser : public TIntermTraverser { public: NodeSearchTraverser() : TIntermTraverser(true, false, false), mFound(false) {} bool found() const { return mFound; } static bool search(TIntermNode *node) { Parent searchTraverser; node->traverse(&searchTraverser); return searchTraverser.found(); } protected: bool mFound; }; class FindDiscard : public NodeSearchTraverser { public: virtual bool visitBranch(Visit visit, TIntermBranch *node) { switch (node->getFlowOp()) { case EOpKill: mFound = true; break; default: break; } return !mFound; } }; } #endif // COMPILER_TRANSLATOR_NODESEARCH_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/Operator.cpp000066400000000000000000000151151321746453100272260ustar00rootroot00000000000000// // Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/Operator.h" const char *GetOperatorString(TOperator op) { switch (op) { // Note: ops from EOpNull to EOpPrototype can't be handled here. case EOpNegative: return "-"; case EOpPositive: return "+"; case EOpLogicalNot: return "!"; case EOpVectorLogicalNot: return "not"; case EOpBitwiseNot: return "~"; case EOpPostIncrement: return "++"; case EOpPostDecrement: return "--"; case EOpPreIncrement: return "++"; case EOpPreDecrement: return "--"; case EOpAdd: return "+"; case EOpSub: return "-"; case EOpMul: return "*"; case EOpDiv: return "/"; case EOpIMod: return "%"; case EOpEqual: return "=="; case EOpNotEqual: return "!="; case EOpVectorEqual: return "equal"; case EOpVectorNotEqual: return "notEqual"; case EOpLessThan: return "<"; case EOpGreaterThan: return ">"; case EOpLessThanEqual: return "<="; case EOpGreaterThanEqual: return ">="; case EOpComma: return ","; // Fall-through. case EOpVectorTimesScalar: case EOpVectorTimesMatrix: case EOpMatrixTimesVector: case EOpMatrixTimesScalar: return "*"; case EOpLogicalOr: return "||"; case EOpLogicalXor: return "^^"; case EOpLogicalAnd: return "&&"; case EOpBitShiftLeft: return "<<"; case EOpBitShiftRight: return ">>"; case EOpBitwiseAnd: return "&"; case EOpBitwiseXor: return "^"; case EOpBitwiseOr: return "|"; // Fall-through. case EOpIndexDirect: case EOpIndexIndirect: return "[]"; case EOpIndexDirectStruct: case EOpIndexDirectInterfaceBlock: return "."; case EOpVectorSwizzle: return "."; case EOpRadians: return "radians"; case EOpDegrees: return "degrees"; case EOpSin: return "sin"; case EOpCos: return "cos"; case EOpTan: return "tan"; case EOpAsin: return "asin"; case EOpAcos: return "acos"; case EOpAtan: return "atan"; case EOpSinh: return "sinh"; case EOpCosh: return "cosh"; case EOpTanh: return "tanh"; case EOpAsinh: return "asinh"; case EOpAcosh: return "acosh"; case EOpAtanh: return "atanh"; case EOpPow: return "pow"; case EOpExp: return "exp"; case EOpLog: return "log"; case EOpExp2: return "exp2"; case EOpLog2: return "log2"; case EOpSqrt: return "sqrt"; case EOpInverseSqrt: return "inversesqrt"; case EOpAbs: return "abs"; case EOpSign: return "sign"; case EOpFloor: return "floor"; case EOpTrunc: return "trunc"; case EOpRound: return "round"; case EOpRoundEven: return "roundEven"; case EOpCeil: return "ceil"; case EOpFract: return "fract"; case EOpMod: return "mod"; case EOpModf: return "modf"; case EOpMin: return "min"; case EOpMax: return "max"; case EOpClamp: return "clamp"; case EOpMix: return "mix"; case EOpStep: return "step"; case EOpSmoothStep: return "smoothstep"; case EOpIsNan: return "isnan"; case EOpIsInf: return "isinf"; case EOpFloatBitsToInt: return "floatBitsToInt"; case EOpFloatBitsToUint: return "floatBitsToUint"; case EOpIntBitsToFloat: return "intBitsToFloat"; case EOpUintBitsToFloat: return "uintBitsToFloat"; case EOpPackSnorm2x16: return "packSnorm2x16"; case EOpPackUnorm2x16: return "packUnorm2x16"; case EOpPackHalf2x16: return "packHalf2x16"; case EOpUnpackSnorm2x16: return "unpackSnorm2x16"; case EOpUnpackUnorm2x16: return "unpackUnorm2x16"; case EOpUnpackHalf2x16: return "unpackHalf2x16"; case EOpLength: return "length"; case EOpDistance: return "distance"; case EOpDot: return "dot"; case EOpCross: return "cross"; case EOpNormalize: return "normalize"; case EOpFaceForward: return "faceforward"; case EOpReflect: return "reflect"; case EOpRefract: return "refract"; case EOpDFdx: return "dFdx"; case EOpDFdy: return "dFdy"; case EOpFwidth: return "fwidth"; case EOpMatrixTimesMatrix: return "*"; case EOpOuterProduct: return "outerProduct"; case EOpTranspose: return "transpose"; case EOpDeterminant: return "determinant"; case EOpInverse: return "inverse"; case EOpAny: return "any"; case EOpAll: return "all"; case EOpKill: return "kill"; case EOpReturn: return "return"; case EOpBreak: return "break"; case EOpContinue: return "continue"; case EOpConstructInt: return "int"; case EOpConstructUInt: return "uint"; case EOpConstructBool: return "bool"; case EOpConstructFloat: return "float"; case EOpConstructVec2: return "vec2"; case EOpConstructVec3: return "vec3"; case EOpConstructVec4: return "vec4"; case EOpConstructBVec2: return "bvec2"; case EOpConstructBVec3: return "bvec3"; case EOpConstructBVec4: return "bvec4"; case EOpConstructIVec2: return "ivec2"; case EOpConstructIVec3: return "ivec3"; case EOpConstructIVec4: return "ivec4"; case EOpConstructUVec2: return "uvec2"; case EOpConstructUVec3: return "uvec3"; case EOpConstructUVec4: return "uvec4"; case EOpConstructMat2: return "mat2"; case EOpConstructMat2x3: return "mat2x3"; case EOpConstructMat2x4: return "mat2x4"; case EOpConstructMat3x2: return "mat3x2"; case EOpConstructMat3: return "mat3"; case EOpConstructMat3x4: return "mat3x4"; case EOpConstructMat4x2: return "mat4x2"; case EOpConstructMat4x3: return "mat4x3"; case EOpConstructMat4: return "mat4"; // Note: EOpConstructStruct can't be handled here case EOpAssign: return "="; case EOpInitialize: return "="; case EOpAddAssign: return "+="; case EOpSubAssign: return "-="; // Fall-through. case EOpMulAssign: case EOpVectorTimesMatrixAssign: case EOpVectorTimesScalarAssign: case EOpMatrixTimesScalarAssign: case EOpMatrixTimesMatrixAssign: return "*="; case EOpDivAssign: return "/="; case EOpIModAssign: return "%="; case EOpBitShiftLeftAssign: return "<<="; case EOpBitShiftRightAssign: return ">>="; case EOpBitwiseAndAssign: return "&="; case EOpBitwiseXorAssign: return "^="; case EOpBitwiseOrAssign: return "|="; default: break; } return ""; } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/Operator.h000066400000000000000000000103351321746453100266720ustar00rootroot00000000000000// // Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_OPERATOR_H_ #define COMPILER_TRANSLATOR_OPERATOR_H_ // // Operators used by the high-level (parse tree) representation. // enum TOperator { EOpNull, // if in a node, should only mean a node is still being built EOpSequence, // denotes a list of statements, or parameters, etc. EOpFunctionCall, EOpFunction, // For function definition EOpParameters, // an aggregate listing the parameters to a function EOpDeclaration, EOpInvariantDeclaration, // Specialized declarations for attributing invariance EOpPrototype, // // Unary operators // EOpNegative, EOpPositive, EOpLogicalNot, EOpVectorLogicalNot, EOpBitwiseNot, EOpPostIncrement, EOpPostDecrement, EOpPreIncrement, EOpPreDecrement, // // binary operations // EOpAdd, EOpSub, EOpMul, EOpDiv, EOpIMod, EOpEqual, EOpNotEqual, EOpVectorEqual, EOpVectorNotEqual, EOpLessThan, EOpGreaterThan, EOpLessThanEqual, EOpGreaterThanEqual, EOpComma, EOpVectorTimesScalar, EOpVectorTimesMatrix, EOpMatrixTimesVector, EOpMatrixTimesScalar, EOpLogicalOr, EOpLogicalXor, EOpLogicalAnd, EOpBitShiftLeft, EOpBitShiftRight, EOpBitwiseAnd, EOpBitwiseXor, EOpBitwiseOr, EOpIndexDirect, EOpIndexIndirect, EOpIndexDirectStruct, EOpIndexDirectInterfaceBlock, EOpVectorSwizzle, // // Built-in functions potentially mapped to operators // EOpRadians, EOpDegrees, EOpSin, EOpCos, EOpTan, EOpAsin, EOpAcos, EOpAtan, EOpSinh, EOpCosh, EOpTanh, EOpAsinh, EOpAcosh, EOpAtanh, EOpPow, EOpExp, EOpLog, EOpExp2, EOpLog2, EOpSqrt, EOpInverseSqrt, EOpAbs, EOpSign, EOpFloor, EOpTrunc, EOpRound, EOpRoundEven, EOpCeil, EOpFract, EOpMod, EOpModf, EOpMin, EOpMax, EOpClamp, EOpMix, EOpStep, EOpSmoothStep, EOpIsNan, EOpIsInf, EOpFloatBitsToInt, EOpFloatBitsToUint, EOpIntBitsToFloat, EOpUintBitsToFloat, EOpPackSnorm2x16, EOpPackUnorm2x16, EOpPackHalf2x16, EOpUnpackSnorm2x16, EOpUnpackUnorm2x16, EOpUnpackHalf2x16, EOpLength, EOpDistance, EOpDot, EOpCross, EOpNormalize, EOpFaceForward, EOpReflect, EOpRefract, EOpDFdx, // Fragment only, OES_standard_derivatives extension EOpDFdy, // Fragment only, OES_standard_derivatives extension EOpFwidth, // Fragment only, OES_standard_derivatives extension EOpMatrixTimesMatrix, EOpOuterProduct, EOpTranspose, EOpDeterminant, EOpInverse, EOpAny, EOpAll, // // Branch // EOpKill, // Fragment only EOpReturn, EOpBreak, EOpContinue, // // Constructors // EOpConstructInt, EOpConstructUInt, EOpConstructBool, EOpConstructFloat, EOpConstructVec2, EOpConstructVec3, EOpConstructVec4, EOpConstructBVec2, EOpConstructBVec3, EOpConstructBVec4, EOpConstructIVec2, EOpConstructIVec3, EOpConstructIVec4, EOpConstructUVec2, EOpConstructUVec3, EOpConstructUVec4, EOpConstructMat2, EOpConstructMat2x3, EOpConstructMat2x4, EOpConstructMat3x2, EOpConstructMat3, EOpConstructMat3x4, EOpConstructMat4x2, EOpConstructMat4x3, EOpConstructMat4, EOpConstructStruct, // // moves // EOpAssign, EOpInitialize, EOpAddAssign, EOpSubAssign, EOpMulAssign, EOpVectorTimesMatrixAssign, EOpVectorTimesScalarAssign, EOpMatrixTimesScalarAssign, EOpMatrixTimesMatrixAssign, EOpDivAssign, EOpIModAssign, EOpBitShiftLeftAssign, EOpBitShiftRightAssign, EOpBitwiseAndAssign, EOpBitwiseXorAssign, EOpBitwiseOrAssign }; // Returns the string corresponding to the operator in GLSL const char* GetOperatorString(TOperator op); #endif // COMPILER_TRANSLATOR_OPERATOR_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/OutputGLSL.cpp000066400000000000000000000036161321746453100274200ustar00rootroot00000000000000// // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/OutputGLSL.h" TOutputGLSL::TOutputGLSL(TInfoSinkBase& objSink, ShHashFunction64 hashFunction, NameMap& nameMap, TSymbolTable& symbolTable, int shaderVersion, ShShaderOutput output) : TOutputGLSLBase(objSink, hashFunction, nameMap, symbolTable, shaderVersion, output) { } bool TOutputGLSL::writeVariablePrecision(TPrecision) { return false; } void TOutputGLSL::visitSymbol(TIntermSymbol *node) { TInfoSinkBase& out = objSink(); const TString &symbol = node->getSymbol(); if (symbol == "gl_FragDepthEXT") { out << "gl_FragDepth"; } else if (symbol == "gl_SecondaryFragColorEXT") { out << "angle_SecondaryFragColor"; } else if (symbol == "gl_SecondaryFragDataEXT") { out << "angle_SecondaryFragData"; } else { TOutputGLSLBase::visitSymbol(node); } } TString TOutputGLSL::translateTextureFunction(TString &name) { static const char *simpleRename[] = { "texture2DLodEXT", "texture2DLod", "texture2DProjLodEXT", "texture2DProjLod", "textureCubeLodEXT", "textureCubeLod", "texture2DGradEXT", "texture2DGradARB", "texture2DProjGradEXT", "texture2DProjGradARB", "textureCubeGradEXT", "textureCubeGradARB", NULL, NULL }; const char **mapping = simpleRename; for (int i = 0; mapping[i] != NULL; i += 2) { if (name == mapping[i]) { return mapping[i+1]; } } return name; } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/OutputGLSL.h000066400000000000000000000015121321746453100270560ustar00rootroot00000000000000// // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_OUTPUTGLSL_H_ #define COMPILER_TRANSLATOR_OUTPUTGLSL_H_ #include "compiler/translator/OutputGLSLBase.h" class TOutputGLSL : public TOutputGLSLBase { public: TOutputGLSL(TInfoSinkBase& objSink, ShHashFunction64 hashFunction, NameMap& nameMap, TSymbolTable& symbolTable, int shaderVersion, ShShaderOutput output); protected: virtual bool writeVariablePrecision(TPrecision); virtual void visitSymbol(TIntermSymbol* node); virtual TString translateTextureFunction(TString& name); }; #endif // COMPILER_TRANSLATOR_OUTPUTGLSL_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/OutputGLSLBase.cpp000066400000000000000000001043671321746453100302200ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/OutputGLSLBase.h" #include "common/debug.h" #include namespace { TString arrayBrackets(const TType &type) { ASSERT(type.isArray()); TInfoSinkBase out; out << "[" << type.getArraySize() << "]"; return TString(out.c_str()); } bool isSingleStatement(TIntermNode *node) { if (const TIntermAggregate *aggregate = node->getAsAggregate()) { return (aggregate->getOp() != EOpFunction) && (aggregate->getOp() != EOpSequence); } else if (const TIntermSelection *selection = node->getAsSelectionNode()) { // Ternary operators are usually part of an assignment operator. // This handles those rare cases in which they are all by themselves. return selection->usesTernaryOperator(); } else if (node->getAsLoopNode()) { return false; } else if (node->getAsSwitchNode()) { return false; } else if (node->getAsCaseNode()) { return false; } return true; } } // namespace TOutputGLSLBase::TOutputGLSLBase(TInfoSinkBase &objSink, ShHashFunction64 hashFunction, NameMap &nameMap, TSymbolTable &symbolTable, int shaderVersion, ShShaderOutput output) : TIntermTraverser(true, true, true), mObjSink(objSink), mDeclaringVariables(false), mHashFunction(hashFunction), mNameMap(nameMap), mSymbolTable(symbolTable), mShaderVersion(shaderVersion), mOutput(output) { } void TOutputGLSLBase::writeTriplet( Visit visit, const char *preStr, const char *inStr, const char *postStr) { TInfoSinkBase &out = objSink(); if (visit == PreVisit && preStr) out << preStr; else if (visit == InVisit && inStr) out << inStr; else if (visit == PostVisit && postStr) out << postStr; } void TOutputGLSLBase::writeBuiltInFunctionTriplet( Visit visit, const char *preStr, bool useEmulatedFunction) { TString preString = useEmulatedFunction ? BuiltInFunctionEmulator::GetEmulatedFunctionName(preStr) : preStr; writeTriplet(visit, preString.c_str(), ", ", ")"); } void TOutputGLSLBase::writeVariableType(const TType &type) { TInfoSinkBase &out = objSink(); if (type.isInvariant()) { out << "invariant "; } TQualifier qualifier = type.getQualifier(); if (qualifier != EvqTemporary && qualifier != EvqGlobal) { out << type.getQualifierString() << " "; } // Declare the struct if we have not done so already. if (type.getBasicType() == EbtStruct && !structDeclared(type.getStruct())) { TStructure *structure = type.getStruct(); declareStruct(structure); if (!structure->name().empty()) { mDeclaredStructs.insert(structure->uniqueId()); } } else { if (writeVariablePrecision(type.getPrecision())) out << " "; out << getTypeName(type); } } void TOutputGLSLBase::writeFunctionParameters(const TIntermSequence &args) { TInfoSinkBase &out = objSink(); for (TIntermSequence::const_iterator iter = args.begin(); iter != args.end(); ++iter) { const TIntermSymbol *arg = (*iter)->getAsSymbolNode(); ASSERT(arg != NULL); const TType &type = arg->getType(); writeVariableType(type); const TString &name = arg->getSymbol(); if (!name.empty()) out << " " << hashName(name); if (type.isArray()) out << arrayBrackets(type); // Put a comma if this is not the last argument. if (iter != args.end() - 1) out << ", "; } } const TConstantUnion *TOutputGLSLBase::writeConstantUnion( const TType &type, const TConstantUnion *pConstUnion) { TInfoSinkBase &out = objSink(); if (type.getBasicType() == EbtStruct) { const TStructure *structure = type.getStruct(); out << hashName(structure->name()) << "("; const TFieldList &fields = structure->fields(); for (size_t i = 0; i < fields.size(); ++i) { const TType *fieldType = fields[i]->type(); ASSERT(fieldType != NULL); pConstUnion = writeConstantUnion(*fieldType, pConstUnion); if (i != fields.size() - 1) out << ", "; } out << ")"; } else { size_t size = type.getObjectSize(); bool writeType = size > 1; if (writeType) out << getTypeName(type) << "("; for (size_t i = 0; i < size; ++i, ++pConstUnion) { switch (pConstUnion->getType()) { case EbtFloat: out << std::min(FLT_MAX, std::max(-FLT_MAX, pConstUnion->getFConst())); break; case EbtInt: out << pConstUnion->getIConst(); break; case EbtUInt: out << pConstUnion->getUConst() << "u"; break; case EbtBool: out << pConstUnion->getBConst(); break; default: UNREACHABLE(); } if (i != size - 1) out << ", "; } if (writeType) out << ")"; } return pConstUnion; } void TOutputGLSLBase::writeConstructorTriplet(Visit visit, const TType &type, const char *constructorBaseType) { TInfoSinkBase &out = objSink(); if (visit == PreVisit) { if (type.isArray()) { out << constructorBaseType; out << arrayBrackets(type); out << "("; } else { out << constructorBaseType << "("; } } else { writeTriplet(visit, nullptr, ", ", ")"); } } void TOutputGLSLBase::visitSymbol(TIntermSymbol *node) { TInfoSinkBase &out = objSink(); if (mLoopUnrollStack.needsToReplaceSymbolWithValue(node)) out << mLoopUnrollStack.getLoopIndexValue(node); else out << hashVariableName(node->getSymbol()); if (mDeclaringVariables && node->getType().isArray()) out << arrayBrackets(node->getType()); } void TOutputGLSLBase::visitConstantUnion(TIntermConstantUnion *node) { writeConstantUnion(node->getType(), node->getUnionArrayPointer()); } bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary *node) { bool visitChildren = true; TInfoSinkBase &out = objSink(); switch (node->getOp()) { case EOpInitialize: if (visit == InVisit) { out << " = "; // RHS of initialize is not being declared. mDeclaringVariables = false; } break; case EOpAssign: writeTriplet(visit, "(", " = ", ")"); break; case EOpAddAssign: writeTriplet(visit, "(", " += ", ")"); break; case EOpSubAssign: writeTriplet(visit, "(", " -= ", ")"); break; case EOpDivAssign: writeTriplet(visit, "(", " /= ", ")"); break; case EOpIModAssign: writeTriplet(visit, "(", " %= ", ")"); break; // Notice the fall-through. case EOpMulAssign: case EOpVectorTimesMatrixAssign: case EOpVectorTimesScalarAssign: case EOpMatrixTimesScalarAssign: case EOpMatrixTimesMatrixAssign: writeTriplet(visit, "(", " *= ", ")"); break; case EOpBitShiftLeftAssign: writeTriplet(visit, "(", " <<= ", ")"); break; case EOpBitShiftRightAssign: writeTriplet(visit, "(", " >>= ", ")"); break; case EOpBitwiseAndAssign: writeTriplet(visit, "(", " &= ", ")"); break; case EOpBitwiseXorAssign: writeTriplet(visit, "(", " ^= ", ")"); break; case EOpBitwiseOrAssign: writeTriplet(visit, "(", " |= ", ")"); break; case EOpIndexDirect: writeTriplet(visit, NULL, "[", "]"); break; case EOpIndexIndirect: writeTriplet(visit, NULL, "[", "]"); break; case EOpIndexDirectStruct: if (visit == InVisit) { // Here we are writing out "foo.bar", where "foo" is struct // and "bar" is field. In AST, it is represented as a binary // node, where left child represents "foo" and right child "bar". // The node itself represents ".". The struct field "bar" is // actually stored as an index into TStructure::fields. out << "."; const TStructure *structure = node->getLeft()->getType().getStruct(); const TIntermConstantUnion *index = node->getRight()->getAsConstantUnion(); const TField *field = structure->fields()[index->getIConst(0)]; TString fieldName = field->name(); if (!mSymbolTable.findBuiltIn(structure->name(), mShaderVersion)) fieldName = hashName(fieldName); out << fieldName; visitChildren = false; } break; case EOpVectorSwizzle: if (visit == InVisit) { out << "."; TIntermAggregate *rightChild = node->getRight()->getAsAggregate(); TIntermSequence *sequence = rightChild->getSequence(); for (TIntermSequence::iterator sit = sequence->begin(); sit != sequence->end(); ++sit) { TIntermConstantUnion *element = (*sit)->getAsConstantUnion(); ASSERT(element->getBasicType() == EbtInt); ASSERT(element->getNominalSize() == 1); const TConstantUnion& data = element->getUnionArrayPointer()[0]; ASSERT(data.getType() == EbtInt); switch (data.getIConst()) { case 0: out << "x"; break; case 1: out << "y"; break; case 2: out << "z"; break; case 3: out << "w"; break; default: UNREACHABLE(); } } visitChildren = false; } break; case EOpAdd: writeTriplet(visit, "(", " + ", ")"); break; case EOpSub: writeTriplet(visit, "(", " - ", ")"); break; case EOpMul: writeTriplet(visit, "(", " * ", ")"); break; case EOpDiv: writeTriplet(visit, "(", " / ", ")"); break; case EOpIMod: writeTriplet(visit, "(", " % ", ")"); break; case EOpBitShiftLeft: writeTriplet(visit, "(", " << ", ")"); break; case EOpBitShiftRight: writeTriplet(visit, "(", " >> ", ")"); break; case EOpBitwiseAnd: writeTriplet(visit, "(", " & ", ")"); break; case EOpBitwiseXor: writeTriplet(visit, "(", " ^ ", ")"); break; case EOpBitwiseOr: writeTriplet(visit, "(", " | ", ")"); break; case EOpEqual: writeTriplet(visit, "(", " == ", ")"); break; case EOpNotEqual: writeTriplet(visit, "(", " != ", ")"); break; case EOpLessThan: writeTriplet(visit, "(", " < ", ")"); break; case EOpGreaterThan: writeTriplet(visit, "(", " > ", ")"); break; case EOpLessThanEqual: writeTriplet(visit, "(", " <= ", ")"); break; case EOpGreaterThanEqual: writeTriplet(visit, "(", " >= ", ")"); break; // Notice the fall-through. case EOpVectorTimesScalar: case EOpVectorTimesMatrix: case EOpMatrixTimesVector: case EOpMatrixTimesScalar: case EOpMatrixTimesMatrix: writeTriplet(visit, "(", " * ", ")"); break; case EOpLogicalOr: writeTriplet(visit, "(", " || ", ")"); break; case EOpLogicalXor: writeTriplet(visit, "(", " ^^ ", ")"); break; case EOpLogicalAnd: writeTriplet(visit, "(", " && ", ")"); break; default: UNREACHABLE(); } return visitChildren; } bool TOutputGLSLBase::visitUnary(Visit visit, TIntermUnary *node) { TString preString; TString postString = ")"; switch (node->getOp()) { case EOpNegative: preString = "(-"; break; case EOpPositive: preString = "(+"; break; case EOpVectorLogicalNot: preString = "not("; break; case EOpLogicalNot: preString = "(!"; break; case EOpBitwiseNot: preString = "(~"; break; case EOpPostIncrement: preString = "("; postString = "++)"; break; case EOpPostDecrement: preString = "("; postString = "--)"; break; case EOpPreIncrement: preString = "(++"; break; case EOpPreDecrement: preString = "(--"; break; case EOpRadians: preString = "radians("; break; case EOpDegrees: preString = "degrees("; break; case EOpSin: preString = "sin("; break; case EOpCos: preString = "cos("; break; case EOpTan: preString = "tan("; break; case EOpAsin: preString = "asin("; break; case EOpAcos: preString = "acos("; break; case EOpAtan: preString = "atan("; break; case EOpSinh: preString = "sinh("; break; case EOpCosh: preString = "cosh("; break; case EOpTanh: preString = "tanh("; break; case EOpAsinh: preString = "asinh("; break; case EOpAcosh: preString = "acosh("; break; case EOpAtanh: preString = "atanh("; break; case EOpExp: preString = "exp("; break; case EOpLog: preString = "log("; break; case EOpExp2: preString = "exp2("; break; case EOpLog2: preString = "log2("; break; case EOpSqrt: preString = "sqrt("; break; case EOpInverseSqrt: preString = "inversesqrt("; break; case EOpAbs: preString = "abs("; break; case EOpSign: preString = "sign("; break; case EOpFloor: preString = "floor("; break; case EOpTrunc: preString = "trunc("; break; case EOpRound: preString = "round("; break; case EOpRoundEven: preString = "roundEven("; break; case EOpCeil: preString = "ceil("; break; case EOpFract: preString = "fract("; break; case EOpIsNan: preString = "isnan("; break; case EOpIsInf: preString = "isinf("; break; case EOpFloatBitsToInt: preString = "floatBitsToInt("; break; case EOpFloatBitsToUint: preString = "floatBitsToUint("; break; case EOpIntBitsToFloat: preString = "intBitsToFloat("; break; case EOpUintBitsToFloat: preString = "uintBitsToFloat("; break; case EOpPackSnorm2x16: preString = "packSnorm2x16("; break; case EOpPackUnorm2x16: preString = "packUnorm2x16("; break; case EOpPackHalf2x16: preString = "packHalf2x16("; break; case EOpUnpackSnorm2x16: preString = "unpackSnorm2x16("; break; case EOpUnpackUnorm2x16: preString = "unpackUnorm2x16("; break; case EOpUnpackHalf2x16: preString = "unpackHalf2x16("; break; case EOpLength: preString = "length("; break; case EOpNormalize: preString = "normalize("; break; case EOpDFdx: preString = "dFdx("; break; case EOpDFdy: preString = "dFdy("; break; case EOpFwidth: preString = "fwidth("; break; case EOpTranspose: preString = "transpose("; break; case EOpDeterminant: preString = "determinant("; break; case EOpInverse: preString = "inverse("; break; case EOpAny: preString = "any("; break; case EOpAll: preString = "all("; break; default: UNREACHABLE(); } if (visit == PreVisit && node->getUseEmulatedFunction()) preString = BuiltInFunctionEmulator::GetEmulatedFunctionName(preString); writeTriplet(visit, preString.c_str(), NULL, postString.c_str()); return true; } bool TOutputGLSLBase::visitSelection(Visit visit, TIntermSelection *node) { TInfoSinkBase &out = objSink(); if (node->usesTernaryOperator()) { // Notice two brackets at the beginning and end. The outer ones // encapsulate the whole ternary expression. This preserves the // order of precedence when ternary expressions are used in a // compound expression, i.e., c = 2 * (a < b ? 1 : 2). out << "(("; node->getCondition()->traverse(this); out << ") ? ("; node->getTrueBlock()->traverse(this); out << ") : ("; node->getFalseBlock()->traverse(this); out << "))"; } else { out << "if ("; node->getCondition()->traverse(this); out << ")\n"; incrementDepth(node); visitCodeBlock(node->getTrueBlock()); if (node->getFalseBlock()) { out << "else\n"; visitCodeBlock(node->getFalseBlock()); } decrementDepth(); } return false; } bool TOutputGLSLBase::visitSwitch(Visit visit, TIntermSwitch *node) { if (node->getStatementList()) { writeTriplet(visit, "switch (", ") ", nullptr); // The curly braces get written when visiting the statementList aggregate } else { // No statementList, so it won't output curly braces writeTriplet(visit, "switch (", ") {", "}\n"); } return true; } bool TOutputGLSLBase::visitCase(Visit visit, TIntermCase *node) { if (node->hasCondition()) { writeTriplet(visit, "case (", nullptr, "):\n"); return true; } else { TInfoSinkBase &out = objSink(); out << "default:\n"; return false; } } bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node) { bool visitChildren = true; TInfoSinkBase &out = objSink(); bool useEmulatedFunction = (visit == PreVisit && node->getUseEmulatedFunction()); switch (node->getOp()) { case EOpSequence: // Scope the sequences except when at the global scope. if (mDepth > 0) { out << "{\n"; } incrementDepth(node); for (TIntermSequence::const_iterator iter = node->getSequence()->begin(); iter != node->getSequence()->end(); ++iter) { TIntermNode *curNode = *iter; ASSERT(curNode != NULL); curNode->traverse(this); if (isSingleStatement(curNode)) out << ";\n"; } decrementDepth(); // Scope the sequences except when at the global scope. if (mDepth > 0) { out << "}\n"; } visitChildren = false; break; case EOpPrototype: // Function declaration. ASSERT(visit == PreVisit); { const TType &type = node->getType(); writeVariableType(type); if (type.isArray()) out << arrayBrackets(type); } out << " " << hashFunctionNameIfNeeded(node->getNameObj()); out << "("; writeFunctionParameters(*(node->getSequence())); out << ")"; visitChildren = false; break; case EOpFunction: { // Function definition. ASSERT(visit == PreVisit); { const TType &type = node->getType(); writeVariableType(type); if (type.isArray()) out << arrayBrackets(type); } out << " " << hashFunctionNameIfNeeded(node->getNameObj()); incrementDepth(node); // Function definition node contains one or two children nodes // representing function parameters and function body. The latter // is not present in case of empty function bodies. const TIntermSequence &sequence = *(node->getSequence()); ASSERT((sequence.size() == 1) || (sequence.size() == 2)); TIntermSequence::const_iterator seqIter = sequence.begin(); // Traverse function parameters. TIntermAggregate *params = (*seqIter)->getAsAggregate(); ASSERT(params != NULL); ASSERT(params->getOp() == EOpParameters); params->traverse(this); // Traverse function body. TIntermAggregate *body = ++seqIter != sequence.end() ? (*seqIter)->getAsAggregate() : NULL; visitCodeBlock(body); decrementDepth(); // Fully processed; no need to visit children. visitChildren = false; break; } case EOpFunctionCall: // Function call. if (visit == PreVisit) out << hashFunctionNameIfNeeded(node->getNameObj()) << "("; else if (visit == InVisit) out << ", "; else out << ")"; break; case EOpParameters: // Function parameters. ASSERT(visit == PreVisit); out << "("; writeFunctionParameters(*(node->getSequence())); out << ")"; visitChildren = false; break; case EOpDeclaration: // Variable declaration. if (visit == PreVisit) { const TIntermSequence &sequence = *(node->getSequence()); const TIntermTyped *variable = sequence.front()->getAsTyped(); writeVariableType(variable->getType()); out << " "; mDeclaringVariables = true; } else if (visit == InVisit) { out << ", "; mDeclaringVariables = true; } else { mDeclaringVariables = false; } break; case EOpInvariantDeclaration: // Invariant declaration. ASSERT(visit == PreVisit); { const TIntermSequence *sequence = node->getSequence(); ASSERT(sequence && sequence->size() == 1); const TIntermSymbol *symbol = sequence->front()->getAsSymbolNode(); ASSERT(symbol); out << "invariant " << hashVariableName(symbol->getSymbol()); } visitChildren = false; break; case EOpConstructFloat: writeConstructorTriplet(visit, node->getType(), "float"); break; case EOpConstructVec2: writeConstructorTriplet(visit, node->getType(), "vec2"); break; case EOpConstructVec3: writeConstructorTriplet(visit, node->getType(), "vec3"); break; case EOpConstructVec4: writeConstructorTriplet(visit, node->getType(), "vec4"); break; case EOpConstructBool: writeConstructorTriplet(visit, node->getType(), "bool"); break; case EOpConstructBVec2: writeConstructorTriplet(visit, node->getType(), "bvec2"); break; case EOpConstructBVec3: writeConstructorTriplet(visit, node->getType(), "bvec3"); break; case EOpConstructBVec4: writeConstructorTriplet(visit, node->getType(), "bvec4"); break; case EOpConstructInt: writeConstructorTriplet(visit, node->getType(), "int"); break; case EOpConstructIVec2: writeConstructorTriplet(visit, node->getType(), "ivec2"); break; case EOpConstructIVec3: writeConstructorTriplet(visit, node->getType(), "ivec3"); break; case EOpConstructIVec4: writeConstructorTriplet(visit, node->getType(), "ivec4"); break; case EOpConstructUInt: writeConstructorTriplet(visit, node->getType(), "uint"); break; case EOpConstructUVec2: writeConstructorTriplet(visit, node->getType(), "uvec2"); break; case EOpConstructUVec3: writeConstructorTriplet(visit, node->getType(), "uvec3"); break; case EOpConstructUVec4: writeConstructorTriplet(visit, node->getType(), "uvec4"); break; case EOpConstructMat2: writeConstructorTriplet(visit, node->getType(), "mat2"); break; case EOpConstructMat2x3: writeConstructorTriplet(visit, node->getType(), "mat2x3"); break; case EOpConstructMat2x4: writeConstructorTriplet(visit, node->getType(), "mat2x4"); break; case EOpConstructMat3x2: writeConstructorTriplet(visit, node->getType(), "mat3x2"); break; case EOpConstructMat3: writeConstructorTriplet(visit, node->getType(), "mat3"); break; case EOpConstructMat3x4: writeConstructorTriplet(visit, node->getType(), "mat3x4"); break; case EOpConstructMat4x2: writeConstructorTriplet(visit, node->getType(), "mat4x2"); break; case EOpConstructMat4x3: writeConstructorTriplet(visit, node->getType(), "mat4x3"); break; case EOpConstructMat4: writeConstructorTriplet(visit, node->getType(), "mat4"); break; case EOpConstructStruct: { const TType &type = node->getType(); ASSERT(type.getBasicType() == EbtStruct); TString constructorName = hashName(type.getStruct()->name()); writeConstructorTriplet(visit, node->getType(), constructorName.c_str()); break; } case EOpOuterProduct: writeBuiltInFunctionTriplet(visit, "outerProduct(", useEmulatedFunction); break; case EOpLessThan: writeBuiltInFunctionTriplet(visit, "lessThan(", useEmulatedFunction); break; case EOpGreaterThan: writeBuiltInFunctionTriplet(visit, "greaterThan(", useEmulatedFunction); break; case EOpLessThanEqual: writeBuiltInFunctionTriplet(visit, "lessThanEqual(", useEmulatedFunction); break; case EOpGreaterThanEqual: writeBuiltInFunctionTriplet(visit, "greaterThanEqual(", useEmulatedFunction); break; case EOpVectorEqual: writeBuiltInFunctionTriplet(visit, "equal(", useEmulatedFunction); break; case EOpVectorNotEqual: writeBuiltInFunctionTriplet(visit, "notEqual(", useEmulatedFunction); break; case EOpComma: writeTriplet(visit, "(", ", ", ")"); break; case EOpMod: writeBuiltInFunctionTriplet(visit, "mod(", useEmulatedFunction); break; case EOpModf: writeBuiltInFunctionTriplet(visit, "modf(", useEmulatedFunction); break; case EOpPow: writeBuiltInFunctionTriplet(visit, "pow(", useEmulatedFunction); break; case EOpAtan: writeBuiltInFunctionTriplet(visit, "atan(", useEmulatedFunction); break; case EOpMin: writeBuiltInFunctionTriplet(visit, "min(", useEmulatedFunction); break; case EOpMax: writeBuiltInFunctionTriplet(visit, "max(", useEmulatedFunction); break; case EOpClamp: writeBuiltInFunctionTriplet(visit, "clamp(", useEmulatedFunction); break; case EOpMix: writeBuiltInFunctionTriplet(visit, "mix(", useEmulatedFunction); break; case EOpStep: writeBuiltInFunctionTriplet(visit, "step(", useEmulatedFunction); break; case EOpSmoothStep: writeBuiltInFunctionTriplet(visit, "smoothstep(", useEmulatedFunction); break; case EOpDistance: writeBuiltInFunctionTriplet(visit, "distance(", useEmulatedFunction); break; case EOpDot: writeBuiltInFunctionTriplet(visit, "dot(", useEmulatedFunction); break; case EOpCross: writeBuiltInFunctionTriplet(visit, "cross(", useEmulatedFunction); break; case EOpFaceForward: writeBuiltInFunctionTriplet(visit, "faceforward(", useEmulatedFunction); break; case EOpReflect: writeBuiltInFunctionTriplet(visit, "reflect(", useEmulatedFunction); break; case EOpRefract: writeBuiltInFunctionTriplet(visit, "refract(", useEmulatedFunction); break; case EOpMul: writeBuiltInFunctionTriplet(visit, "matrixCompMult(", useEmulatedFunction); break; default: UNREACHABLE(); } return visitChildren; } bool TOutputGLSLBase::visitLoop(Visit visit, TIntermLoop *node) { TInfoSinkBase &out = objSink(); incrementDepth(node); // Loop header. TLoopType loopType = node->getType(); if (loopType == ELoopFor) // for loop { if (!node->getUnrollFlag()) { out << "for ("; if (node->getInit()) node->getInit()->traverse(this); out << "; "; if (node->getCondition()) node->getCondition()->traverse(this); out << "; "; if (node->getExpression()) node->getExpression()->traverse(this); out << ")\n"; } else { // Need to put a one-iteration loop here to handle break. TIntermSequence *declSeq = node->getInit()->getAsAggregate()->getSequence(); TIntermSymbol *indexSymbol = (*declSeq)[0]->getAsBinaryNode()->getLeft()->getAsSymbolNode(); TString name = hashVariableName(indexSymbol->getSymbol()); out << "for (int " << name << " = 0; " << name << " < 1; " << "++" << name << ")\n"; } } else if (loopType == ELoopWhile) // while loop { out << "while ("; ASSERT(node->getCondition() != NULL); node->getCondition()->traverse(this); out << ")\n"; } else // do-while loop { ASSERT(loopType == ELoopDoWhile); out << "do\n"; } // Loop body. if (node->getUnrollFlag()) { out << "{\n"; mLoopUnrollStack.push(node); while (mLoopUnrollStack.satisfiesLoopCondition()) { visitCodeBlock(node->getBody()); mLoopUnrollStack.step(); } mLoopUnrollStack.pop(); out << "}\n"; } else { visitCodeBlock(node->getBody()); } // Loop footer. if (loopType == ELoopDoWhile) // do-while loop { out << "while ("; ASSERT(node->getCondition() != NULL); node->getCondition()->traverse(this); out << ");\n"; } decrementDepth(); // No need to visit children. They have been already processed in // this function. return false; } bool TOutputGLSLBase::visitBranch(Visit visit, TIntermBranch *node) { switch (node->getFlowOp()) { case EOpKill: writeTriplet(visit, "discard", NULL, NULL); break; case EOpBreak: writeTriplet(visit, "break", NULL, NULL); break; case EOpContinue: writeTriplet(visit, "continue", NULL, NULL); break; case EOpReturn: writeTriplet(visit, "return ", NULL, NULL); break; default: UNREACHABLE(); } return true; } void TOutputGLSLBase::visitCodeBlock(TIntermNode *node) { TInfoSinkBase &out = objSink(); if (node != NULL) { node->traverse(this); // Single statements not part of a sequence need to be terminated // with semi-colon. if (isSingleStatement(node)) out << ";\n"; } else { out << "{\n}\n"; // Empty code block. } } TString TOutputGLSLBase::getTypeName(const TType &type) { TInfoSinkBase out; if (type.isMatrix()) { out << "mat"; out << type.getNominalSize(); } else if (type.isVector()) { switch (type.getBasicType()) { case EbtFloat: out << "vec"; break; case EbtInt: out << "ivec"; break; case EbtBool: out << "bvec"; break; case EbtUInt: out << "uvec"; break; default: UNREACHABLE(); } out << type.getNominalSize(); } else { if (type.getBasicType() == EbtStruct) out << hashName(type.getStruct()->name()); else out << type.getBasicString(); } return TString(out.c_str()); } TString TOutputGLSLBase::hashName(const TString &name) { if (mHashFunction == NULL || name.empty()) return name; NameMap::const_iterator it = mNameMap.find(name.c_str()); if (it != mNameMap.end()) return it->second.c_str(); TString hashedName = TIntermTraverser::hash(name, mHashFunction); mNameMap[name.c_str()] = hashedName.c_str(); return hashedName; } TString TOutputGLSLBase::hashVariableName(const TString &name) { if (mSymbolTable.findBuiltIn(name, mShaderVersion) != NULL) return name; return hashName(name); } TString TOutputGLSLBase::hashFunctionNameIfNeeded(const TName &mangledName) { TString mangledStr = mangledName.getString(); TString name = TFunction::unmangleName(mangledStr); if (mSymbolTable.findBuiltIn(mangledStr, mShaderVersion) != nullptr || name == "main") return translateTextureFunction(name); if (mangledName.isInternal()) return name; else return hashName(name); } bool TOutputGLSLBase::structDeclared(const TStructure *structure) const { ASSERT(structure); if (structure->name().empty()) { return false; } return (mDeclaredStructs.count(structure->uniqueId()) > 0); } void TOutputGLSLBase::declareStruct(const TStructure *structure) { TInfoSinkBase &out = objSink(); out << "struct " << hashName(structure->name()) << "{\n"; const TFieldList &fields = structure->fields(); for (size_t i = 0; i < fields.size(); ++i) { const TField *field = fields[i]; if (writeVariablePrecision(field->type()->getPrecision())) out << " "; out << getTypeName(*field->type()) << " " << hashName(field->name()); if (field->type()->isArray()) out << arrayBrackets(*field->type()); out << ";\n"; } out << "}"; } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/OutputGLSLBase.h000066400000000000000000000064421321746453100276600ustar00rootroot00000000000000// // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_OUTPUTGLSLBASE_H_ #define COMPILER_TRANSLATOR_OUTPUTGLSLBASE_H_ #include #include "compiler/translator/IntermNode.h" #include "compiler/translator/LoopInfo.h" #include "compiler/translator/ParseContext.h" class TOutputGLSLBase : public TIntermTraverser { public: TOutputGLSLBase(TInfoSinkBase &objSink, ShHashFunction64 hashFunction, NameMap &nameMap, TSymbolTable& symbolTable, int shaderVersion, ShShaderOutput output); ShShaderOutput getShaderOutput() const { return mOutput; } protected: TInfoSinkBase &objSink() { return mObjSink; } void writeTriplet(Visit visit, const char *preStr, const char *inStr, const char *postStr); void writeVariableType(const TType &type); virtual bool writeVariablePrecision(TPrecision precision) = 0; void writeFunctionParameters(const TIntermSequence &args); const TConstantUnion *writeConstantUnion(const TType &type, const TConstantUnion *pConstUnion); void writeConstructorTriplet(Visit visit, const TType &type, const char *constructorBaseType); TString getTypeName(const TType &type); virtual void visitSymbol(TIntermSymbol *node); virtual void visitConstantUnion(TIntermConstantUnion *node); virtual bool visitBinary(Visit visit, TIntermBinary *node); virtual bool visitUnary(Visit visit, TIntermUnary *node); virtual bool visitSelection(Visit visit, TIntermSelection *node); virtual bool visitSwitch(Visit visit, TIntermSwitch *node); virtual bool visitCase(Visit visit, TIntermCase *node); virtual bool visitAggregate(Visit visit, TIntermAggregate *node); virtual bool visitLoop(Visit visit, TIntermLoop *node); virtual bool visitBranch(Visit visit, TIntermBranch *node); void visitCodeBlock(TIntermNode *node); // Return the original name if hash function pointer is NULL; // otherwise return the hashed name. TString hashName(const TString &name); // Same as hashName(), but without hashing built-in variables. TString hashVariableName(const TString &name); // Same as hashName(), but without hashing built-in functions and with unmangling. TString hashFunctionNameIfNeeded(const TName &mangledName); // Used to translate function names for differences between ESSL and GLSL virtual TString translateTextureFunction(TString &name) { return name; } private: bool structDeclared(const TStructure *structure) const; void declareStruct(const TStructure *structure); void writeBuiltInFunctionTriplet(Visit visit, const char *preStr, bool useEmulatedFunction); TInfoSinkBase &mObjSink; bool mDeclaringVariables; // This set contains all the ids of the structs from every scope. std::set mDeclaredStructs; // Stack of loops that need to be unrolled. TLoopStack mLoopUnrollStack; // name hashing. ShHashFunction64 mHashFunction; NameMap &mNameMap; TSymbolTable &mSymbolTable; const int mShaderVersion; ShShaderOutput mOutput; }; #endif // COMPILER_TRANSLATOR_OUTPUTGLSLBASE_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/ParseContext.cpp000066400000000000000000004055411321746453100300600ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/ParseContext.h" #include #include #include "compiler/preprocessor/SourceLocation.h" #include "compiler/translator/Cache.h" #include "compiler/translator/glslang.h" #include "compiler/translator/ValidateSwitch.h" #include "compiler/translator/ValidateGlobalInitializer.h" #include "compiler/translator/util.h" /////////////////////////////////////////////////////////////////////// // // Sub- vector and matrix fields // //////////////////////////////////////////////////////////////////////// // // Look at a '.' field selector string and change it into offsets // for a vector. // bool TParseContext::parseVectorFields(const TString &compString, int vecSize, TVectorFields &fields, const TSourceLoc &line) { fields.num = (int)compString.size(); if (fields.num > 4) { error(line, "illegal vector field selection", compString.c_str()); return false; } enum { exyzw, ergba, estpq } fieldSet[4]; for (int i = 0; i < fields.num; ++i) { switch (compString[i]) { case 'x': fields.offsets[i] = 0; fieldSet[i] = exyzw; break; case 'r': fields.offsets[i] = 0; fieldSet[i] = ergba; break; case 's': fields.offsets[i] = 0; fieldSet[i] = estpq; break; case 'y': fields.offsets[i] = 1; fieldSet[i] = exyzw; break; case 'g': fields.offsets[i] = 1; fieldSet[i] = ergba; break; case 't': fields.offsets[i] = 1; fieldSet[i] = estpq; break; case 'z': fields.offsets[i] = 2; fieldSet[i] = exyzw; break; case 'b': fields.offsets[i] = 2; fieldSet[i] = ergba; break; case 'p': fields.offsets[i] = 2; fieldSet[i] = estpq; break; case 'w': fields.offsets[i] = 3; fieldSet[i] = exyzw; break; case 'a': fields.offsets[i] = 3; fieldSet[i] = ergba; break; case 'q': fields.offsets[i] = 3; fieldSet[i] = estpq; break; default: error(line, "illegal vector field selection", compString.c_str()); return false; } } for (int i = 0; i < fields.num; ++i) { if (fields.offsets[i] >= vecSize) { error(line, "vector field selection out of range", compString.c_str()); return false; } if (i > 0) { if (fieldSet[i] != fieldSet[i - 1]) { error(line, "illegal - vector component fields not from the same set", compString.c_str()); return false; } } } return true; } /////////////////////////////////////////////////////////////////////// // // Errors // //////////////////////////////////////////////////////////////////////// // // Track whether errors have occurred. // void TParseContext::recover() { } // // Used by flex/bison to output all syntax and parsing errors. // void TParseContext::error(const TSourceLoc &loc, const char *reason, const char *token, const char *extraInfo) { pp::SourceLocation srcLoc; srcLoc.file = loc.first_file; srcLoc.line = loc.first_line; mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, srcLoc, reason, token, extraInfo); } void TParseContext::warning(const TSourceLoc &loc, const char *reason, const char *token, const char *extraInfo) { pp::SourceLocation srcLoc; srcLoc.file = loc.first_file; srcLoc.line = loc.first_line; mDiagnostics.writeInfo(pp::Diagnostics::PP_WARNING, srcLoc, reason, token, extraInfo); } // // Same error message for all places assignments don't work. // void TParseContext::assignError(const TSourceLoc &line, const char *op, TString left, TString right) { std::stringstream extraInfoStream; extraInfoStream << "cannot convert from '" << right << "' to '" << left << "'"; std::string extraInfo = extraInfoStream.str(); error(line, "", op, extraInfo.c_str()); } // // Same error message for all places unary operations don't work. // void TParseContext::unaryOpError(const TSourceLoc &line, const char *op, TString operand) { std::stringstream extraInfoStream; extraInfoStream << "no operation '" << op << "' exists that takes an operand of type " << operand << " (or there is no acceptable conversion)"; std::string extraInfo = extraInfoStream.str(); error(line, " wrong operand type", op, extraInfo.c_str()); } // // Same error message for all binary operations don't work. // void TParseContext::binaryOpError(const TSourceLoc &line, const char *op, TString left, TString right) { std::stringstream extraInfoStream; extraInfoStream << "no operation '" << op << "' exists that takes a left-hand operand of type '" << left << "' and a right operand of type '" << right << "' (or there is no acceptable conversion)"; std::string extraInfo = extraInfoStream.str(); error(line, " wrong operand types ", op, extraInfo.c_str()); } bool TParseContext::precisionErrorCheck(const TSourceLoc &line, TPrecision precision, TBasicType type) { if (!mChecksPrecisionErrors) return false; switch (type) { case EbtFloat: if (precision == EbpUndefined) { error(line, "No precision specified for (float)", ""); return true; } break; case EbtInt: if (precision == EbpUndefined) { error(line, "No precision specified (int)", ""); return true; } break; default: return false; } return false; } // // Both test and if necessary, spit out an error, to see if the node is really // an l-value that can be operated on this way. // // Returns true if the was an error. // bool TParseContext::lValueErrorCheck(const TSourceLoc &line, const char *op, TIntermTyped *node) { TIntermSymbol *symNode = node->getAsSymbolNode(); TIntermBinary *binaryNode = node->getAsBinaryNode(); if (binaryNode) { bool errorReturn; switch (binaryNode->getOp()) { case EOpIndexDirect: case EOpIndexIndirect: case EOpIndexDirectStruct: case EOpIndexDirectInterfaceBlock: return lValueErrorCheck(line, op, binaryNode->getLeft()); case EOpVectorSwizzle: errorReturn = lValueErrorCheck(line, op, binaryNode->getLeft()); if (!errorReturn) { int offset[4] = {0, 0, 0, 0}; TIntermTyped *rightNode = binaryNode->getRight(); TIntermAggregate *aggrNode = rightNode->getAsAggregate(); for (TIntermSequence::iterator p = aggrNode->getSequence()->begin(); p != aggrNode->getSequence()->end(); p++) { int value = (*p)->getAsTyped()->getAsConstantUnion()->getIConst(0); offset[value]++; if (offset[value] > 1) { error(line, " l-value of swizzle cannot have duplicate components", op); return true; } } } return errorReturn; default: break; } error(line, " l-value required", op); return true; } const char *symbol = 0; if (symNode != 0) symbol = symNode->getSymbol().c_str(); const char *message = 0; switch (node->getQualifier()) { case EvqConst: message = "can't modify a const"; break; case EvqConstReadOnly: message = "can't modify a const"; break; case EvqAttribute: message = "can't modify an attribute"; break; case EvqFragmentIn: message = "can't modify an input"; break; case EvqVertexIn: message = "can't modify an input"; break; case EvqUniform: message = "can't modify a uniform"; break; case EvqVaryingIn: message = "can't modify a varying"; break; case EvqFragCoord: message = "can't modify gl_FragCoord"; break; case EvqFrontFacing: message = "can't modify gl_FrontFacing"; break; case EvqPointCoord: message = "can't modify gl_PointCoord"; break; default: // // Type that can't be written to? // if (node->getBasicType() == EbtVoid) { message = "can't modify void"; } if (IsSampler(node->getBasicType())) { message = "can't modify a sampler"; } } if (message == 0 && binaryNode == 0 && symNode == 0) { error(line, " l-value required", op); return true; } // // Everything else is okay, no error. // if (message == 0) return false; // // If we get here, we have an error and a message. // if (symNode) { std::stringstream extraInfoStream; extraInfoStream << "\"" << symbol << "\" (" << message << ")"; std::string extraInfo = extraInfoStream.str(); error(line, " l-value required", op, extraInfo.c_str()); } else { std::stringstream extraInfoStream; extraInfoStream << "(" << message << ")"; std::string extraInfo = extraInfoStream.str(); error(line, " l-value required", op, extraInfo.c_str()); } return true; } // // Both test, and if necessary spit out an error, to see if the node is really // a constant. // // Returns true if the was an error. // bool TParseContext::constErrorCheck(TIntermTyped *node) { if (node->getQualifier() == EvqConst) return false; error(node->getLine(), "constant expression required", ""); return true; } // // Both test, and if necessary spit out an error, to see if the node is really // an integer. // // Returns true if the was an error. // bool TParseContext::integerErrorCheck(TIntermTyped *node, const char *token) { if (node->isScalarInt()) return false; error(node->getLine(), "integer expression required", token); return true; } // // Both test, and if necessary spit out an error, to see if we are currently // globally scoped. // // Returns true if the was an error. // bool TParseContext::globalErrorCheck(const TSourceLoc &line, bool global, const char *token) { if (global) return false; error(line, "only allowed at global scope", token); return true; } // // For now, keep it simple: if it starts "gl_", it's reserved, independent // of scope. Except, if the symbol table is at the built-in push-level, // which is when we are parsing built-ins. // Also checks for "webgl_" and "_webgl_" reserved identifiers if parsing a // webgl shader. // // Returns true if there was an error. // bool TParseContext::reservedErrorCheck(const TSourceLoc &line, const TString &identifier) { static const char *reservedErrMsg = "reserved built-in name"; if (!symbolTable.atBuiltInLevel()) { if (identifier.compare(0, 3, "gl_") == 0) { error(line, reservedErrMsg, "gl_"); return true; } if (identifier.find("__") != TString::npos) { error(line, "identifiers containing two consecutive underscores (__) are reserved as " "possible future keywords", identifier.c_str()); return true; } } return false; } // // Make sure there is enough data provided to the constructor to build // something of the type of the constructor. Also returns the type of // the constructor. // // Returns true if there was an error in construction. // bool TParseContext::constructorErrorCheck(const TSourceLoc &line, TIntermNode *node, TFunction &function, TOperator op, TType *type) { *type = function.getReturnType(); bool constructingMatrix = false; switch (op) { case EOpConstructMat2: case EOpConstructMat2x3: case EOpConstructMat2x4: case EOpConstructMat3x2: case EOpConstructMat3: case EOpConstructMat3x4: case EOpConstructMat4x2: case EOpConstructMat4x3: case EOpConstructMat4: constructingMatrix = true; break; default: break; } // // Note: It's okay to have too many components available, but not okay to have unused // arguments. 'full' will go to true when enough args have been seen. If we loop // again, there is an extra argument, so 'overfull' will become true. // size_t size = 0; bool constType = true; bool full = false; bool overFull = false; bool matrixInMatrix = false; bool arrayArg = false; for (size_t i = 0; i < function.getParamCount(); ++i) { const TConstParameter ¶m = function.getParam(i); size += param.type->getObjectSize(); if (constructingMatrix && param.type->isMatrix()) matrixInMatrix = true; if (full) overFull = true; if (op != EOpConstructStruct && !type->isArray() && size >= type->getObjectSize()) full = true; if (param.type->getQualifier() != EvqConst) constType = false; if (param.type->isArray()) arrayArg = true; } if (constType) type->setQualifier(EvqConst); if (type->isArray()) { if (type->isUnsizedArray()) { type->setArraySize(static_cast(function.getParamCount())); } else if (static_cast(type->getArraySize()) != function.getParamCount()) { error(line, "array constructor needs one argument per array element", "constructor"); return true; } } if (arrayArg && op != EOpConstructStruct) { error(line, "constructing from a non-dereferenced array", "constructor"); return true; } if (matrixInMatrix && !type->isArray()) { if (function.getParamCount() != 1) { error(line, "constructing matrix from matrix can only take one argument", "constructor"); return true; } } if (overFull) { error(line, "too many arguments", "constructor"); return true; } if (op == EOpConstructStruct && !type->isArray() && type->getStruct()->fields().size() != function.getParamCount()) { error(line, "Number of constructor parameters does not match the number of structure fields", "constructor"); return true; } if (!type->isMatrix() || !matrixInMatrix) { if ((op != EOpConstructStruct && size != 1 && size < type->getObjectSize()) || (op == EOpConstructStruct && size < type->getObjectSize())) { error(line, "not enough data provided for construction", "constructor"); return true; } } TIntermTyped *typed = node ? node->getAsTyped() : 0; if (typed == 0) { error(line, "constructor argument does not have a type", "constructor"); return true; } if (op != EOpConstructStruct && IsSampler(typed->getBasicType())) { error(line, "cannot convert a sampler", "constructor"); return true; } if (typed->getBasicType() == EbtVoid) { error(line, "cannot convert a void", "constructor"); return true; } return false; } // This function checks to see if a void variable has been declared and raise an error message for // such a case // // returns true in case of an error // bool TParseContext::voidErrorCheck(const TSourceLoc &line, const TString &identifier, const TBasicType &type) { if (type == EbtVoid) { error(line, "illegal use of type 'void'", identifier.c_str()); return true; } return false; } // This function checks to see if the node (for the expression) contains a scalar boolean expression // or not // // returns true in case of an error // bool TParseContext::boolErrorCheck(const TSourceLoc &line, const TIntermTyped *type) { if (type->getBasicType() != EbtBool || type->isArray() || type->isMatrix() || type->isVector()) { error(line, "boolean expression expected", ""); return true; } return false; } // This function checks to see if the node (for the expression) contains a scalar boolean expression // or not // // returns true in case of an error // bool TParseContext::boolErrorCheck(const TSourceLoc &line, const TPublicType &pType) { if (pType.type != EbtBool || pType.isAggregate()) { error(line, "boolean expression expected", ""); return true; } return false; } bool TParseContext::samplerErrorCheck(const TSourceLoc &line, const TPublicType &pType, const char *reason) { if (pType.type == EbtStruct) { if (containsSampler(*pType.userDef)) { error(line, reason, getBasicString(pType.type), "(structure contains a sampler)"); return true; } return false; } else if (IsSampler(pType.type)) { error(line, reason, getBasicString(pType.type)); return true; } return false; } bool TParseContext::locationDeclaratorListCheck(const TSourceLoc &line, const TPublicType &pType) { if (pType.layoutQualifier.location != -1) { error(line, "location must only be specified for a single input or output variable", "location"); return true; } return false; } bool TParseContext::parameterSamplerErrorCheck(const TSourceLoc &line, TQualifier qualifier, const TType &type) { if ((qualifier == EvqOut || qualifier == EvqInOut) && type.getBasicType() != EbtStruct && IsSampler(type.getBasicType())) { error(line, "samplers cannot be output parameters", type.getBasicString()); return true; } return false; } bool TParseContext::containsSampler(const TType &type) { if (IsSampler(type.getBasicType())) return true; if (type.getBasicType() == EbtStruct || type.isInterfaceBlock()) { const TFieldList &fields = type.getStruct()->fields(); for (unsigned int i = 0; i < fields.size(); ++i) { if (containsSampler(*fields[i]->type())) return true; } } return false; } // // Do size checking for an array type's size. // // Returns true if there was an error. // bool TParseContext::arraySizeErrorCheck(const TSourceLoc &line, TIntermTyped *expr, int &size) { TIntermConstantUnion *constant = expr->getAsConstantUnion(); if (constant == nullptr || !constant->isScalarInt()) { error(line, "array size must be a constant integer expression", ""); size = 1; return true; } unsigned int unsignedSize = 0; if (constant->getBasicType() == EbtUInt) { unsignedSize = constant->getUConst(0); size = static_cast(unsignedSize); } else { size = constant->getIConst(0); if (size < 0) { error(line, "array size must be non-negative", ""); size = 1; return true; } unsignedSize = static_cast(size); } if (size == 0) { error(line, "array size must be greater than zero", ""); size = 1; return true; } // The size of arrays is restricted here to prevent issues further down the // compiler/translator/driver stack. Shader Model 5 generation hardware is limited to // 4096 registers so this should be reasonable even for aggressively optimizable code. const unsigned int sizeLimit = 65536; if (unsignedSize > sizeLimit) { error(line, "array size too large", ""); size = 1; return true; } return false; } // // See if this qualifier can be an array. // // Returns true if there is an error. // bool TParseContext::arrayQualifierErrorCheck(const TSourceLoc &line, const TPublicType &type) { if ((type.qualifier == EvqAttribute) || (type.qualifier == EvqVertexIn) || (type.qualifier == EvqConst && mShaderVersion < 300)) { error(line, "cannot declare arrays of this qualifier", TType(type).getCompleteString().c_str()); return true; } return false; } // // See if this type can be an array. // // Returns true if there is an error. // bool TParseContext::arrayTypeErrorCheck(const TSourceLoc &line, const TPublicType &type) { // // Can the type be an array? // if (type.array) { error(line, "cannot declare arrays of arrays", TType(type).getCompleteString().c_str()); return true; } // In ESSL1.00 shaders, structs cannot be varying (section 4.3.5). This is checked elsewhere. // In ESSL3.00 shaders, struct inputs/outputs are allowed but not arrays of structs (section // 4.3.4). if (mShaderVersion >= 300 && type.type == EbtStruct && sh::IsVarying(type.qualifier)) { error(line, "cannot declare arrays of structs of this qualifier", TType(type).getCompleteString().c_str()); return true; } return false; } // // Enforce non-initializer type/qualifier rules. // // Returns true if there was an error. // bool TParseContext::nonInitErrorCheck(const TSourceLoc &line, const TString &identifier, TPublicType *type) { ASSERT(type != nullptr); if (type->qualifier == EvqConst) { // Make the qualifier make sense. type->qualifier = EvqTemporary; // Generate informative error messages for ESSL1. // In ESSL3 arrays and structures containing arrays can be constant. if (mShaderVersion < 300 && type->isStructureContainingArrays()) { error(line, "structures containing arrays may not be declared constant since they cannot be " "initialized", identifier.c_str()); } else { error(line, "variables with qualifier 'const' must be initialized", identifier.c_str()); } return true; } if (type->isUnsizedArray()) { error(line, "implicitly sized arrays need to be initialized", identifier.c_str()); return true; } return false; } // Do some simple checks that are shared between all variable declarations, // and update the symbol table. // // Returns true if declaring the variable succeeded. // bool TParseContext::declareVariable(const TSourceLoc &line, const TString &identifier, const TType &type, TVariable **variable) { ASSERT((*variable) == nullptr); bool needsReservedErrorCheck = true; // gl_LastFragData may be redeclared with a new precision qualifier if (type.isArray() && identifier.compare(0, 15, "gl_LastFragData") == 0) { const TVariable *maxDrawBuffers = static_cast( symbolTable.findBuiltIn("gl_MaxDrawBuffers", mShaderVersion)); if (type.getArraySize() == maxDrawBuffers->getConstPointer()->getIConst()) { if (TSymbol *builtInSymbol = symbolTable.findBuiltIn(identifier, mShaderVersion)) { needsReservedErrorCheck = extensionErrorCheck(line, builtInSymbol->getExtension()); } } else { error(line, "redeclaration of gl_LastFragData with size != gl_MaxDrawBuffers", identifier.c_str()); return false; } } if (needsReservedErrorCheck && reservedErrorCheck(line, identifier)) return false; (*variable) = new TVariable(&identifier, type); if (!symbolTable.declare(*variable)) { error(line, "redefinition", identifier.c_str()); *variable = nullptr; return false; } if (voidErrorCheck(line, identifier, type.getBasicType())) return false; return true; } bool TParseContext::paramErrorCheck(const TSourceLoc &line, TQualifier qualifier, TQualifier paramQualifier, TType *type) { if (qualifier != EvqConst && qualifier != EvqTemporary) { error(line, "qualifier not allowed on function parameter", getQualifierString(qualifier)); return true; } if (qualifier == EvqConst && paramQualifier != EvqIn) { error(line, "qualifier not allowed with ", getQualifierString(qualifier), getQualifierString(paramQualifier)); return true; } if (qualifier == EvqConst) type->setQualifier(EvqConstReadOnly); else type->setQualifier(paramQualifier); return false; } bool TParseContext::extensionErrorCheck(const TSourceLoc &line, const TString &extension) { const TExtensionBehavior &extBehavior = extensionBehavior(); TExtensionBehavior::const_iterator iter = extBehavior.find(extension.c_str()); if (iter == extBehavior.end()) { error(line, "extension", extension.c_str(), "is not supported"); return true; } // In GLSL ES, an extension's default behavior is "disable". if (iter->second == EBhDisable || iter->second == EBhUndefined) { error(line, "extension", extension.c_str(), "is disabled"); return true; } if (iter->second == EBhWarn) { warning(line, "extension", extension.c_str(), "is being used"); return false; } return false; } // These checks are common for all declarations starting a declarator list, and declarators that // follow an empty declaration. // bool TParseContext::singleDeclarationErrorCheck(const TPublicType &publicType, const TSourceLoc &identifierLocation) { switch (publicType.qualifier) { case EvqVaryingIn: case EvqVaryingOut: case EvqAttribute: case EvqVertexIn: case EvqFragmentOut: if (publicType.type == EbtStruct) { error(identifierLocation, "cannot be used with a structure", getQualifierString(publicType.qualifier)); return true; } default: break; } if (publicType.qualifier != EvqUniform && samplerErrorCheck(identifierLocation, publicType, "samplers must be uniform")) { return true; } // check for layout qualifier issues const TLayoutQualifier layoutQualifier = publicType.layoutQualifier; if (layoutQualifier.matrixPacking != EmpUnspecified) { error(identifierLocation, "layout qualifier", getMatrixPackingString(layoutQualifier.matrixPacking), "only valid for interface blocks"); return true; } if (layoutQualifier.blockStorage != EbsUnspecified) { error(identifierLocation, "layout qualifier", getBlockStorageString(layoutQualifier.blockStorage), "only valid for interface blocks"); return true; } if (publicType.qualifier != EvqVertexIn && publicType.qualifier != EvqFragmentOut && layoutLocationErrorCheck(identifierLocation, publicType.layoutQualifier)) { return true; } return false; } bool TParseContext::layoutLocationErrorCheck(const TSourceLoc &location, const TLayoutQualifier &layoutQualifier) { if (layoutQualifier.location != -1) { error(location, "invalid layout qualifier:", "location", "only valid on program inputs and outputs"); return true; } return false; } bool TParseContext::functionCallLValueErrorCheck(const TFunction *fnCandidate, TIntermAggregate *aggregate) { for (size_t i = 0; i < fnCandidate->getParamCount(); ++i) { TQualifier qual = fnCandidate->getParam(i).type->getQualifier(); if (qual == EvqOut || qual == EvqInOut) { TIntermTyped *node = (*(aggregate->getSequence()))[i]->getAsTyped(); if (lValueErrorCheck(node->getLine(), "assign", node)) { error(node->getLine(), "Constant value cannot be passed for 'out' or 'inout' parameters.", "Error"); recover(); return true; } } } return false; } void TParseContext::es3InvariantErrorCheck(const TQualifier qualifier, const TSourceLoc &invariantLocation) { if (!sh::IsVaryingOut(qualifier) && qualifier != EvqFragmentOut) { error(invariantLocation, "Only out variables can be invariant.", "invariant"); recover(); } } bool TParseContext::supportsExtension(const char *extension) { const TExtensionBehavior &extbehavior = extensionBehavior(); TExtensionBehavior::const_iterator iter = extbehavior.find(extension); return (iter != extbehavior.end()); } bool TParseContext::isExtensionEnabled(const char *extension) const { return ::IsExtensionEnabled(extensionBehavior(), extension); } void TParseContext::handleExtensionDirective(const TSourceLoc &loc, const char *extName, const char *behavior) { pp::SourceLocation srcLoc; srcLoc.file = loc.first_file; srcLoc.line = loc.first_line; mDirectiveHandler.handleExtension(srcLoc, extName, behavior); } void TParseContext::handlePragmaDirective(const TSourceLoc &loc, const char *name, const char *value, bool stdgl) { pp::SourceLocation srcLoc; srcLoc.file = loc.first_file; srcLoc.line = loc.first_line; mDirectiveHandler.handlePragma(srcLoc, name, value, stdgl); } ///////////////////////////////////////////////////////////////////////////////// // // Non-Errors. // ///////////////////////////////////////////////////////////////////////////////// const TVariable *TParseContext::getNamedVariable(const TSourceLoc &location, const TString *name, const TSymbol *symbol) { const TVariable *variable = NULL; if (!symbol) { error(location, "undeclared identifier", name->c_str()); recover(); } else if (!symbol->isVariable()) { error(location, "variable expected", name->c_str()); recover(); } else { variable = static_cast(symbol); if (symbolTable.findBuiltIn(variable->getName(), mShaderVersion) && !variable->getExtension().empty() && extensionErrorCheck(location, variable->getExtension())) { recover(); } // Reject shaders using both gl_FragData and gl_FragColor TQualifier qualifier = variable->getType().getQualifier(); if (qualifier == EvqFragData || qualifier == EvqSecondaryFragDataEXT) { mUsesFragData = true; } else if (qualifier == EvqFragColor || qualifier == EvqSecondaryFragColorEXT) { mUsesFragColor = true; } if (qualifier == EvqSecondaryFragDataEXT || qualifier == EvqSecondaryFragColorEXT) { mUsesSecondaryOutputs = true; } // This validation is not quite correct - it's only an error to write to // both FragData and FragColor. For simplicity, and because users shouldn't // be rewarded for reading from undefined varaibles, return an error // if they are both referenced, rather than assigned. if (mUsesFragData && mUsesFragColor) { const char *errorMessage = "cannot use both gl_FragData and gl_FragColor"; if (mUsesSecondaryOutputs) { errorMessage = "cannot use both output variable sets (gl_FragData, gl_SecondaryFragDataEXT)" " and (gl_FragColor, gl_SecondaryFragColorEXT)"; } error(location, errorMessage, name->c_str()); recover(); } } if (!variable) { TType type(EbtFloat, EbpUndefined); TVariable *fakeVariable = new TVariable(name, type); symbolTable.declare(fakeVariable); variable = fakeVariable; } return variable; } // // Look up a function name in the symbol table, and make sure it is a function. // // Return the function symbol if found, otherwise 0. // const TFunction *TParseContext::findFunction(const TSourceLoc &line, TFunction *call, int inputShaderVersion, bool *builtIn) { // First find by unmangled name to check whether the function name has been // hidden by a variable name or struct typename. // If a function is found, check for one with a matching argument list. const TSymbol *symbol = symbolTable.find(call->getName(), inputShaderVersion, builtIn); if (symbol == 0 || symbol->isFunction()) { symbol = symbolTable.find(call->getMangledName(), inputShaderVersion, builtIn); } if (symbol == 0) { error(line, "no matching overloaded function found", call->getName().c_str()); return 0; } if (!symbol->isFunction()) { error(line, "function name expected", call->getName().c_str()); return 0; } return static_cast(symbol); } // // Initializers show up in several places in the grammar. Have one set of // code to handle them here. // // Returns true on error, false if no error // bool TParseContext::executeInitializer(const TSourceLoc &line, const TString &identifier, const TPublicType &pType, TIntermTyped *initializer, TIntermNode **intermNode) { ASSERT(intermNode != nullptr); TType type = TType(pType); TVariable *variable = nullptr; if (type.isUnsizedArray()) { type.setArraySize(initializer->getArraySize()); } if (!declareVariable(line, identifier, type, &variable)) { return true; } bool globalInitWarning = false; if (symbolTable.atGlobalLevel() && !ValidateGlobalInitializer(initializer, this, &globalInitWarning)) { // Error message does not completely match behavior with ESSL 1.00, but // we want to steer developers towards only using constant expressions. error(line, "global variable initializers must be constant expressions", "="); return true; } if (globalInitWarning) { warning( line, "global variable initializers should be constant expressions " "(uniforms and globals are allowed in global initializers for legacy compatibility)", "="); } // // identifier must be of type constant, a global, or a temporary // TQualifier qualifier = variable->getType().getQualifier(); if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal) && (qualifier != EvqConst)) { error(line, " cannot initialize this type of qualifier ", variable->getType().getQualifierString()); return true; } // // test for and propagate constant // if (qualifier == EvqConst) { if (qualifier != initializer->getType().getQualifier()) { std::stringstream extraInfoStream; extraInfoStream << "'" << variable->getType().getCompleteString() << "'"; std::string extraInfo = extraInfoStream.str(); error(line, " assigning non-constant to", "=", extraInfo.c_str()); variable->getType().setQualifier(EvqTemporary); return true; } if (type != initializer->getType()) { error(line, " non-matching types for const initializer ", variable->getType().getQualifierString()); variable->getType().setQualifier(EvqTemporary); return true; } if (initializer->getAsConstantUnion()) { variable->shareConstPointer(initializer->getAsConstantUnion()->getUnionArrayPointer()); } else if (initializer->getAsSymbolNode()) { const TSymbol *symbol = symbolTable.find(initializer->getAsSymbolNode()->getSymbol(), 0); const TVariable *tVar = static_cast(symbol); TConstantUnion *constArray = tVar->getConstPointer(); variable->shareConstPointer(constArray); } else { std::stringstream extraInfoStream; extraInfoStream << "'" << variable->getType().getCompleteString() << "'"; std::string extraInfo = extraInfoStream.str(); error(line, " cannot assign to", "=", extraInfo.c_str()); variable->getType().setQualifier(EvqTemporary); return true; } } if (qualifier != EvqConst) { TIntermSymbol *intermSymbol = intermediate.addSymbol( variable->getUniqueId(), variable->getName(), variable->getType(), line); *intermNode = createAssign(EOpInitialize, intermSymbol, initializer, line); if (*intermNode == nullptr) { assignError(line, "=", intermSymbol->getCompleteString(), initializer->getCompleteString()); return true; } } else { *intermNode = nullptr; } return false; } bool TParseContext::areAllChildConst(TIntermAggregate *aggrNode) { ASSERT(aggrNode != NULL); if (!aggrNode->isConstructor()) return false; bool allConstant = true; // check if all the child nodes are constants so that they can be inserted into // the parent node TIntermSequence *sequence = aggrNode->getSequence(); for (TIntermSequence::iterator p = sequence->begin(); p != sequence->end(); ++p) { if (!(*p)->getAsTyped()->getAsConstantUnion()) return false; } return allConstant; } TPublicType TParseContext::addFullySpecifiedType(TQualifier qualifier, bool invariant, TLayoutQualifier layoutQualifier, const TPublicType &typeSpecifier) { TPublicType returnType = typeSpecifier; returnType.qualifier = qualifier; returnType.invariant = invariant; returnType.layoutQualifier = layoutQualifier; if (mShaderVersion < 300) { if (typeSpecifier.array) { error(typeSpecifier.line, "not supported", "first-class array"); recover(); returnType.clearArrayness(); } if (qualifier == EvqAttribute && (typeSpecifier.type == EbtBool || typeSpecifier.type == EbtInt)) { error(typeSpecifier.line, "cannot be bool or int", getQualifierString(qualifier)); recover(); } if ((qualifier == EvqVaryingIn || qualifier == EvqVaryingOut) && (typeSpecifier.type == EbtBool || typeSpecifier.type == EbtInt)) { error(typeSpecifier.line, "cannot be bool or int", getQualifierString(qualifier)); recover(); } } else { if (!layoutQualifier.isEmpty()) { if (globalErrorCheck(typeSpecifier.line, symbolTable.atGlobalLevel(), "layout")) { recover(); } } if (sh::IsVarying(qualifier) || qualifier == EvqVertexIn || qualifier == EvqFragmentOut) { es3InputOutputTypeCheck(qualifier, typeSpecifier, typeSpecifier.line); } } return returnType; } void TParseContext::es3InputOutputTypeCheck(const TQualifier qualifier, const TPublicType &type, const TSourceLoc &qualifierLocation) { // An input/output variable can never be bool or a sampler. Samplers are checked elsewhere. if (type.type == EbtBool) { error(qualifierLocation, "cannot be bool", getQualifierString(qualifier)); recover(); } // Specific restrictions apply for vertex shader inputs and fragment shader outputs. switch (qualifier) { case EvqVertexIn: // ESSL 3.00 section 4.3.4 if (type.array) { error(qualifierLocation, "cannot be array", getQualifierString(qualifier)); recover(); } // Vertex inputs with a struct type are disallowed in singleDeclarationErrorCheck return; case EvqFragmentOut: // ESSL 3.00 section 4.3.6 if (type.isMatrix()) { error(qualifierLocation, "cannot be matrix", getQualifierString(qualifier)); recover(); } // Fragment outputs with a struct type are disallowed in singleDeclarationErrorCheck return; default: break; } // Vertex shader outputs / fragment shader inputs have a different, slightly more lenient set of // restrictions. bool typeContainsIntegers = (type.type == EbtInt || type.type == EbtUInt || type.isStructureContainingType(EbtInt) || type.isStructureContainingType(EbtUInt)); if (typeContainsIntegers && qualifier != EvqFlatIn && qualifier != EvqFlatOut) { error(qualifierLocation, "must use 'flat' interpolation here", getQualifierString(qualifier)); recover(); } if (type.type == EbtStruct) { // ESSL 3.00 sections 4.3.4 and 4.3.6. // These restrictions are only implied by the ESSL 3.00 spec, but // the ESSL 3.10 spec lists these restrictions explicitly. if (type.array) { error(qualifierLocation, "cannot be an array of structures", getQualifierString(qualifier)); recover(); } if (type.isStructureContainingArrays()) { error(qualifierLocation, "cannot be a structure containing an array", getQualifierString(qualifier)); recover(); } if (type.isStructureContainingType(EbtStruct)) { error(qualifierLocation, "cannot be a structure containing a structure", getQualifierString(qualifier)); recover(); } if (type.isStructureContainingType(EbtBool)) { error(qualifierLocation, "cannot be a structure containing a bool", getQualifierString(qualifier)); recover(); } } } TIntermAggregate *TParseContext::parseSingleDeclaration(TPublicType &publicType, const TSourceLoc &identifierOrTypeLocation, const TString &identifier) { TIntermSymbol *symbol = intermediate.addSymbol(0, identifier, TType(publicType), identifierOrTypeLocation); bool emptyDeclaration = (identifier == ""); mDeferredSingleDeclarationErrorCheck = emptyDeclaration; if (emptyDeclaration) { if (publicType.isUnsizedArray()) { // ESSL3 spec section 4.1.9: Array declaration which leaves the size unspecified is an // error. It is assumed that this applies to empty declarations as well. error(identifierOrTypeLocation, "empty array declaration needs to specify a size", identifier.c_str()); } } else { if (singleDeclarationErrorCheck(publicType, identifierOrTypeLocation)) recover(); if (nonInitErrorCheck(identifierOrTypeLocation, identifier, &publicType)) recover(); TVariable *variable = nullptr; if (!declareVariable(identifierOrTypeLocation, identifier, TType(publicType), &variable)) recover(); if (variable && symbol) symbol->setId(variable->getUniqueId()); } return intermediate.makeAggregate(symbol, identifierOrTypeLocation); } TIntermAggregate *TParseContext::parseSingleArrayDeclaration(TPublicType &publicType, const TSourceLoc &identifierLocation, const TString &identifier, const TSourceLoc &indexLocation, TIntermTyped *indexExpression) { mDeferredSingleDeclarationErrorCheck = false; if (singleDeclarationErrorCheck(publicType, identifierLocation)) recover(); if (nonInitErrorCheck(identifierLocation, identifier, &publicType)) recover(); if (arrayTypeErrorCheck(indexLocation, publicType) || arrayQualifierErrorCheck(indexLocation, publicType)) { recover(); } TType arrayType(publicType); int size; if (arraySizeErrorCheck(identifierLocation, indexExpression, size)) { recover(); } // Make the type an array even if size check failed. // This ensures useless error messages regarding the variable's non-arrayness won't follow. arrayType.setArraySize(size); TVariable *variable = nullptr; if (!declareVariable(identifierLocation, identifier, arrayType, &variable)) recover(); TIntermSymbol *symbol = intermediate.addSymbol(0, identifier, arrayType, identifierLocation); if (variable && symbol) symbol->setId(variable->getUniqueId()); return intermediate.makeAggregate(symbol, identifierLocation); } TIntermAggregate *TParseContext::parseSingleInitDeclaration(const TPublicType &publicType, const TSourceLoc &identifierLocation, const TString &identifier, const TSourceLoc &initLocation, TIntermTyped *initializer) { mDeferredSingleDeclarationErrorCheck = false; if (singleDeclarationErrorCheck(publicType, identifierLocation)) recover(); TIntermNode *intermNode = nullptr; if (!executeInitializer(identifierLocation, identifier, publicType, initializer, &intermNode)) { // // Build intermediate representation // return intermNode ? intermediate.makeAggregate(intermNode, initLocation) : nullptr; } else { recover(); return nullptr; } } TIntermAggregate *TParseContext::parseSingleArrayInitDeclaration( TPublicType &publicType, const TSourceLoc &identifierLocation, const TString &identifier, const TSourceLoc &indexLocation, TIntermTyped *indexExpression, const TSourceLoc &initLocation, TIntermTyped *initializer) { mDeferredSingleDeclarationErrorCheck = false; if (singleDeclarationErrorCheck(publicType, identifierLocation)) recover(); if (arrayTypeErrorCheck(indexLocation, publicType) || arrayQualifierErrorCheck(indexLocation, publicType)) { recover(); } TPublicType arrayType(publicType); int size = 0; // If indexExpression is nullptr, then the array will eventually get its size implicitly from // the initializer. if (indexExpression != nullptr && arraySizeErrorCheck(identifierLocation, indexExpression, size)) { recover(); } // Make the type an array even if size check failed. // This ensures useless error messages regarding the variable's non-arrayness won't follow. arrayType.setArraySize(size); // initNode will correspond to the whole of "type b[n] = initializer". TIntermNode *initNode = nullptr; if (!executeInitializer(identifierLocation, identifier, arrayType, initializer, &initNode)) { return initNode ? intermediate.makeAggregate(initNode, initLocation) : nullptr; } else { recover(); return nullptr; } } TIntermAggregate *TParseContext::parseInvariantDeclaration(const TSourceLoc &invariantLoc, const TSourceLoc &identifierLoc, const TString *identifier, const TSymbol *symbol) { // invariant declaration if (globalErrorCheck(invariantLoc, symbolTable.atGlobalLevel(), "invariant varying")) { recover(); } if (!symbol) { error(identifierLoc, "undeclared identifier declared as invariant", identifier->c_str()); recover(); return nullptr; } else { const TString kGlFrontFacing("gl_FrontFacing"); if (*identifier == kGlFrontFacing) { error(identifierLoc, "identifier should not be declared as invariant", identifier->c_str()); recover(); return nullptr; } symbolTable.addInvariantVarying(std::string(identifier->c_str())); const TVariable *variable = getNamedVariable(identifierLoc, identifier, symbol); ASSERT(variable); const TType &type = variable->getType(); TIntermSymbol *intermSymbol = intermediate.addSymbol(variable->getUniqueId(), *identifier, type, identifierLoc); TIntermAggregate *aggregate = intermediate.makeAggregate(intermSymbol, identifierLoc); aggregate->setOp(EOpInvariantDeclaration); return aggregate; } } TIntermAggregate *TParseContext::parseDeclarator(TPublicType &publicType, TIntermAggregate *aggregateDeclaration, const TSourceLoc &identifierLocation, const TString &identifier) { // If the declaration starting this declarator list was empty (example: int,), some checks were // not performed. if (mDeferredSingleDeclarationErrorCheck) { if (singleDeclarationErrorCheck(publicType, identifierLocation)) recover(); mDeferredSingleDeclarationErrorCheck = false; } if (locationDeclaratorListCheck(identifierLocation, publicType)) recover(); if (nonInitErrorCheck(identifierLocation, identifier, &publicType)) recover(); TVariable *variable = nullptr; if (!declareVariable(identifierLocation, identifier, TType(publicType), &variable)) recover(); TIntermSymbol *symbol = intermediate.addSymbol(0, identifier, TType(publicType), identifierLocation); if (variable && symbol) symbol->setId(variable->getUniqueId()); return intermediate.growAggregate(aggregateDeclaration, symbol, identifierLocation); } TIntermAggregate *TParseContext::parseArrayDeclarator(TPublicType &publicType, TIntermAggregate *aggregateDeclaration, const TSourceLoc &identifierLocation, const TString &identifier, const TSourceLoc &arrayLocation, TIntermTyped *indexExpression) { // If the declaration starting this declarator list was empty (example: int,), some checks were // not performed. if (mDeferredSingleDeclarationErrorCheck) { if (singleDeclarationErrorCheck(publicType, identifierLocation)) recover(); mDeferredSingleDeclarationErrorCheck = false; } if (locationDeclaratorListCheck(identifierLocation, publicType)) recover(); if (nonInitErrorCheck(identifierLocation, identifier, &publicType)) recover(); if (arrayTypeErrorCheck(arrayLocation, publicType) || arrayQualifierErrorCheck(arrayLocation, publicType)) { recover(); } else { TType arrayType = TType(publicType); int size; if (arraySizeErrorCheck(arrayLocation, indexExpression, size)) { recover(); } arrayType.setArraySize(size); TVariable *variable = nullptr; if (!declareVariable(identifierLocation, identifier, arrayType, &variable)) recover(); TIntermSymbol *symbol = intermediate.addSymbol(0, identifier, arrayType, identifierLocation); if (variable && symbol) symbol->setId(variable->getUniqueId()); return intermediate.growAggregate(aggregateDeclaration, symbol, identifierLocation); } return nullptr; } TIntermAggregate *TParseContext::parseInitDeclarator(const TPublicType &publicType, TIntermAggregate *aggregateDeclaration, const TSourceLoc &identifierLocation, const TString &identifier, const TSourceLoc &initLocation, TIntermTyped *initializer) { // If the declaration starting this declarator list was empty (example: int,), some checks were // not performed. if (mDeferredSingleDeclarationErrorCheck) { if (singleDeclarationErrorCheck(publicType, identifierLocation)) recover(); mDeferredSingleDeclarationErrorCheck = false; } if (locationDeclaratorListCheck(identifierLocation, publicType)) recover(); TIntermNode *intermNode = nullptr; if (!executeInitializer(identifierLocation, identifier, publicType, initializer, &intermNode)) { // // build the intermediate representation // if (intermNode) { return intermediate.growAggregate(aggregateDeclaration, intermNode, initLocation); } else { return aggregateDeclaration; } } else { recover(); return nullptr; } } TIntermAggregate *TParseContext::parseArrayInitDeclarator(const TPublicType &publicType, TIntermAggregate *aggregateDeclaration, const TSourceLoc &identifierLocation, const TString &identifier, const TSourceLoc &indexLocation, TIntermTyped *indexExpression, const TSourceLoc &initLocation, TIntermTyped *initializer) { // If the declaration starting this declarator list was empty (example: int,), some checks were // not performed. if (mDeferredSingleDeclarationErrorCheck) { if (singleDeclarationErrorCheck(publicType, identifierLocation)) recover(); mDeferredSingleDeclarationErrorCheck = false; } if (locationDeclaratorListCheck(identifierLocation, publicType)) recover(); if (arrayTypeErrorCheck(indexLocation, publicType) || arrayQualifierErrorCheck(indexLocation, publicType)) { recover(); } TPublicType arrayType(publicType); int size = 0; // If indexExpression is nullptr, then the array will eventually get its size implicitly from // the initializer. if (indexExpression != nullptr && arraySizeErrorCheck(identifierLocation, indexExpression, size)) { recover(); } // Make the type an array even if size check failed. // This ensures useless error messages regarding the variable's non-arrayness won't follow. arrayType.setArraySize(size); // initNode will correspond to the whole of "b[n] = initializer". TIntermNode *initNode = nullptr; if (!executeInitializer(identifierLocation, identifier, arrayType, initializer, &initNode)) { if (initNode) { return intermediate.growAggregate(aggregateDeclaration, initNode, initLocation); } else { return aggregateDeclaration; } } else { recover(); return nullptr; } } void TParseContext::parseGlobalLayoutQualifier(const TPublicType &typeQualifier) { if (typeQualifier.qualifier != EvqUniform) { error(typeQualifier.line, "invalid qualifier:", getQualifierString(typeQualifier.qualifier), "global layout must be uniform"); recover(); return; } const TLayoutQualifier layoutQualifier = typeQualifier.layoutQualifier; ASSERT(!layoutQualifier.isEmpty()); if (mShaderVersion < 300) { error(typeQualifier.line, "layout qualifiers supported in GLSL ES 3.00 only", "layout"); recover(); return; } if (layoutLocationErrorCheck(typeQualifier.line, typeQualifier.layoutQualifier)) { recover(); return; } if (layoutQualifier.matrixPacking != EmpUnspecified) { mDefaultMatrixPacking = layoutQualifier.matrixPacking; } if (layoutQualifier.blockStorage != EbsUnspecified) { mDefaultBlockStorage = layoutQualifier.blockStorage; } } void TParseContext::parseFunctionPrototype(const TSourceLoc &location, TFunction *function, TIntermAggregate **aggregateOut) { const TSymbol *builtIn = symbolTable.findBuiltIn(function->getMangledName(), getShaderVersion()); if (builtIn) { error(location, "built-in functions cannot be redefined", function->getName().c_str()); recover(); } TFunction *prevDec = static_cast(symbolTable.find(function->getMangledName(), getShaderVersion())); // // Note: 'prevDec' could be 'function' if this is the first time we've seen function // as it would have just been put in the symbol table. Otherwise, we're looking up // an earlier occurrence. // if (prevDec->isDefined()) { // Then this function already has a body. error(location, "function already has a body", function->getName().c_str()); recover(); } prevDec->setDefined(); // // Overload the unique ID of the definition to be the same unique ID as the declaration. // Eventually we will probably want to have only a single definition and just swap the // arguments to be the definition's arguments. // function->setUniqueId(prevDec->getUniqueId()); // Raise error message if main function takes any parameters or return anything other than void if (function->getName() == "main") { if (function->getParamCount() > 0) { error(location, "function cannot take any parameter(s)", function->getName().c_str()); recover(); } if (function->getReturnType().getBasicType() != EbtVoid) { error(location, "", function->getReturnType().getBasicString(), "main function cannot return a value"); recover(); } } // // Remember the return type for later checking for RETURN statements. // setCurrentFunctionType(&(prevDec->getReturnType())); setFunctionReturnsValue(false); // // Insert parameters into the symbol table. // If the parameter has no name, it's not an error, just don't insert it // (could be used for unused args). // // Also, accumulate the list of parameters into the HIL, so lower level code // knows where to find parameters. // TIntermAggregate *paramNodes = new TIntermAggregate; for (size_t i = 0; i < function->getParamCount(); i++) { const TConstParameter ¶m = function->getParam(i); if (param.name != 0) { TVariable *variable = new TVariable(param.name, *param.type); // // Insert the parameters with name in the symbol table. // if (!symbolTable.declare(variable)) { error(location, "redefinition", variable->getName().c_str()); recover(); paramNodes = intermediate.growAggregate( paramNodes, intermediate.addSymbol(0, "", *param.type, location), location); continue; } // // Add the parameter to the HIL // TIntermSymbol *symbol = intermediate.addSymbol( variable->getUniqueId(), variable->getName(), variable->getType(), location); paramNodes = intermediate.growAggregate(paramNodes, symbol, location); } else { paramNodes = intermediate.growAggregate( paramNodes, intermediate.addSymbol(0, "", *param.type, location), location); } } intermediate.setAggregateOperator(paramNodes, EOpParameters, location); *aggregateOut = paramNodes; setLoopNestingLevel(0); } TFunction *TParseContext::parseFunctionDeclarator(const TSourceLoc &location, TFunction *function) { // // Multiple declarations of the same function are allowed. // // If this is a definition, the definition production code will check for redefinitions // (we don't know at this point if it's a definition or not). // // Redeclarations are allowed. But, return types and parameter qualifiers must match. // TFunction *prevDec = static_cast(symbolTable.find(function->getMangledName(), getShaderVersion())); if (prevDec) { if (prevDec->getReturnType() != function->getReturnType()) { error(location, "overloaded functions must have the same return type", function->getReturnType().getBasicString()); recover(); } for (size_t i = 0; i < prevDec->getParamCount(); ++i) { if (prevDec->getParam(i).type->getQualifier() != function->getParam(i).type->getQualifier()) { error(location, "overloaded functions must have the same parameter qualifiers", function->getParam(i).type->getQualifierString()); recover(); } } } // // Check for previously declared variables using the same name. // TSymbol *prevSym = symbolTable.find(function->getName(), getShaderVersion()); if (prevSym) { if (!prevSym->isFunction()) { error(location, "redefinition", function->getName().c_str(), "function"); recover(); } } else { // Insert the unmangled name to detect potential future redefinition as a variable. TFunction *newFunction = new TFunction(NewPoolTString(function->getName().c_str()), &function->getReturnType()); symbolTable.getOuterLevel()->insertUnmangled(newFunction); } // We're at the inner scope level of the function's arguments and body statement. // Add the function prototype to the surrounding scope instead. symbolTable.getOuterLevel()->insert(function); // // If this is a redeclaration, it could also be a definition, in which case, we want to use the // variable names from this one, and not the one that's // being redeclared. So, pass back up this declaration, not the one in the symbol table. // return function; } TFunction *TParseContext::addConstructorFunc(const TPublicType &publicTypeIn) { TPublicType publicType = publicTypeIn; TOperator op = EOpNull; if (publicType.userDef) { op = EOpConstructStruct; } else { switch (publicType.type) { case EbtFloat: if (publicType.isMatrix()) { switch (publicType.getCols()) { case 2: switch (publicType.getRows()) { case 2: op = EOpConstructMat2; break; case 3: op = EOpConstructMat2x3; break; case 4: op = EOpConstructMat2x4; break; } break; case 3: switch (publicType.getRows()) { case 2: op = EOpConstructMat3x2; break; case 3: op = EOpConstructMat3; break; case 4: op = EOpConstructMat3x4; break; } break; case 4: switch (publicType.getRows()) { case 2: op = EOpConstructMat4x2; break; case 3: op = EOpConstructMat4x3; break; case 4: op = EOpConstructMat4; break; } break; } } else { switch (publicType.getNominalSize()) { case 1: op = EOpConstructFloat; break; case 2: op = EOpConstructVec2; break; case 3: op = EOpConstructVec3; break; case 4: op = EOpConstructVec4; break; } } break; case EbtInt: switch (publicType.getNominalSize()) { case 1: op = EOpConstructInt; break; case 2: op = EOpConstructIVec2; break; case 3: op = EOpConstructIVec3; break; case 4: op = EOpConstructIVec4; break; } break; case EbtUInt: switch (publicType.getNominalSize()) { case 1: op = EOpConstructUInt; break; case 2: op = EOpConstructUVec2; break; case 3: op = EOpConstructUVec3; break; case 4: op = EOpConstructUVec4; break; } break; case EbtBool: switch (publicType.getNominalSize()) { case 1: op = EOpConstructBool; break; case 2: op = EOpConstructBVec2; break; case 3: op = EOpConstructBVec3; break; case 4: op = EOpConstructBVec4; break; } break; default: break; } if (op == EOpNull) { error(publicType.line, "cannot construct this type", getBasicString(publicType.type)); recover(); publicType.type = EbtFloat; op = EOpConstructFloat; } } TString tempString; const TType *type = new TType(publicType); return new TFunction(&tempString, type, op); } // This function is used to test for the correctness of the parameters passed to various constructor // functions and also convert them to the right datatype if it is allowed and required. // // Returns 0 for an error or the constructed node (aggregate or typed) for no error. // TIntermTyped *TParseContext::addConstructor(TIntermNode *arguments, TType *type, TOperator op, TFunction *fnCall, const TSourceLoc &line) { TIntermAggregate *aggregateArguments = arguments->getAsAggregate(); if (!aggregateArguments) { aggregateArguments = new TIntermAggregate; aggregateArguments->getSequence()->push_back(arguments); } if (type->isArray()) { // GLSL ES 3.00 section 5.4.4: Each argument must be the same type as the element type of // the array. TIntermSequence *args = aggregateArguments->getSequence(); for (size_t i = 0; i < args->size(); i++) { const TType &argType = (*args)[i]->getAsTyped()->getType(); // It has already been checked that the argument is not an array. ASSERT(!argType.isArray()); if (!argType.sameElementType(*type)) { error(line, "Array constructor argument has an incorrect type", "Error"); recover(); return nullptr; } } } else if (op == EOpConstructStruct) { const TFieldList &fields = type->getStruct()->fields(); TIntermSequence *args = aggregateArguments->getSequence(); for (size_t i = 0; i < fields.size(); i++) { if (i >= args->size() || (*args)[i]->getAsTyped()->getType() != *fields[i]->type()) { error(line, "Structure constructor arguments do not match structure fields", "Error"); recover(); return 0; } } } // Turn the argument list itself into a constructor TIntermAggregate *constructor = intermediate.setAggregateOperator(aggregateArguments, op, line); TIntermTyped *constConstructor = foldConstConstructor(constructor, *type); if (constConstructor) { return constConstructor; } // Structs should not be precision qualified, the individual members may be. // Built-in types on the other hand should be precision qualified. if (op != EOpConstructStruct) { constructor->setPrecisionFromChildren(); type->setPrecision(constructor->getPrecision()); } return constructor; } TIntermTyped *TParseContext::foldConstConstructor(TIntermAggregate *aggrNode, const TType &type) { // TODO: Add support for folding array constructors bool canBeFolded = areAllChildConst(aggrNode) && !type.isArray(); aggrNode->setType(type); if (canBeFolded) { bool returnVal = false; TConstantUnion *unionArray = new TConstantUnion[type.getObjectSize()]; if (aggrNode->getSequence()->size() == 1) { returnVal = intermediate.parseConstTree(aggrNode->getLine(), aggrNode, unionArray, aggrNode->getOp(), type, true); } else { returnVal = intermediate.parseConstTree(aggrNode->getLine(), aggrNode, unionArray, aggrNode->getOp(), type); } if (returnVal) return 0; return intermediate.addConstantUnion(unionArray, type, aggrNode->getLine()); } return 0; } // // This function returns the tree representation for the vector field(s) being accessed from contant // vector. // If only one component of vector is accessed (v.x or v[0] where v is a contant vector), then a // contant node is returned, else an aggregate node is returned (for v.xy). The input to this // function could either // be the symbol node or it could be the intermediate tree representation of accessing fields in a // constant // structure or column of a constant matrix. // TIntermTyped *TParseContext::addConstVectorNode(TVectorFields &fields, TIntermTyped *node, const TSourceLoc &line) { TIntermTyped *typedNode; TIntermConstantUnion *tempConstantNode = node->getAsConstantUnion(); const TConstantUnion *unionArray; if (tempConstantNode) { unionArray = tempConstantNode->getUnionArrayPointer(); if (!unionArray) { return node; } } else { // The node has to be either a symbol node or an aggregate node or a tempConstant node, else, // its an error error(line, "Cannot offset into the vector", "Error"); recover(); return 0; } TConstantUnion *constArray = new TConstantUnion[fields.num]; for (int i = 0; i < fields.num; i++) { if (fields.offsets[i] >= node->getType().getNominalSize()) { std::stringstream extraInfoStream; extraInfoStream << "vector field selection out of range '" << fields.offsets[i] << "'"; std::string extraInfo = extraInfoStream.str(); error(line, "", "[", extraInfo.c_str()); recover(); fields.offsets[i] = 0; } constArray[i] = unionArray[fields.offsets[i]]; } typedNode = intermediate.addConstantUnion(constArray, node->getType(), line); return typedNode; } // // This function returns the column being accessed from a constant matrix. The values are retrieved // from the symbol table and parse-tree is built for a vector (each column of a matrix is a vector). // The // input to the function could either be a symbol node (m[0] where m is a constant matrix)that // represents // a constant matrix or it could be the tree representation of the constant matrix (s.m1[0] where s // is a constant structure) // TIntermTyped *TParseContext::addConstMatrixNode(int index, TIntermTyped *node, const TSourceLoc &line) { TIntermTyped *typedNode; TIntermConstantUnion *tempConstantNode = node->getAsConstantUnion(); if (index >= node->getType().getCols()) { std::stringstream extraInfoStream; extraInfoStream << "matrix field selection out of range '" << index << "'"; std::string extraInfo = extraInfoStream.str(); error(line, "", "[", extraInfo.c_str()); recover(); index = 0; } if (tempConstantNode) { TConstantUnion *unionArray = tempConstantNode->getUnionArrayPointer(); int size = tempConstantNode->getType().getCols(); typedNode = intermediate.addConstantUnion(&unionArray[size * index], tempConstantNode->getType(), line); } else { error(line, "Cannot offset into the matrix", "Error"); recover(); return 0; } return typedNode; } // // This function returns an element of an array accessed from a constant array. The values are // retrieved from the symbol table and parse-tree is built for the type of the element. The input // to the function could either be a symbol node (a[0] where a is a constant array)that represents a // constant array or it could be the tree representation of the constant array (s.a1[0] where s is a // constant structure) // TIntermTyped *TParseContext::addConstArrayNode(int index, TIntermTyped *node, const TSourceLoc &line) { TIntermTyped *typedNode; TIntermConstantUnion *tempConstantNode = node->getAsConstantUnion(); TType arrayElementType = node->getType(); arrayElementType.clearArrayness(); if (index >= node->getType().getArraySize()) { std::stringstream extraInfoStream; extraInfoStream << "array field selection out of range '" << index << "'"; std::string extraInfo = extraInfoStream.str(); error(line, "", "[", extraInfo.c_str()); recover(); index = 0; } if (tempConstantNode) { size_t arrayElementSize = arrayElementType.getObjectSize(); TConstantUnion *unionArray = tempConstantNode->getUnionArrayPointer(); typedNode = intermediate.addConstantUnion(&unionArray[arrayElementSize * index], tempConstantNode->getType(), line); } else { error(line, "Cannot offset into the array", "Error"); recover(); return 0; } return typedNode; } // // This function returns the value of a particular field inside a constant structure from the symbol // table. // If there is an embedded/nested struct, it appropriately calls addConstStructNested or // addConstStructFromAggr function and returns the parse-tree with the values of the embedded/nested // struct. // TIntermTyped *TParseContext::addConstStruct(const TString &identifier, TIntermTyped *node, const TSourceLoc &line) { const TFieldList &fields = node->getType().getStruct()->fields(); size_t instanceSize = 0; for (size_t index = 0; index < fields.size(); ++index) { if (fields[index]->name() == identifier) { break; } else { instanceSize += fields[index]->type()->getObjectSize(); } } TIntermTyped *typedNode; TIntermConstantUnion *tempConstantNode = node->getAsConstantUnion(); if (tempConstantNode) { TConstantUnion *constArray = tempConstantNode->getUnionArrayPointer(); // type will be changed in the calling function typedNode = intermediate.addConstantUnion(constArray + instanceSize, tempConstantNode->getType(), line); } else { error(line, "Cannot offset into the structure", "Error"); recover(); return 0; } return typedNode; } // // Interface/uniform blocks // TIntermAggregate *TParseContext::addInterfaceBlock(const TPublicType &typeQualifier, const TSourceLoc &nameLine, const TString &blockName, TFieldList *fieldList, const TString *instanceName, const TSourceLoc &instanceLine, TIntermTyped *arrayIndex, const TSourceLoc &arrayIndexLine) { if (reservedErrorCheck(nameLine, blockName)) recover(); if (typeQualifier.qualifier != EvqUniform) { error(typeQualifier.line, "invalid qualifier:", getQualifierString(typeQualifier.qualifier), "interface blocks must be uniform"); recover(); } TLayoutQualifier blockLayoutQualifier = typeQualifier.layoutQualifier; if (layoutLocationErrorCheck(typeQualifier.line, blockLayoutQualifier)) { recover(); } if (blockLayoutQualifier.matrixPacking == EmpUnspecified) { blockLayoutQualifier.matrixPacking = mDefaultMatrixPacking; } if (blockLayoutQualifier.blockStorage == EbsUnspecified) { blockLayoutQualifier.blockStorage = mDefaultBlockStorage; } TSymbol *blockNameSymbol = new TInterfaceBlockName(&blockName); if (!symbolTable.declare(blockNameSymbol)) { error(nameLine, "redefinition", blockName.c_str(), "interface block name"); recover(); } // check for sampler types and apply layout qualifiers for (size_t memberIndex = 0; memberIndex < fieldList->size(); ++memberIndex) { TField *field = (*fieldList)[memberIndex]; TType *fieldType = field->type(); if (IsSampler(fieldType->getBasicType())) { error(field->line(), "unsupported type", fieldType->getBasicString(), "sampler types are not allowed in interface blocks"); recover(); } const TQualifier qualifier = fieldType->getQualifier(); switch (qualifier) { case EvqGlobal: case EvqUniform: break; default: error(field->line(), "invalid qualifier on interface block member", getQualifierString(qualifier)); recover(); break; } // check layout qualifiers TLayoutQualifier fieldLayoutQualifier = fieldType->getLayoutQualifier(); if (layoutLocationErrorCheck(field->line(), fieldLayoutQualifier)) { recover(); } if (fieldLayoutQualifier.blockStorage != EbsUnspecified) { error(field->line(), "invalid layout qualifier:", getBlockStorageString(fieldLayoutQualifier.blockStorage), "cannot be used here"); recover(); } if (fieldLayoutQualifier.matrixPacking == EmpUnspecified) { fieldLayoutQualifier.matrixPacking = blockLayoutQualifier.matrixPacking; } else if (!fieldType->isMatrix() && fieldType->getBasicType() != EbtStruct) { warning(field->line(), "extraneous layout qualifier:", getMatrixPackingString(fieldLayoutQualifier.matrixPacking), "only has an effect on matrix types"); } fieldType->setLayoutQualifier(fieldLayoutQualifier); } // add array index int arraySize = 0; if (arrayIndex != NULL) { if (arraySizeErrorCheck(arrayIndexLine, arrayIndex, arraySize)) recover(); } TInterfaceBlock *interfaceBlock = new TInterfaceBlock(&blockName, fieldList, instanceName, arraySize, blockLayoutQualifier); TType interfaceBlockType(interfaceBlock, typeQualifier.qualifier, blockLayoutQualifier, arraySize); TString symbolName = ""; int symbolId = 0; if (!instanceName) { // define symbols for the members of the interface block for (size_t memberIndex = 0; memberIndex < fieldList->size(); ++memberIndex) { TField *field = (*fieldList)[memberIndex]; TType *fieldType = field->type(); // set parent pointer of the field variable fieldType->setInterfaceBlock(interfaceBlock); TVariable *fieldVariable = new TVariable(&field->name(), *fieldType); fieldVariable->setQualifier(typeQualifier.qualifier); if (!symbolTable.declare(fieldVariable)) { error(field->line(), "redefinition", field->name().c_str(), "interface block member name"); recover(); } } } else { if (reservedErrorCheck(instanceLine, *instanceName)) recover(); // add a symbol for this interface block TVariable *instanceTypeDef = new TVariable(instanceName, interfaceBlockType, false); instanceTypeDef->setQualifier(typeQualifier.qualifier); if (!symbolTable.declare(instanceTypeDef)) { error(instanceLine, "redefinition", instanceName->c_str(), "interface block instance name"); recover(); } symbolId = instanceTypeDef->getUniqueId(); symbolName = instanceTypeDef->getName(); } TIntermAggregate *aggregate = intermediate.makeAggregate( intermediate.addSymbol(symbolId, symbolName, interfaceBlockType, typeQualifier.line), nameLine); aggregate->setOp(EOpDeclaration); exitStructDeclaration(); return aggregate; } bool TParseContext::enterStructDeclaration(const TSourceLoc &line, const TString &identifier) { ++mStructNestingLevel; // Embedded structure definitions are not supported per GLSL ES spec. // They aren't allowed in GLSL either, but we need to detect this here // so we don't rely on the GLSL compiler to catch it. if (mStructNestingLevel > 1) { error(line, "", "Embedded struct definitions are not allowed"); return true; } return false; } void TParseContext::exitStructDeclaration() { --mStructNestingLevel; } namespace { const int kWebGLMaxStructNesting = 4; } // namespace bool TParseContext::structNestingErrorCheck(const TSourceLoc &line, const TField &field) { return false; } // // Parse an array index expression // TIntermTyped *TParseContext::addIndexExpression(TIntermTyped *baseExpression, const TSourceLoc &location, TIntermTyped *indexExpression) { TIntermTyped *indexedExpression = NULL; if (!baseExpression->isArray() && !baseExpression->isMatrix() && !baseExpression->isVector()) { if (baseExpression->getAsSymbolNode()) { error(location, " left of '[' is not of type array, matrix, or vector ", baseExpression->getAsSymbolNode()->getSymbol().c_str()); } else { error(location, " left of '[' is not of type array, matrix, or vector ", "expression"); } recover(); } TIntermConstantUnion *indexConstantUnion = indexExpression->getAsConstantUnion(); if (indexExpression->getQualifier() == EvqConst && indexConstantUnion) { int index = indexConstantUnion->getIConst(0); if (index < 0) { std::stringstream infoStream; infoStream << index; std::string info = infoStream.str(); error(location, "negative index", info.c_str()); recover(); index = 0; } if (baseExpression->getType().getQualifier() == EvqConst) { if (baseExpression->isArray()) { // constant folding for arrays indexedExpression = addConstArrayNode(index, baseExpression, location); } else if (baseExpression->isVector()) { // constant folding for vectors TVectorFields fields; fields.num = 1; fields.offsets[0] = index; // need to do it this way because v.xy sends fields integer array indexedExpression = addConstVectorNode(fields, baseExpression, location); } else if (baseExpression->isMatrix()) { // constant folding for matrices indexedExpression = addConstMatrixNode(index, baseExpression, location); } } else { int safeIndex = -1; if (baseExpression->isArray()) { if (index >= baseExpression->getType().getArraySize()) { std::stringstream extraInfoStream; extraInfoStream << "array index out of range '" << index << "'"; std::string extraInfo = extraInfoStream.str(); error(location, "", "[", extraInfo.c_str()); recover(); safeIndex = baseExpression->getType().getArraySize() - 1; } else if (baseExpression->getQualifier() == EvqFragData && index > 0 && !isExtensionEnabled("GL_EXT_draw_buffers")) { error(location, "", "[", "array indexes for gl_FragData must be zero when GL_EXT_draw_buffers is " "disabled"); recover(); safeIndex = 0; } } else if ((baseExpression->isVector() || baseExpression->isMatrix()) && baseExpression->getType().getNominalSize() <= index) { std::stringstream extraInfoStream; extraInfoStream << "field selection out of range '" << index << "'"; std::string extraInfo = extraInfoStream.str(); error(location, "", "[", extraInfo.c_str()); recover(); safeIndex = baseExpression->getType().getNominalSize() - 1; } // Don't modify the data of the previous constant union, because it can point // to builtins, like gl_MaxDrawBuffers. Instead use a new sanitized object. if (safeIndex != -1) { TConstantUnion *safeConstantUnion = new TConstantUnion(); safeConstantUnion->setIConst(safeIndex); indexConstantUnion->replaceConstantUnion(safeConstantUnion); } indexedExpression = intermediate.addIndex(EOpIndexDirect, baseExpression, indexExpression, location); } } else { if (baseExpression->isInterfaceBlock()) { error( location, "", "[", "array indexes for interface blocks arrays must be constant integral expressions"); recover(); } else if (baseExpression->getQualifier() == EvqFragmentOut) { error(location, "", "[", "array indexes for fragment outputs must be constant integral expressions"); recover(); } indexedExpression = intermediate.addIndex(EOpIndexIndirect, baseExpression, indexExpression, location); } if (indexedExpression == 0) { TConstantUnion *unionArray = new TConstantUnion[1]; unionArray->setFConst(0.0f); indexedExpression = intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpHigh, EvqConst), location); } else if (baseExpression->isArray()) { const TType &baseType = baseExpression->getType(); if (baseType.getStruct()) { TType copyOfType(baseType.getStruct()); indexedExpression->setType(copyOfType); } else if (baseType.isInterfaceBlock()) { TType copyOfType(baseType.getInterfaceBlock(), baseType.getQualifier(), baseType.getLayoutQualifier(), 0); indexedExpression->setType(copyOfType); } else { indexedExpression->setType( TType(baseExpression->getBasicType(), baseExpression->getPrecision(), EvqTemporary, static_cast(baseExpression->getNominalSize()), static_cast(baseExpression->getSecondarySize()))); } if (baseExpression->getType().getQualifier() == EvqConst) { indexedExpression->getTypePointer()->setQualifier(EvqConst); } } else if (baseExpression->isMatrix()) { TQualifier qualifier = baseExpression->getType().getQualifier() == EvqConst ? EvqConst : EvqTemporary; indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision(), qualifier, static_cast(baseExpression->getRows()))); } else if (baseExpression->isVector()) { TQualifier qualifier = baseExpression->getType().getQualifier() == EvqConst ? EvqConst : EvqTemporary; indexedExpression->setType( TType(baseExpression->getBasicType(), baseExpression->getPrecision(), qualifier)); } else { indexedExpression->setType(baseExpression->getType()); } return indexedExpression; } TIntermTyped *TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpression, const TSourceLoc &dotLocation, const TString &fieldString, const TSourceLoc &fieldLocation) { TIntermTyped *indexedExpression = NULL; if (baseExpression->isArray()) { error(fieldLocation, "cannot apply dot operator to an array", "."); recover(); } if (baseExpression->isVector()) { TVectorFields fields; if (!parseVectorFields(fieldString, baseExpression->getNominalSize(), fields, fieldLocation)) { fields.num = 1; fields.offsets[0] = 0; recover(); } if (baseExpression->getType().getQualifier() == EvqConst) { // constant folding for vector fields indexedExpression = addConstVectorNode(fields, baseExpression, fieldLocation); if (indexedExpression == 0) { recover(); indexedExpression = baseExpression; } else { indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision(), EvqConst, (unsigned char)(fieldString).size())); } } else { TString vectorString = fieldString; TIntermTyped *index = intermediate.addSwizzle(fields, fieldLocation); indexedExpression = intermediate.addIndex(EOpVectorSwizzle, baseExpression, index, dotLocation); indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision(), EvqTemporary, (unsigned char)vectorString.size())); } } else if (baseExpression->getBasicType() == EbtStruct) { bool fieldFound = false; const TFieldList &fields = baseExpression->getType().getStruct()->fields(); if (fields.empty()) { error(dotLocation, "structure has no fields", "Internal Error"); recover(); indexedExpression = baseExpression; } else { unsigned int i; for (i = 0; i < fields.size(); ++i) { if (fields[i]->name() == fieldString) { fieldFound = true; break; } } if (fieldFound) { if (baseExpression->getType().getQualifier() == EvqConst) { indexedExpression = addConstStruct(fieldString, baseExpression, dotLocation); if (indexedExpression == 0) { recover(); indexedExpression = baseExpression; } else { indexedExpression->setType(*fields[i]->type()); // change the qualifier of the return type, not of the structure field // as the structure definition is shared between various structures. indexedExpression->getTypePointer()->setQualifier(EvqConst); } } else { TConstantUnion *unionArray = new TConstantUnion[1]; unionArray->setIConst(i); TIntermTyped *index = intermediate.addConstantUnion( unionArray, *fields[i]->type(), fieldLocation); indexedExpression = intermediate.addIndex(EOpIndexDirectStruct, baseExpression, index, dotLocation); indexedExpression->setType(*fields[i]->type()); } } else { error(dotLocation, " no such field in structure", fieldString.c_str()); recover(); indexedExpression = baseExpression; } } } else if (baseExpression->isInterfaceBlock()) { bool fieldFound = false; const TFieldList &fields = baseExpression->getType().getInterfaceBlock()->fields(); if (fields.empty()) { error(dotLocation, "interface block has no fields", "Internal Error"); recover(); indexedExpression = baseExpression; } else { unsigned int i; for (i = 0; i < fields.size(); ++i) { if (fields[i]->name() == fieldString) { fieldFound = true; break; } } if (fieldFound) { TConstantUnion *unionArray = new TConstantUnion[1]; unionArray->setIConst(i); TIntermTyped *index = intermediate.addConstantUnion(unionArray, *fields[i]->type(), fieldLocation); indexedExpression = intermediate.addIndex(EOpIndexDirectInterfaceBlock, baseExpression, index, dotLocation); indexedExpression->setType(*fields[i]->type()); } else { error(dotLocation, " no such field in interface block", fieldString.c_str()); recover(); indexedExpression = baseExpression; } } } else { if (mShaderVersion < 300) { error(dotLocation, " field selection requires structure or vector on left hand side", fieldString.c_str()); } else { error(dotLocation, " field selection requires structure, vector, or interface block on left hand " "side", fieldString.c_str()); } recover(); indexedExpression = baseExpression; } return indexedExpression; } TLayoutQualifier TParseContext::parseLayoutQualifier(const TString &qualifierType, const TSourceLoc &qualifierTypeLine) { TLayoutQualifier qualifier; qualifier.location = -1; qualifier.matrixPacking = EmpUnspecified; qualifier.blockStorage = EbsUnspecified; if (qualifierType == "shared") { qualifier.blockStorage = EbsShared; } else if (qualifierType == "packed") { qualifier.blockStorage = EbsPacked; } else if (qualifierType == "std140") { qualifier.blockStorage = EbsStd140; } else if (qualifierType == "row_major") { qualifier.matrixPacking = EmpRowMajor; } else if (qualifierType == "column_major") { qualifier.matrixPacking = EmpColumnMajor; } else if (qualifierType == "location") { error(qualifierTypeLine, "invalid layout qualifier", qualifierType.c_str(), "location requires an argument"); recover(); } else { error(qualifierTypeLine, "invalid layout qualifier", qualifierType.c_str()); recover(); } return qualifier; } TLayoutQualifier TParseContext::parseLayoutQualifier(const TString &qualifierType, const TSourceLoc &qualifierTypeLine, const TString &intValueString, int intValue, const TSourceLoc &intValueLine) { TLayoutQualifier qualifier; qualifier.location = -1; qualifier.matrixPacking = EmpUnspecified; qualifier.blockStorage = EbsUnspecified; if (qualifierType != "location") { error(qualifierTypeLine, "invalid layout qualifier", qualifierType.c_str(), "only location may have arguments"); recover(); } else { // must check that location is non-negative if (intValue < 0) { error(intValueLine, "out of range:", intValueString.c_str(), "location must be non-negative"); recover(); } else { qualifier.location = intValue; } } return qualifier; } TLayoutQualifier TParseContext::joinLayoutQualifiers(TLayoutQualifier leftQualifier, TLayoutQualifier rightQualifier) { TLayoutQualifier joinedQualifier = leftQualifier; if (rightQualifier.location != -1) { joinedQualifier.location = rightQualifier.location; } if (rightQualifier.matrixPacking != EmpUnspecified) { joinedQualifier.matrixPacking = rightQualifier.matrixPacking; } if (rightQualifier.blockStorage != EbsUnspecified) { joinedQualifier.blockStorage = rightQualifier.blockStorage; } return joinedQualifier; } TPublicType TParseContext::joinInterpolationQualifiers(const TSourceLoc &interpolationLoc, TQualifier interpolationQualifier, const TSourceLoc &storageLoc, TQualifier storageQualifier) { TQualifier mergedQualifier = EvqSmoothIn; if (storageQualifier == EvqFragmentIn) { if (interpolationQualifier == EvqSmooth) mergedQualifier = EvqSmoothIn; else if (interpolationQualifier == EvqFlat) mergedQualifier = EvqFlatIn; else UNREACHABLE(); } else if (storageQualifier == EvqCentroidIn) { if (interpolationQualifier == EvqSmooth) mergedQualifier = EvqCentroidIn; else if (interpolationQualifier == EvqFlat) mergedQualifier = EvqFlatIn; else UNREACHABLE(); } else if (storageQualifier == EvqVertexOut) { if (interpolationQualifier == EvqSmooth) mergedQualifier = EvqSmoothOut; else if (interpolationQualifier == EvqFlat) mergedQualifier = EvqFlatOut; else UNREACHABLE(); } else if (storageQualifier == EvqCentroidOut) { if (interpolationQualifier == EvqSmooth) mergedQualifier = EvqCentroidOut; else if (interpolationQualifier == EvqFlat) mergedQualifier = EvqFlatOut; else UNREACHABLE(); } else { error(interpolationLoc, "interpolation qualifier requires a fragment 'in' or vertex 'out' storage qualifier", getInterpolationString(interpolationQualifier)); recover(); mergedQualifier = storageQualifier; } TPublicType type; type.setBasic(EbtVoid, mergedQualifier, storageLoc); return type; } TFieldList *TParseContext::addStructDeclaratorList(const TPublicType &typeSpecifier, TFieldList *fieldList) { if (voidErrorCheck(typeSpecifier.line, (*fieldList)[0]->name(), typeSpecifier.type)) { recover(); } for (unsigned int i = 0; i < fieldList->size(); ++i) { // // Careful not to replace already known aspects of type, like array-ness // TType *type = (*fieldList)[i]->type(); type->setBasicType(typeSpecifier.type); type->setPrimarySize(typeSpecifier.primarySize); type->setSecondarySize(typeSpecifier.secondarySize); type->setPrecision(typeSpecifier.precision); type->setQualifier(typeSpecifier.qualifier); type->setLayoutQualifier(typeSpecifier.layoutQualifier); // don't allow arrays of arrays if (type->isArray()) { if (arrayTypeErrorCheck(typeSpecifier.line, typeSpecifier)) recover(); } if (typeSpecifier.array) type->setArraySize(typeSpecifier.arraySize); if (typeSpecifier.userDef) { type->setStruct(typeSpecifier.userDef->getStruct()); } if (structNestingErrorCheck(typeSpecifier.line, *(*fieldList)[i])) { recover(); } } return fieldList; } TPublicType TParseContext::addStructure(const TSourceLoc &structLine, const TSourceLoc &nameLine, const TString *structName, TFieldList *fieldList) { TStructure *structure = new TStructure(structName, fieldList); TType *structureType = new TType(structure); // Store a bool in the struct if we're at global scope, to allow us to // skip the local struct scoping workaround in HLSL. structure->setUniqueId(TSymbolTable::nextUniqueId()); structure->setAtGlobalScope(symbolTable.atGlobalLevel()); if (!structName->empty()) { if (reservedErrorCheck(nameLine, *structName)) { recover(); } TVariable *userTypeDef = new TVariable(structName, *structureType, true); if (!symbolTable.declare(userTypeDef)) { error(nameLine, "redefinition", structName->c_str(), "struct"); recover(); } } // ensure we do not specify any storage qualifiers on the struct members for (unsigned int typeListIndex = 0; typeListIndex < fieldList->size(); typeListIndex++) { const TField &field = *(*fieldList)[typeListIndex]; const TQualifier qualifier = field.type()->getQualifier(); switch (qualifier) { case EvqGlobal: case EvqTemporary: break; default: error(field.line(), "invalid qualifier on struct member", getQualifierString(qualifier)); recover(); break; } } TPublicType publicType; publicType.setBasic(EbtStruct, EvqTemporary, structLine); publicType.userDef = structureType; exitStructDeclaration(); return publicType; } TIntermSwitch *TParseContext::addSwitch(TIntermTyped *init, TIntermAggregate *statementList, const TSourceLoc &loc) { TBasicType switchType = init->getBasicType(); if ((switchType != EbtInt && switchType != EbtUInt) || init->isMatrix() || init->isArray() || init->isVector()) { error(init->getLine(), "init-expression in a switch statement must be a scalar integer", "switch"); recover(); return nullptr; } if (statementList) { if (!ValidateSwitch::validate(switchType, this, statementList, loc)) { recover(); return nullptr; } } TIntermSwitch *node = intermediate.addSwitch(init, statementList, loc); if (node == nullptr) { error(loc, "erroneous switch statement", "switch"); recover(); return nullptr; } return node; } TIntermCase *TParseContext::addCase(TIntermTyped *condition, const TSourceLoc &loc) { if (mSwitchNestingLevel == 0) { error(loc, "case labels need to be inside switch statements", "case"); recover(); return nullptr; } if (condition == nullptr) { error(loc, "case label must have a condition", "case"); recover(); return nullptr; } if ((condition->getBasicType() != EbtInt && condition->getBasicType() != EbtUInt) || condition->isMatrix() || condition->isArray() || condition->isVector()) { error(condition->getLine(), "case label must be a scalar integer", "case"); recover(); } TIntermConstantUnion *conditionConst = condition->getAsConstantUnion(); if (conditionConst == nullptr) { error(condition->getLine(), "case label must be constant", "case"); recover(); } TIntermCase *node = intermediate.addCase(condition, loc); if (node == nullptr) { error(loc, "erroneous case statement", "case"); recover(); return nullptr; } return node; } TIntermCase *TParseContext::addDefault(const TSourceLoc &loc) { if (mSwitchNestingLevel == 0) { error(loc, "default labels need to be inside switch statements", "default"); recover(); return nullptr; } TIntermCase *node = intermediate.addCase(nullptr, loc); if (node == nullptr) { error(loc, "erroneous default statement", "default"); recover(); return nullptr; } return node; } TIntermTyped *TParseContext::createUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc, const TType *funcReturnType) { if (child == nullptr) { return nullptr; } switch (op) { case EOpLogicalNot: if (child->getBasicType() != EbtBool || child->isMatrix() || child->isArray() || child->isVector()) { return nullptr; } break; case EOpBitwiseNot: if ((child->getBasicType() != EbtInt && child->getBasicType() != EbtUInt) || child->isMatrix() || child->isArray()) { return nullptr; } break; case EOpPostIncrement: case EOpPreIncrement: case EOpPostDecrement: case EOpPreDecrement: case EOpNegative: case EOpPositive: if (child->getBasicType() == EbtStruct || child->getBasicType() == EbtBool || child->isArray()) { return nullptr; } // Operators for built-ins are already type checked against their prototype. default: break; } return intermediate.addUnaryMath(op, child, loc, funcReturnType); } TIntermTyped *TParseContext::addUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc) { TIntermTyped *node = createUnaryMath(op, child, loc, nullptr); if (node == nullptr) { unaryOpError(loc, GetOperatorString(op), child->getCompleteString()); recover(); return child; } return node; } TIntermTyped *TParseContext::addUnaryMathLValue(TOperator op, TIntermTyped *child, const TSourceLoc &loc) { if (lValueErrorCheck(loc, GetOperatorString(op), child)) recover(); return addUnaryMath(op, child, loc); } bool TParseContext::binaryOpCommonCheck(TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc) { if (left->isArray() || right->isArray()) { if (mShaderVersion < 300) { error(loc, "Invalid operation for arrays", GetOperatorString(op)); return false; } if (left->isArray() != right->isArray()) { error(loc, "array / non-array mismatch", GetOperatorString(op)); return false; } switch (op) { case EOpEqual: case EOpNotEqual: case EOpAssign: case EOpInitialize: break; default: error(loc, "Invalid operation for arrays", GetOperatorString(op)); return false; } // At this point, size of implicitly sized arrays should be resolved. if (left->getArraySize() != right->getArraySize()) { error(loc, "array size mismatch", GetOperatorString(op)); return false; } } // Check ops which require integer / ivec parameters bool isBitShift = false; switch (op) { case EOpBitShiftLeft: case EOpBitShiftRight: case EOpBitShiftLeftAssign: case EOpBitShiftRightAssign: // Unsigned can be bit-shifted by signed and vice versa, but we need to // check that the basic type is an integer type. isBitShift = true; if (!IsInteger(left->getBasicType()) || !IsInteger(right->getBasicType())) { return false; } break; case EOpBitwiseAnd: case EOpBitwiseXor: case EOpBitwiseOr: case EOpBitwiseAndAssign: case EOpBitwiseXorAssign: case EOpBitwiseOrAssign: // It is enough to check the type of only one operand, since later it // is checked that the operand types match. if (!IsInteger(left->getBasicType())) { return false; } break; default: break; } // GLSL ES 1.00 and 3.00 do not support implicit type casting. // So the basic type should usually match. if (!isBitShift && left->getBasicType() != right->getBasicType()) { return false; } // Check that type sizes match exactly on ops that require that. // Also check restrictions for structs that contain arrays or samplers. switch (op) { case EOpAssign: case EOpInitialize: case EOpEqual: case EOpNotEqual: // ESSL 1.00 sections 5.7, 5.8, 5.9 if (mShaderVersion < 300 && left->getType().isStructureContainingArrays()) { error(loc, "undefined operation for structs containing arrays", GetOperatorString(op)); return false; } // Samplers as l-values are disallowed also in ESSL 3.00, see section 4.1.7, // we interpret the spec so that this extends to structs containing samplers, // similarly to ESSL 1.00 spec. if ((mShaderVersion < 300 || op == EOpAssign || op == EOpInitialize) && left->getType().isStructureContainingSamplers()) { error(loc, "undefined operation for structs containing samplers", GetOperatorString(op)); return false; } case EOpLessThan: case EOpGreaterThan: case EOpLessThanEqual: case EOpGreaterThanEqual: if ((left->getNominalSize() != right->getNominalSize()) || (left->getSecondarySize() != right->getSecondarySize())) { return false; } default: break; } return true; } TIntermTyped *TParseContext::addBinaryMathInternal(TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc) { if (!binaryOpCommonCheck(op, left, right, loc)) return nullptr; switch (op) { case EOpEqual: case EOpNotEqual: break; case EOpLessThan: case EOpGreaterThan: case EOpLessThanEqual: case EOpGreaterThanEqual: ASSERT(!left->isArray() && !right->isArray()); if (left->isMatrix() || left->isVector() || left->getBasicType() == EbtStruct) { return nullptr; } break; case EOpLogicalOr: case EOpLogicalXor: case EOpLogicalAnd: ASSERT(!left->isArray() && !right->isArray()); if (left->getBasicType() != EbtBool || left->isMatrix() || left->isVector()) { return nullptr; } break; case EOpAdd: case EOpSub: case EOpDiv: case EOpMul: ASSERT(!left->isArray() && !right->isArray()); if (left->getBasicType() == EbtStruct || left->getBasicType() == EbtBool) { return nullptr; } break; case EOpIMod: ASSERT(!left->isArray() && !right->isArray()); // Note that this is only for the % operator, not for mod() if (left->getBasicType() == EbtStruct || left->getBasicType() == EbtBool || left->getBasicType() == EbtFloat) { return nullptr; } break; // Note that for bitwise ops, type checking is done in promote() to // share code between ops and compound assignment default: break; } return intermediate.addBinaryMath(op, left, right, loc); } TIntermTyped *TParseContext::addBinaryMath(TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc) { TIntermTyped *node = addBinaryMathInternal(op, left, right, loc); if (node == 0) { binaryOpError(loc, GetOperatorString(op), left->getCompleteString(), right->getCompleteString()); recover(); return left; } return node; } TIntermTyped *TParseContext::addBinaryMathBooleanResult(TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc) { TIntermTyped *node = addBinaryMathInternal(op, left, right, loc); if (node == 0) { binaryOpError(loc, GetOperatorString(op), left->getCompleteString(), right->getCompleteString()); recover(); TConstantUnion *unionArray = new TConstantUnion[1]; unionArray->setBConst(false); return intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), loc); } return node; } TIntermTyped *TParseContext::createAssign(TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc) { if (binaryOpCommonCheck(op, left, right, loc)) { return intermediate.addAssign(op, left, right, loc); } return nullptr; } TIntermTyped *TParseContext::addAssign(TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc) { TIntermTyped *node = createAssign(op, left, right, loc); if (node == nullptr) { assignError(loc, "assign", left->getCompleteString(), right->getCompleteString()); recover(); return left; } return node; } TIntermBranch *TParseContext::addBranch(TOperator op, const TSourceLoc &loc) { switch (op) { case EOpContinue: if (mLoopNestingLevel <= 0) { error(loc, "continue statement only allowed in loops", ""); recover(); } break; case EOpBreak: if (mLoopNestingLevel <= 0 && mSwitchNestingLevel <= 0) { error(loc, "break statement only allowed in loops and switch statements", ""); recover(); } break; case EOpReturn: if (mCurrentFunctionType->getBasicType() != EbtVoid) { error(loc, "non-void function must return a value", "return"); recover(); } break; default: // No checks for discard break; } return intermediate.addBranch(op, loc); } TIntermBranch *TParseContext::addBranch(TOperator op, TIntermTyped *returnValue, const TSourceLoc &loc) { ASSERT(op == EOpReturn); mFunctionReturnsValue = true; if (mCurrentFunctionType->getBasicType() == EbtVoid) { error(loc, "void function cannot return a value", "return"); recover(); } else if (*mCurrentFunctionType != returnValue->getType()) { error(loc, "function return is not matching type:", "return"); recover(); } return intermediate.addBranch(op, returnValue, loc); } TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermNode *paramNode, TIntermNode *thisNode, const TSourceLoc &loc, bool *fatalError) { *fatalError = false; TOperator op = fnCall->getBuiltInOp(); TIntermTyped *callNode = nullptr; if (thisNode != nullptr) { TConstantUnion *unionArray = new TConstantUnion[1]; int arraySize = 0; TIntermTyped *typedThis = thisNode->getAsTyped(); if (fnCall->getName() != "length") { error(loc, "invalid method", fnCall->getName().c_str()); recover(); } else if (paramNode != nullptr) { error(loc, "method takes no parameters", "length"); recover(); } else if (typedThis == nullptr || !typedThis->isArray()) { error(loc, "length can only be called on arrays", "length"); recover(); } else { arraySize = typedThis->getArraySize(); if (typedThis->getAsSymbolNode() == nullptr) { // This code path can be hit with expressions like these: // (a = b).length() // (func()).length() // (int[3](0, 1, 2)).length() // ESSL 3.00 section 5.9 defines expressions so that this is not actually a valid // expression. // It allows "An array name with the length method applied" in contrast to GLSL 4.4 // spec section 5.9 which allows "An array, vector or matrix expression with the // length method applied". error(loc, "length can only be called on array names, not on array expressions", "length"); recover(); } } unionArray->setIConst(arraySize); callNode = intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), loc); } else if (op != EOpNull) { // // Then this should be a constructor. // Don't go through the symbol table for constructors. // Their parameters will be verified algorithmically. // TType type(EbtVoid, EbpUndefined); // use this to get the type back if (!constructorErrorCheck(loc, paramNode, *fnCall, op, &type)) { // // It's a constructor, of type 'type'. // callNode = addConstructor(paramNode, &type, op, fnCall, loc); } if (callNode == nullptr) { recover(); callNode = intermediate.setAggregateOperator(nullptr, op, loc); } callNode->setType(type); } else { // // Not a constructor. Find it in the symbol table. // const TFunction *fnCandidate; bool builtIn; fnCandidate = findFunction(loc, fnCall, mShaderVersion, &builtIn); if (fnCandidate) { // // A declared function. // if (builtIn && !fnCandidate->getExtension().empty() && extensionErrorCheck(loc, fnCandidate->getExtension())) { recover(); } op = fnCandidate->getBuiltInOp(); if (builtIn && op != EOpNull) { // // A function call mapped to a built-in operation. // if (fnCandidate->getParamCount() == 1) { // // Treat it like a built-in unary operator. // callNode = createUnaryMath(op, paramNode->getAsTyped(), loc, &fnCandidate->getReturnType()); if (callNode == nullptr) { std::stringstream extraInfoStream; extraInfoStream << "built in unary operator function. Type: " << static_cast(paramNode)->getCompleteString(); std::string extraInfo = extraInfoStream.str(); error(paramNode->getLine(), " wrong operand type", "Internal Error", extraInfo.c_str()); *fatalError = true; return nullptr; } } else { TIntermAggregate *aggregate = intermediate.setAggregateOperator(paramNode, op, loc); aggregate->setType(fnCandidate->getReturnType()); aggregate->setPrecisionFromChildren(); // Some built-in functions have out parameters too. functionCallLValueErrorCheck(fnCandidate, aggregate); // See if we can constant fold a built-in. TIntermTyped *foldedNode = intermediate.foldAggregateBuiltIn(aggregate); if (foldedNode) { callNode = foldedNode; } else { callNode = aggregate; } } } else { // This is a real function call TIntermAggregate *aggregate = intermediate.setAggregateOperator(paramNode, EOpFunctionCall, loc); aggregate->setType(fnCandidate->getReturnType()); // this is how we know whether the given function is a builtIn function or a user // defined function // if builtIn == false, it's a userDefined -> could be an overloaded // builtIn function also // if builtIn == true, it's definitely a builtIn function with EOpNull if (!builtIn) aggregate->setUserDefined(); aggregate->setName(fnCandidate->getMangledName()); aggregate->setFunctionId(fnCandidate->getUniqueId()); // This needs to happen after the name is set if (builtIn) aggregate->setBuiltInFunctionPrecision(); callNode = aggregate; functionCallLValueErrorCheck(fnCandidate, aggregate); } } else { // error message was put out by findFunction() // Put on a dummy node for error recovery TConstantUnion *unionArray = new TConstantUnion[1]; unionArray->setFConst(0.0f); callNode = intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), loc); recover(); } } return callNode; } TIntermTyped *TParseContext::addTernarySelection(TIntermTyped *cond, TIntermTyped *trueBlock, TIntermTyped *falseBlock, const TSourceLoc &loc) { if (boolErrorCheck(loc, cond)) recover(); if (trueBlock->getType() != falseBlock->getType()) { binaryOpError(loc, ":", trueBlock->getCompleteString(), falseBlock->getCompleteString()); recover(); return falseBlock; } // ESSL1 sections 5.2 and 5.7: // ESSL3 section 5.7: // Ternary operator is not among the operators allowed for structures/arrays. if (trueBlock->isArray() || trueBlock->getBasicType() == EbtStruct) { error(loc, "ternary operator is not allowed for structures or arrays", ":"); recover(); return falseBlock; } return intermediate.addSelection(cond, trueBlock, falseBlock, loc); } // // Parse an array of strings using yyparse. // // Returns 0 for success. // int PaParseStrings(size_t count, const char *const string[], const int length[], TParseContext *context) { if ((count == 0) || (string == NULL)) return 1; if (glslang_initialize(context)) return 1; int error = glslang_scan(count, string, length, context); if (!error) error = glslang_parse(context); glslang_finalize(context); return (error == 0) && (context->numErrors() == 0) ? 0 : 1; } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/ParseContext.h000066400000000000000000000467271321746453100275340ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_PARSECONTEXT_H_ #define COMPILER_TRANSLATOR_PARSECONTEXT_H_ #include "compiler/translator/Compiler.h" #include "compiler/translator/Diagnostics.h" #include "compiler/translator/DirectiveHandler.h" #include "compiler/translator/Intermediate.h" #include "compiler/translator/SymbolTable.h" #include "compiler/preprocessor/Preprocessor.h" struct TMatrixFields { bool wholeRow; bool wholeCol; int row; int col; }; // // The following are extra variables needed during parsing, grouped together so // they can be passed to the parser without needing a global. // class TParseContext : angle::NonCopyable { public: TParseContext(TSymbolTable &symt, TExtensionBehavior &ext, TIntermediate &interm, sh::GLenum type, ShShaderSpec spec, int options, bool checksPrecErrors, TInfoSink &is, bool debugShaderPrecisionSupported) : intermediate(interm), symbolTable(symt), mDeferredSingleDeclarationErrorCheck(false), mShaderType(type), mShaderSpec(spec), mShaderVersion(100), mTreeRoot(nullptr), mLoopNestingLevel(0), mStructNestingLevel(0), mSwitchNestingLevel(0), mCurrentFunctionType(nullptr), mFunctionReturnsValue(false), mChecksPrecisionErrors(checksPrecErrors), mFragmentPrecisionHigh(false), mDefaultMatrixPacking(EmpColumnMajor), mDefaultBlockStorage(EbsShared), mDiagnostics(is), mDirectiveHandler(ext, mDiagnostics, mShaderVersion, debugShaderPrecisionSupported), mPreprocessor(&mDiagnostics, &mDirectiveHandler), mScanner(nullptr), mUsesFragData(false), mUsesFragColor(false), mUsesSecondaryOutputs(false) { } const pp::Preprocessor &getPreprocessor() const { return mPreprocessor; } pp::Preprocessor &getPreprocessor() { return mPreprocessor; } void *getScanner() const { return mScanner; } void setScanner(void *scanner) { mScanner = scanner; } int getShaderVersion() const { return mShaderVersion; } sh::GLenum getShaderType() const { return mShaderType; } ShShaderSpec getShaderSpec() const { return mShaderSpec; } int numErrors() const { return mDiagnostics.numErrors(); } TInfoSink &infoSink() { return mDiagnostics.infoSink(); } void error(const TSourceLoc &loc, const char *reason, const char *token, const char *extraInfo=""); void warning(const TSourceLoc &loc, const char *reason, const char *token, const char *extraInfo=""); void recover(); TIntermNode *getTreeRoot() const { return mTreeRoot; } void setTreeRoot(TIntermNode *treeRoot) { mTreeRoot = treeRoot; } bool getFragmentPrecisionHigh() const { return mFragmentPrecisionHigh; } void setFragmentPrecisionHigh(bool fragmentPrecisionHigh) { mFragmentPrecisionHigh = fragmentPrecisionHigh; } bool getFunctionReturnsValue() const { return mFunctionReturnsValue; } void setFunctionReturnsValue(bool functionReturnsValue) { mFunctionReturnsValue = functionReturnsValue; } void setLoopNestingLevel(int loopNestintLevel) { mLoopNestingLevel = loopNestintLevel; } const TType *getCurrentFunctionType() const { return mCurrentFunctionType; } void setCurrentFunctionType(const TType *currentFunctionType) { mCurrentFunctionType = currentFunctionType; } void incrLoopNestingLevel() { ++mLoopNestingLevel; } void decrLoopNestingLevel() { --mLoopNestingLevel; } void incrSwitchNestingLevel() { ++mSwitchNestingLevel; } void decrSwitchNestingLevel() { --mSwitchNestingLevel; } // This method is guaranteed to succeed, even if no variable with 'name' exists. const TVariable *getNamedVariable(const TSourceLoc &location, const TString *name, const TSymbol *symbol); bool parseVectorFields(const TString&, int vecSize, TVectorFields&, const TSourceLoc &line); bool reservedErrorCheck(const TSourceLoc &line, const TString &identifier); void assignError(const TSourceLoc &line, const char *op, TString left, TString right); void unaryOpError(const TSourceLoc &line, const char *op, TString operand); void binaryOpError(const TSourceLoc &line, const char *op, TString left, TString right); bool precisionErrorCheck(const TSourceLoc &line, TPrecision precision, TBasicType type); bool lValueErrorCheck(const TSourceLoc &line, const char *op, TIntermTyped*); bool constErrorCheck(TIntermTyped *node); bool integerErrorCheck(TIntermTyped *node, const char *token); bool globalErrorCheck(const TSourceLoc &line, bool global, const char *token); bool constructorErrorCheck(const TSourceLoc &line, TIntermNode*, TFunction&, TOperator, TType*); bool arraySizeErrorCheck(const TSourceLoc &line, TIntermTyped *expr, int &size); bool arrayQualifierErrorCheck(const TSourceLoc &line, const TPublicType &type); bool arrayTypeErrorCheck(const TSourceLoc &line, const TPublicType &type); bool voidErrorCheck(const TSourceLoc &line, const TString &identifier, const TBasicType &type); bool boolErrorCheck(const TSourceLoc&, const TIntermTyped*); bool boolErrorCheck(const TSourceLoc&, const TPublicType&); bool samplerErrorCheck(const TSourceLoc &line, const TPublicType &pType, const char *reason); bool locationDeclaratorListCheck(const TSourceLoc &line, const TPublicType &pType); bool parameterSamplerErrorCheck(const TSourceLoc &line, TQualifier qualifier, const TType &type); bool paramErrorCheck(const TSourceLoc &line, TQualifier qualifier, TQualifier paramQualifier, TType *type); bool extensionErrorCheck(const TSourceLoc &line, const TString&); bool singleDeclarationErrorCheck(const TPublicType &publicType, const TSourceLoc &identifierLocation); bool layoutLocationErrorCheck(const TSourceLoc &location, const TLayoutQualifier &layoutQualifier); bool functionCallLValueErrorCheck(const TFunction *fnCandidate, TIntermAggregate *); void es3InvariantErrorCheck(const TQualifier qualifier, const TSourceLoc &invariantLocation); void es3InputOutputTypeCheck(const TQualifier qualifier, const TPublicType &type, const TSourceLoc &qualifierLocation); const TPragma &pragma() const { return mDirectiveHandler.pragma(); } const TExtensionBehavior &extensionBehavior() const { return mDirectiveHandler.extensionBehavior(); } bool supportsExtension(const char *extension); bool isExtensionEnabled(const char *extension) const; void handleExtensionDirective(const TSourceLoc &loc, const char *extName, const char *behavior); void handlePragmaDirective(const TSourceLoc &loc, const char *name, const char *value, bool stdgl); bool containsSampler(const TType &type); bool areAllChildConst(TIntermAggregate *aggrNode); const TFunction* findFunction( const TSourceLoc &line, TFunction *pfnCall, int inputShaderVersion, bool *builtIn = 0); bool executeInitializer(const TSourceLoc &line, const TString &identifier, const TPublicType &pType, TIntermTyped *initializer, TIntermNode **intermNode); TPublicType addFullySpecifiedType(TQualifier qualifier, bool invariant, TLayoutQualifier layoutQualifier, const TPublicType &typeSpecifier); TIntermAggregate *parseSingleDeclaration(TPublicType &publicType, const TSourceLoc &identifierOrTypeLocation, const TString &identifier); TIntermAggregate *parseSingleArrayDeclaration(TPublicType &publicType, const TSourceLoc &identifierLocation, const TString &identifier, const TSourceLoc &indexLocation, TIntermTyped *indexExpression); TIntermAggregate *parseSingleInitDeclaration(const TPublicType &publicType, const TSourceLoc &identifierLocation, const TString &identifier, const TSourceLoc &initLocation, TIntermTyped *initializer); // Parse a declaration like "type a[n] = initializer" // Note that this does not apply to declarations like "type[n] a = initializer" TIntermAggregate *parseSingleArrayInitDeclaration(TPublicType &publicType, const TSourceLoc &identifierLocation, const TString &identifier, const TSourceLoc &indexLocation, TIntermTyped *indexExpression, const TSourceLoc &initLocation, TIntermTyped *initializer); TIntermAggregate *parseInvariantDeclaration(const TSourceLoc &invariantLoc, const TSourceLoc &identifierLoc, const TString *identifier, const TSymbol *symbol); TIntermAggregate *parseDeclarator(TPublicType &publicType, TIntermAggregate *aggregateDeclaration, const TSourceLoc &identifierLocation, const TString &identifier); TIntermAggregate *parseArrayDeclarator(TPublicType &publicType, TIntermAggregate *aggregateDeclaration, const TSourceLoc &identifierLocation, const TString &identifier, const TSourceLoc &arrayLocation, TIntermTyped *indexExpression); TIntermAggregate *parseInitDeclarator(const TPublicType &publicType, TIntermAggregate *aggregateDeclaration, const TSourceLoc &identifierLocation, const TString &identifier, const TSourceLoc &initLocation, TIntermTyped *initializer); // Parse a declarator like "a[n] = initializer" TIntermAggregate *parseArrayInitDeclarator(const TPublicType &publicType, TIntermAggregate *aggregateDeclaration, const TSourceLoc &identifierLocation, const TString &identifier, const TSourceLoc &indexLocation, TIntermTyped *indexExpression, const TSourceLoc &initLocation, TIntermTyped *initializer); void parseGlobalLayoutQualifier(const TPublicType &typeQualifier); void parseFunctionPrototype(const TSourceLoc &location, TFunction *function, TIntermAggregate **aggregateOut); TFunction *parseFunctionDeclarator(const TSourceLoc &location, TFunction *function); TFunction *addConstructorFunc(const TPublicType &publicType); TIntermTyped *addConstructor(TIntermNode *arguments, TType *type, TOperator op, TFunction *fnCall, const TSourceLoc &line); TIntermTyped *foldConstConstructor(TIntermAggregate *aggrNode, const TType &type); TIntermTyped *addConstVectorNode(TVectorFields&, TIntermTyped*, const TSourceLoc&); TIntermTyped *addConstMatrixNode(int, TIntermTyped*, const TSourceLoc&); TIntermTyped *addConstArrayNode(int index, TIntermTyped *node, const TSourceLoc &line); TIntermTyped *addConstStruct( const TString &identifier, TIntermTyped *node, const TSourceLoc& line); TIntermTyped *addIndexExpression(TIntermTyped *baseExpression, const TSourceLoc& location, TIntermTyped *indexExpression); TIntermTyped* addFieldSelectionExpression(TIntermTyped *baseExpression, const TSourceLoc &dotLocation, const TString &fieldString, const TSourceLoc &fieldLocation); TFieldList *addStructDeclaratorList(const TPublicType &typeSpecifier, TFieldList *fieldList); TPublicType addStructure(const TSourceLoc &structLine, const TSourceLoc &nameLine, const TString *structName, TFieldList *fieldList); TIntermAggregate* addInterfaceBlock(const TPublicType &typeQualifier, const TSourceLoc &nameLine, const TString &blockName, TFieldList *fieldList, const TString *instanceName, const TSourceLoc &instanceLine, TIntermTyped *arrayIndex, const TSourceLoc& arrayIndexLine); TLayoutQualifier parseLayoutQualifier( const TString &qualifierType, const TSourceLoc &qualifierTypeLine); TLayoutQualifier parseLayoutQualifier(const TString &qualifierType, const TSourceLoc &qualifierTypeLine, const TString &intValueString, int intValue, const TSourceLoc &intValueLine); TLayoutQualifier joinLayoutQualifiers(TLayoutQualifier leftQualifier, TLayoutQualifier rightQualifier); TPublicType joinInterpolationQualifiers(const TSourceLoc &interpolationLoc, TQualifier interpolationQualifier, const TSourceLoc &storageLoc, TQualifier storageQualifier); // Performs an error check for embedded struct declarations. // Returns true if an error was raised due to the declaration of // this struct. bool enterStructDeclaration(const TSourceLoc &line, const TString &identifier); void exitStructDeclaration(); bool structNestingErrorCheck(const TSourceLoc &line, const TField &field); TIntermSwitch *addSwitch(TIntermTyped *init, TIntermAggregate *statementList, const TSourceLoc &loc); TIntermCase *addCase(TIntermTyped *condition, const TSourceLoc &loc); TIntermCase *addDefault(const TSourceLoc &loc); TIntermTyped *addUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc); TIntermTyped *addUnaryMathLValue(TOperator op, TIntermTyped *child, const TSourceLoc &loc); TIntermTyped *addBinaryMath( TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc); TIntermTyped *addBinaryMathBooleanResult( TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc); TIntermTyped *addAssign( TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc); TIntermBranch *addBranch(TOperator op, const TSourceLoc &loc); TIntermBranch *addBranch(TOperator op, TIntermTyped *returnValue, const TSourceLoc &loc); TIntermTyped *addFunctionCallOrMethod(TFunction *fnCall, TIntermNode *paramNode, TIntermNode *thisNode, const TSourceLoc &loc, bool *fatalError); TIntermTyped *addTernarySelection( TIntermTyped *cond, TIntermTyped *trueBlock, TIntermTyped *falseBlock, const TSourceLoc &line); // TODO(jmadill): make these private TIntermediate &intermediate; // to hold and build a parse tree TSymbolTable &symbolTable; // symbol table that goes with the language currently being parsed private: bool declareVariable(const TSourceLoc &line, const TString &identifier, const TType &type, TVariable **variable); bool nonInitErrorCheck(const TSourceLoc &line, const TString &identifier, TPublicType *type); TIntermTyped *addBinaryMathInternal( TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc); TIntermTyped *createAssign( TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc); // The funcReturnType parameter is expected to be non-null when the operation is a built-in function. // It is expected to be null for other unary operators. TIntermTyped *createUnaryMath( TOperator op, TIntermTyped *child, const TSourceLoc &loc, const TType *funcReturnType); // Return true if the checks pass bool binaryOpCommonCheck( TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc); // Set to true when the last/current declarator list was started with an empty declaration. bool mDeferredSingleDeclarationErrorCheck; sh::GLenum mShaderType; // vertex or fragment language (future: pack or unpack) ShShaderSpec mShaderSpec; // The language specification compiler conforms to - GLES2 or WebGL. int mShaderVersion; TIntermNode *mTreeRoot; // root of parse tree being created int mLoopNestingLevel; // 0 if outside all loops int mStructNestingLevel; // incremented while parsing a struct declaration int mSwitchNestingLevel; // 0 if outside all switch statements const TType *mCurrentFunctionType; // the return type of the function that's currently being parsed bool mFunctionReturnsValue; // true if a non-void function has a return bool mChecksPrecisionErrors; // true if an error will be generated when a variable is declared without precision, explicit or implicit. bool mFragmentPrecisionHigh; // true if highp precision is supported in the fragment language. TLayoutMatrixPacking mDefaultMatrixPacking; TLayoutBlockStorage mDefaultBlockStorage; TString mHashErrMsg; TDiagnostics mDiagnostics; TDirectiveHandler mDirectiveHandler; pp::Preprocessor mPreprocessor; void *mScanner; bool mUsesFragData; // track if we are using both gl_FragData and gl_FragColor bool mUsesFragColor; bool mUsesSecondaryOutputs; // Track if we are using either gl_SecondaryFragData or // gl_Secondary FragColor or both. }; int PaParseStrings( size_t count, const char *const string[], const int length[], TParseContext *context); #endif // COMPILER_TRANSLATOR_PARSECONTEXT_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/PoolAlloc.cpp000066400000000000000000000176361321746453100273310ustar00rootroot00000000000000// // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/PoolAlloc.h" #include "compiler/translator/InitializeGlobals.h" #include "common/platform.h" #include "common/angleutils.h" #include "common/tls.h" #include #include #include TLSIndex PoolIndex = TLS_INVALID_INDEX; bool InitializePoolIndex() { assert(PoolIndex == TLS_INVALID_INDEX); PoolIndex = CreateTLSIndex(); return PoolIndex != TLS_INVALID_INDEX; } void FreePoolIndex() { assert(PoolIndex != TLS_INVALID_INDEX); DestroyTLSIndex(PoolIndex); PoolIndex = TLS_INVALID_INDEX; } TPoolAllocator* GetGlobalPoolAllocator() { assert(PoolIndex != TLS_INVALID_INDEX); return static_cast(GetTLSValue(PoolIndex)); } void SetGlobalPoolAllocator(TPoolAllocator* poolAllocator) { assert(PoolIndex != TLS_INVALID_INDEX); SetTLSValue(PoolIndex, poolAllocator); } // // Implement the functionality of the TPoolAllocator class, which // is documented in PoolAlloc.h. // TPoolAllocator::TPoolAllocator(int growthIncrement, int allocationAlignment) : pageSize(growthIncrement), alignment(allocationAlignment), freeList(0), inUseList(0), numCalls(0), totalBytes(0) { // // Don't allow page sizes we know are smaller than all common // OS page sizes. // if (pageSize < 4*1024) pageSize = 4*1024; // // A large currentPageOffset indicates a new page needs to // be obtained to allocate memory. // currentPageOffset = pageSize; // // Adjust alignment to be at least pointer aligned and // power of 2. // size_t minAlign = sizeof(void*); alignment &= ~(minAlign - 1); if (alignment < minAlign) alignment = minAlign; size_t a = 1; while (a < alignment) a <<= 1; alignment = a; alignmentMask = a - 1; // // Align header skip // headerSkip = minAlign; if (headerSkip < sizeof(tHeader)) { headerSkip = (sizeof(tHeader) + alignmentMask) & ~alignmentMask; } } TPoolAllocator::~TPoolAllocator() { while (inUseList) { tHeader* next = inUseList->nextPage; inUseList->~tHeader(); delete [] reinterpret_cast(inUseList); inUseList = next; } // We should not check the guard blocks // here, because we did it already when the block was // placed into the free list. // while (freeList) { tHeader* next = freeList->nextPage; delete [] reinterpret_cast(freeList); freeList = next; } } // Support MSVC++ 6.0 const unsigned char TAllocation::guardBlockBeginVal = 0xfb; const unsigned char TAllocation::guardBlockEndVal = 0xfe; const unsigned char TAllocation::userDataFill = 0xcd; #ifdef GUARD_BLOCKS const size_t TAllocation::guardBlockSize = 16; #else const size_t TAllocation::guardBlockSize = 0; #endif // // Check a single guard block for damage // void TAllocation::checkGuardBlock(unsigned char* blockMem, unsigned char val, const char* locText) const { #ifdef GUARD_BLOCKS for (size_t x = 0; x < guardBlockSize; x++) { if (blockMem[x] != val) { char assertMsg[80]; // We don't print the assert message. It's here just to be helpful. #if defined(_MSC_VER) snprintf(assertMsg, sizeof(assertMsg), "PoolAlloc: Damage %s %Iu byte allocation at 0x%p\n", locText, size, data()); #else snprintf(assertMsg, sizeof(assertMsg), "PoolAlloc: Damage %s %zu byte allocation at 0x%p\n", locText, size, data()); #endif assert(0 && "PoolAlloc: Damage in guard block"); } } #endif } void TPoolAllocator::push() { tAllocState state = { currentPageOffset, inUseList }; stack.push_back(state); // // Indicate there is no current page to allocate from. // currentPageOffset = pageSize; } // // Do a mass-deallocation of all the individual allocations // that have occurred since the last push(), or since the // last pop(), or since the object's creation. // // The deallocated pages are saved for future allocations. // void TPoolAllocator::pop() { if (stack.size() < 1) return; tHeader* page = stack.back().page; currentPageOffset = stack.back().offset; while (inUseList != page) { // invoke destructor to free allocation list inUseList->~tHeader(); tHeader* nextInUse = inUseList->nextPage; if (inUseList->pageCount > 1) delete [] reinterpret_cast(inUseList); else { inUseList->nextPage = freeList; freeList = inUseList; } inUseList = nextInUse; } stack.pop_back(); } // // Do a mass-deallocation of all the individual allocations // that have occurred. // void TPoolAllocator::popAll() { while (stack.size() > 0) pop(); } void* TPoolAllocator::allocate(size_t numBytes) { // // Just keep some interesting statistics. // ++numCalls; totalBytes += numBytes; // If we are using guard blocks, all allocations are bracketed by // them: [guardblock][allocation][guardblock]. numBytes is how // much memory the caller asked for. allocationSize is the total // size including guard blocks. In release build, // guardBlockSize=0 and this all gets optimized away. size_t allocationSize = TAllocation::allocationSize(numBytes); // Detect integer overflow. if (allocationSize < numBytes) return 0; // // Do the allocation, most likely case first, for efficiency. // This step could be moved to be inline sometime. // if (allocationSize <= pageSize - currentPageOffset) { // // Safe to allocate from currentPageOffset. // unsigned char* memory = reinterpret_cast(inUseList) + currentPageOffset; currentPageOffset += allocationSize; currentPageOffset = (currentPageOffset + alignmentMask) & ~alignmentMask; return initializeAllocation(inUseList, memory, numBytes); } if (allocationSize > pageSize - headerSkip) { // // Do a multi-page allocation. Don't mix these with the others. // The OS is efficient and allocating and free-ing multiple pages. // size_t numBytesToAlloc = allocationSize + headerSkip; // Detect integer overflow. if (numBytesToAlloc < allocationSize) return 0; tHeader* memory = reinterpret_cast(::new char[numBytesToAlloc]); if (memory == 0) return 0; // Use placement-new to initialize header new(memory) tHeader(inUseList, (numBytesToAlloc + pageSize - 1) / pageSize); inUseList = memory; currentPageOffset = pageSize; // make next allocation come from a new page // No guard blocks for multi-page allocations (yet) return reinterpret_cast(reinterpret_cast(memory) + headerSkip); } // // Need a simple page to allocate from. // tHeader* memory; if (freeList) { memory = freeList; freeList = freeList->nextPage; } else { memory = reinterpret_cast(::new char[pageSize]); if (memory == 0) return 0; } // Use placement-new to initialize header new(memory) tHeader(inUseList, 1); inUseList = memory; unsigned char* ret = reinterpret_cast(inUseList) + headerSkip; currentPageOffset = (headerSkip + allocationSize + alignmentMask) & ~alignmentMask; return initializeAllocation(inUseList, ret, numBytes); } // // Check all allocations in a list for damage by calling check on each. // void TAllocation::checkAllocList() const { for (const TAllocation* alloc = this; alloc != 0; alloc = alloc->prevAlloc) alloc->check(); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/PoolAlloc.h000066400000000000000000000236541321746453100267730ustar00rootroot00000000000000// // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_POOLALLOC_H_ #define COMPILER_TRANSLATOR_POOLALLOC_H_ #ifdef _DEBUG #define GUARD_BLOCKS // define to enable guard block sanity checking #endif // // This header defines an allocator that can be used to efficiently // allocate a large number of small requests for heap memory, with the // intention that they are not individually deallocated, but rather // collectively deallocated at one time. // // This simultaneously // // * Makes each individual allocation much more efficient; the // typical allocation is trivial. // * Completely avoids the cost of doing individual deallocation. // * Saves the trouble of tracking down and plugging a large class of leaks. // // Individual classes can use this allocator by supplying their own // new and delete methods. // // STL containers can use this allocator by using the pool_allocator // class as the allocator (second) template argument. // #include #include #include // If we are using guard blocks, we must track each indivual // allocation. If we aren't using guard blocks, these // never get instantiated, so won't have any impact. // class TAllocation { public: TAllocation(size_t size, unsigned char* mem, TAllocation* prev = 0) : size(size), mem(mem), prevAlloc(prev) { // Allocations are bracketed: // [allocationHeader][initialGuardBlock][userData][finalGuardBlock] // This would be cleaner with if (guardBlockSize)..., but that // makes the compiler print warnings about 0 length memsets, // even with the if() protecting them. #ifdef GUARD_BLOCKS memset(preGuard(), guardBlockBeginVal, guardBlockSize); memset(data(), userDataFill, size); memset(postGuard(), guardBlockEndVal, guardBlockSize); #endif } void check() const { checkGuardBlock(preGuard(), guardBlockBeginVal, "before"); checkGuardBlock(postGuard(), guardBlockEndVal, "after"); } void checkAllocList() const; // Return total size needed to accommodate user buffer of 'size', // plus our tracking data. inline static size_t allocationSize(size_t size) { return size + 2 * guardBlockSize + headerSize(); } // Offset from surrounding buffer to get to user data buffer. inline static unsigned char* offsetAllocation(unsigned char* m) { return m + guardBlockSize + headerSize(); } private: void checkGuardBlock(unsigned char* blockMem, unsigned char val, const char* locText) const; // Find offsets to pre and post guard blocks, and user data buffer unsigned char* preGuard() const { return mem + headerSize(); } unsigned char* data() const { return preGuard() + guardBlockSize; } unsigned char* postGuard() const { return data() + size; } size_t size; // size of the user data area unsigned char* mem; // beginning of our allocation (pts to header) TAllocation* prevAlloc; // prior allocation in the chain // Support MSVC++ 6.0 const static unsigned char guardBlockBeginVal; const static unsigned char guardBlockEndVal; const static unsigned char userDataFill; const static size_t guardBlockSize; #ifdef GUARD_BLOCKS inline static size_t headerSize() { return sizeof(TAllocation); } #else inline static size_t headerSize() { return 0; } #endif }; // // There are several stacks. One is to track the pushing and popping // of the user, and not yet implemented. The others are simply a // repositories of free pages or used pages. // // Page stacks are linked together with a simple header at the beginning // of each allocation obtained from the underlying OS. Multi-page allocations // are returned to the OS. Individual page allocations are kept for future // re-use. // // The "page size" used is not, nor must it match, the underlying OS // page size. But, having it be about that size or equal to a set of // pages is likely most optimal. // class TPoolAllocator { public: TPoolAllocator(int growthIncrement = 8*1024, int allocationAlignment = 16); // // Don't call the destructor just to free up the memory, call pop() // ~TPoolAllocator(); // // Call push() to establish a new place to pop memory too. Does not // have to be called to get things started. // void push(); // // Call pop() to free all memory allocated since the last call to push(), // or if no last call to push, frees all memory since first allocation. // void pop(); // // Call popAll() to free all memory allocated. // void popAll(); // // Call allocate() to actually acquire memory. Returns 0 if no memory // available, otherwise a properly aligned pointer to 'numBytes' of memory. // void* allocate(size_t numBytes); // // There is no deallocate. The point of this class is that // deallocation can be skipped by the user of it, as the model // of use is to simultaneously deallocate everything at once // by calling pop(), and to not have to solve memory leak problems. // protected: friend struct tHeader; struct tHeader { tHeader(tHeader* nextPage, size_t pageCount) : nextPage(nextPage), pageCount(pageCount) #ifdef GUARD_BLOCKS , lastAllocation(0) #endif { } ~tHeader() { #ifdef GUARD_BLOCKS if (lastAllocation) lastAllocation->checkAllocList(); #endif } tHeader* nextPage; size_t pageCount; #ifdef GUARD_BLOCKS TAllocation* lastAllocation; #endif }; struct tAllocState { size_t offset; tHeader* page; }; typedef std::vector tAllocStack; // Track allocations if and only if we're using guard blocks void* initializeAllocation(tHeader* block, unsigned char* memory, size_t numBytes) { #ifdef GUARD_BLOCKS new(memory) TAllocation(numBytes, memory, block->lastAllocation); block->lastAllocation = reinterpret_cast(memory); #endif // This is optimized entirely away if GUARD_BLOCKS is not defined. return TAllocation::offsetAllocation(memory); } size_t pageSize; // granularity of allocation from the OS size_t alignment; // all returned allocations will be aligned at // this granularity, which will be a power of 2 size_t alignmentMask; size_t headerSkip; // amount of memory to skip to make room for the // header (basically, size of header, rounded // up to make it aligned size_t currentPageOffset; // next offset in top of inUseList to allocate from tHeader* freeList; // list of popped memory tHeader* inUseList; // list of all memory currently being used tAllocStack stack; // stack of where to allocate from, to partition pool int numCalls; // just an interesting statistic size_t totalBytes; // just an interesting statistic private: TPoolAllocator& operator=(const TPoolAllocator&); // don't allow assignment operator TPoolAllocator(const TPoolAllocator&); // don't allow default copy constructor }; // // There could potentially be many pools with pops happening at // different times. But a simple use is to have a global pop // with everyone using the same global allocator. // extern TPoolAllocator* GetGlobalPoolAllocator(); extern void SetGlobalPoolAllocator(TPoolAllocator* poolAllocator); // // This STL compatible allocator is intended to be used as the allocator // parameter to templatized STL containers, like vector and map. // // It will use the pools for allocation, and not // do any deallocation, but will still do destruction. // template class pool_allocator { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef T* pointer; typedef const T* const_pointer; typedef T& reference; typedef const T& const_reference; typedef T value_type; template struct rebind { typedef pool_allocator other; }; pointer address(reference x) const { return &x; } const_pointer address(const_reference x) const { return &x; } pool_allocator() { } template pool_allocator(const pool_allocator& p) { } template pool_allocator& operator=(const pool_allocator& p) { return *this; } #if defined(__SUNPRO_CC) && !defined(_RWSTD_ALLOCATOR) // libCStd on some platforms have a different allocate/deallocate interface. // Caller pre-bakes sizeof(T) into 'n' which is the number of bytes to be // allocated, not the number of elements. void* allocate(size_type n) { return getAllocator().allocate(n); } void* allocate(size_type n, const void*) { return getAllocator().allocate(n); } void deallocate(void*, size_type) {} #else pointer allocate(size_type n) { return reinterpret_cast(getAllocator().allocate(n * sizeof(T))); } pointer allocate(size_type n, const void*) { return reinterpret_cast(getAllocator().allocate(n * sizeof(T))); } void deallocate(pointer, size_type) {} #endif // _RWSTD_ALLOCATOR void construct(pointer p, const T& val) { new ((void *)p) T(val); } void destroy(pointer p) { p->T::~T(); } bool operator==(const pool_allocator& rhs) const { return true; } bool operator!=(const pool_allocator& rhs) const { return false; } size_type max_size() const { return static_cast(-1) / sizeof(T); } size_type max_size(int size) const { return static_cast(-1) / size; } TPoolAllocator& getAllocator() const { return *GetGlobalPoolAllocator(); } }; #endif // COMPILER_TRANSLATOR_POOLALLOC_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/Pragma.h000066400000000000000000000015151321746453100263060ustar00rootroot00000000000000// // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_PRAGMA_H_ #define COMPILER_TRANSLATOR_PRAGMA_H_ struct TPragma { struct STDGL { STDGL() : invariantAll(false) { } bool invariantAll; }; // By default optimization is turned on and debug is turned off. // Precision emulation is turned on by default, but has no effect unless // the extension is enabled. TPragma() : optimize(true), debug(false), debugShaderPrecision(true) { } TPragma(bool o, bool d) : optimize(o), debug(d), debugShaderPrecision(true) { } bool optimize; bool debug; bool debugShaderPrecision; STDGL stdgl; }; #endif // COMPILER_TRANSLATOR_PRAGMA_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/PruneEmptyDeclarations.cpp000066400000000000000000000056031321746453100320750ustar00rootroot00000000000000// // Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // The PruneEmptyDeclarations function prunes unnecessary empty declarations and declarators from the AST. #include "compiler/translator/PruneEmptyDeclarations.h" #include "compiler/translator/IntermNode.h" namespace { class PruneEmptyDeclarationsTraverser : private TIntermTraverser { public: static void apply(TIntermNode *root); private: PruneEmptyDeclarationsTraverser(); bool visitAggregate(Visit, TIntermAggregate *node) override; }; void PruneEmptyDeclarationsTraverser::apply(TIntermNode *root) { PruneEmptyDeclarationsTraverser prune; root->traverse(&prune); prune.updateTree(); } PruneEmptyDeclarationsTraverser::PruneEmptyDeclarationsTraverser() : TIntermTraverser(true, false, false) { } bool PruneEmptyDeclarationsTraverser::visitAggregate(Visit, TIntermAggregate *node) { if (node->getOp() == EOpDeclaration) { TIntermSequence *sequence = node->getSequence(); if (sequence->size() >= 1) { TIntermSymbol *sym = sequence->front()->getAsSymbolNode(); // Prune declarations without a variable name, unless it's an interface block declaration. if (sym != nullptr && sym->getSymbol() == "" && !sym->isInterfaceBlock()) { if (sequence->size() > 1) { // Generate a replacement that will remove the empty declarator in the beginning of a declarator // list. Example of a declaration that will be changed: // float, a; // will be changed to // float a; // This applies also to struct declarations. TIntermSequence emptyReplacement; mMultiReplacements.push_back(NodeReplaceWithMultipleEntry(node, sym, emptyReplacement)); } else if (sym->getBasicType() != EbtStruct) { // Single struct declarations may just declare the struct type and no variables, so they should // not be pruned. All other single empty declarations can be pruned entirely. Example of an empty // declaration that will be pruned: // float; TIntermSequence emptyReplacement; TIntermAggregate *parentAgg = getParentNode()->getAsAggregate(); ASSERT(parentAgg != nullptr); mMultiReplacements.push_back(NodeReplaceWithMultipleEntry(parentAgg, node, emptyReplacement)); } } } return false; } return true; } } // namespace void PruneEmptyDeclarations(TIntermNode *root) { PruneEmptyDeclarationsTraverser::apply(root); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/PruneEmptyDeclarations.h000066400000000000000000000010201321746453100315270ustar00rootroot00000000000000// // Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // The PruneEmptyDeclarations function prunes unnecessary empty declarations and declarators from the AST. #ifndef COMPILER_TRANSLATOR_PRUNEEMPTYDECLARATIONS_H_ #define COMPILER_TRANSLATOR_PRUNEEMPTYDECLARATIONS_H_ class TIntermNode; void PruneEmptyDeclarations(TIntermNode *root); #endif // COMPILER_TRANSLATOR_PRUNEEMPTYDECLARATIONS_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/RecordConstantPrecision.cpp000066400000000000000000000133401321746453100322350ustar00rootroot00000000000000// // Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // During parsing, all constant expressions are folded to constant union nodes. The expressions that have been // folded may have had precision qualifiers, which should affect the precision of the consuming operation. // If the folded constant union nodes are written to output as such they won't have any precision qualifiers, // and their effect on the precision of the consuming operation is lost. // // RecordConstantPrecision is an AST traverser that inspects the precision qualifiers of constants and hoists // the constants outside the containing expression as precision qualified named variables in case that is // required for correct precision propagation. // #include "compiler/translator/RecordConstantPrecision.h" #include "compiler/translator/InfoSink.h" #include "compiler/translator/IntermNode.h" namespace { class RecordConstantPrecisionTraverser : public TIntermTraverser { public: RecordConstantPrecisionTraverser(); void visitConstantUnion(TIntermConstantUnion *node) override; void nextIteration(); bool foundHigherPrecisionConstant() const { return mFoundHigherPrecisionConstant; } protected: bool operandAffectsParentOperationPrecision(TIntermTyped *operand); bool mFoundHigherPrecisionConstant; }; RecordConstantPrecisionTraverser::RecordConstantPrecisionTraverser() : TIntermTraverser(true, false, true), mFoundHigherPrecisionConstant(false) { } bool RecordConstantPrecisionTraverser::operandAffectsParentOperationPrecision(TIntermTyped *operand) { const TIntermBinary *parentAsBinary = getParentNode()->getAsBinaryNode(); if (parentAsBinary != nullptr) { // If the constant is assigned or is used to initialize a variable, or if it's an index, // its precision has no effect. switch (parentAsBinary->getOp()) { case EOpInitialize: case EOpAssign: case EOpIndexDirect: case EOpIndexDirectStruct: case EOpIndexDirectInterfaceBlock: case EOpIndexIndirect: return false; default: break; } TIntermTyped *otherOperand = parentAsBinary->getRight(); if (otherOperand == operand) { otherOperand = parentAsBinary->getLeft(); } // If the precision of the other child is at least as high as the precision of the constant, the precision of // the constant has no effect. if (otherOperand->getAsConstantUnion() == nullptr && otherOperand->getPrecision() >= operand->getPrecision()) { return false; } } TIntermAggregate *parentAsAggregate = getParentNode()->getAsAggregate(); if (parentAsAggregate != nullptr) { if (!parentAsAggregate->gotPrecisionFromChildren()) { // This can be either: // * a call to an user-defined function // * a call to a texture function // * some other kind of aggregate // In any of these cases the constant precision has no effect. return false; } if (parentAsAggregate->isConstructor() && parentAsAggregate->getBasicType() == EbtBool) { return false; } // If the precision of operands does affect the result, but the precision of any of the other children // has a precision that's at least as high as the precision of the constant, the precision of the constant // has no effect. TIntermSequence *parameters = parentAsAggregate->getSequence(); for (TIntermNode *parameter : *parameters) { const TIntermTyped *typedParameter = parameter->getAsTyped(); if (parameter != operand && typedParameter != nullptr && parameter->getAsConstantUnion() == nullptr && typedParameter->getPrecision() >= operand->getPrecision()) { return false; } } } return true; } void RecordConstantPrecisionTraverser::visitConstantUnion(TIntermConstantUnion *node) { if (mFoundHigherPrecisionConstant) return; // If the constant has lowp or undefined precision, it can't increase the precision of consuming operations. if (node->getPrecision() < EbpMedium) return; // It's possible the node has no effect on the precision of the consuming expression, depending on the // consuming expression, and the precision of the other parameters of the expression. if (!operandAffectsParentOperationPrecision(node)) return; // Make the constant a precision-qualified named variable to make sure it affects the precision of the consuming // expression. TIntermSequence insertions; insertions.push_back(createTempInitDeclaration(node, EvqConst)); insertStatementsInParentBlock(insertions); mReplacements.push_back(NodeUpdateEntry(getParentNode(), node, createTempSymbol(node->getType()), false)); mFoundHigherPrecisionConstant = true; } void RecordConstantPrecisionTraverser::nextIteration() { nextTemporaryIndex(); mFoundHigherPrecisionConstant = false; } } // namespace void RecordConstantPrecision(TIntermNode *root, unsigned int *temporaryIndex) { RecordConstantPrecisionTraverser traverser; ASSERT(temporaryIndex != nullptr); traverser.useTemporaryIndex(temporaryIndex); // Iterate as necessary, and reset the traverser between iterations. do { traverser.nextIteration(); root->traverse(&traverser); if (traverser.foundHigherPrecisionConstant()) traverser.updateTree(); } while (traverser.foundHigherPrecisionConstant()); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/RecordConstantPrecision.h000066400000000000000000000021461321746453100317040ustar00rootroot00000000000000// // Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // During parsing, all constant expressions are folded to constant union nodes. The expressions that have been // folded may have had precision qualifiers, which should affect the precision of the consuming operation. // If the folded constant union nodes are written to output as such they won't have any precision qualifiers, // and their effect on the precision of the consuming operation is lost. // // RecordConstantPrecision is an AST traverser that inspects the precision qualifiers of constants and hoists // the constants outside the containing expression as precision qualified named variables in case that is // required for correct precision propagation. // #ifndef COMPILER_TRANSLATOR_RECORDCONSTANTPRECISION_H_ #define COMPILER_TRANSLATOR_RECORDCONSTANTPRECISION_H_ class TIntermNode; void RecordConstantPrecision(TIntermNode *root, unsigned int *temporaryIndex); #endif // COMPILER_TRANSLATOR_RECORDCONSTANTPRECISION_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/ShaderLang.cpp000066400000000000000000000121311321746453100274360ustar00rootroot00000000000000// // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // // Implement the top-level of interface to the compiler, // as defined in ShaderLang.h // #include "GLSLANG/ShaderLang.h" #include "compiler/translator/Compiler.h" #include "compiler/translator/InitializeDll.h" #include "compiler/translator/length_limits.h" #include "angle_gl.h" namespace { enum ShaderVariableType { SHADERVAR_UNIFORM, SHADERVAR_VARYING, SHADERVAR_ATTRIBUTE, SHADERVAR_OUTPUTVARIABLE, SHADERVAR_INTERFACEBLOCK }; bool isInitialized = false; // // This is the platform independent interface between an OGL driver // and the shading language compiler. // TCompiler *GetCompilerFromHandle(ShHandle handle) { if (!handle) return NULL; TShHandleBase *base = static_cast(handle); return base->getAsCompiler(); } } // namespace anonymous // // Driver must call this first, once, before doing any other compiler operations. // Subsequent calls to this function are no-op. // bool ShInitialize() { if (!isInitialized) { isInitialized = InitProcess(); } return isInitialized; } // // Cleanup symbol tables // bool ShFinalize() { if (isInitialized) { DetachProcess(); isInitialized = false; } return true; } // // Initialize built-in resources with minimum expected values. // void ShInitBuiltInResources(ShBuiltInResources* resources) { // Make comparable. memset(resources, 0, sizeof(*resources)); // Constants. resources->MaxVertexAttribs = 8; resources->MaxVertexUniformVectors = 128; resources->MaxVaryingVectors = 8; resources->MaxVertexTextureImageUnits = 0; resources->MaxCombinedTextureImageUnits = 8; resources->MaxTextureImageUnits = 8; resources->MaxFragmentUniformVectors = 16; resources->MaxDrawBuffers = 1; // Extensions. resources->OES_standard_derivatives = 0; resources->OES_EGL_image_external = 0; resources->ARB_texture_rectangle = 0; resources->EXT_blend_func_extended = 0; resources->EXT_draw_buffers = 0; resources->EXT_frag_depth = 0; resources->EXT_shader_texture_lod = 0; resources->WEBGL_debug_shader_precision = 0; resources->EXT_shader_framebuffer_fetch = 0; resources->NV_shader_framebuffer_fetch = 0; resources->ARM_shader_framebuffer_fetch = 0; resources->NV_draw_buffers = 0; // Disable highp precision in fragment shader by default. resources->FragmentPrecisionHigh = 0; // GLSL ES 3.0 constants. resources->MaxVertexOutputVectors = 16; resources->MaxFragmentInputVectors = 15; resources->MinProgramTexelOffset = -8; resources->MaxProgramTexelOffset = 7; // Extensions constants. resources->MaxDualSourceDrawBuffers = 0; // Disable name hashing by default. resources->HashFunction = NULL; resources->MaxExpressionComplexity = 256; resources->MaxCallStackDepth = 256; } // // Driver calls these to create and destroy compiler objects. // ShHandle ShConstructCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output, const ShBuiltInResources* resources) { TShHandleBase* base = static_cast(ConstructCompiler(type, spec, output)); TCompiler* compiler = base->getAsCompiler(); if (compiler == 0) return 0; // Generate built-in symbol table. if (!compiler->Init(*resources)) { ShDestruct(base); return 0; } return reinterpret_cast(base); } void ShDestruct(ShHandle handle) { if (handle == 0) return; TShHandleBase* base = static_cast(handle); if (base->getAsCompiler()) DeleteCompiler(base->getAsCompiler()); } const std::string &ShGetBuiltInResourcesString(const ShHandle handle) { TCompiler *compiler = GetCompilerFromHandle(handle); ASSERT(compiler); return compiler->getBuiltInResourcesString(); } // // Do an actual compile on the given strings. The result is left // in the given compile object. // // Return: The return value of ShCompile is really boolean, indicating // success or failure. // bool ShCompile( const ShHandle handle, const char *const shaderStrings[], size_t numStrings, int compileOptions) { TCompiler *compiler = GetCompilerFromHandle(handle); ASSERT(compiler); return compiler->compile(shaderStrings, numStrings, compileOptions); } void ShClearResults(const ShHandle handle) { TCompiler *compiler = GetCompilerFromHandle(handle); ASSERT(compiler); compiler->clearResults(); } ShShaderOutput ShGetShaderOutputType(const ShHandle handle) { TCompiler* compiler = GetCompilerFromHandle(handle); ASSERT(compiler); return compiler->getOutputType(); } // // Return any object code. // const std::string &ShGetObjectCode(const ShHandle handle) { TCompiler *compiler = GetCompilerFromHandle(handle); ASSERT(compiler); TInfoSink &infoSink = compiler->getInfoSink(); return infoSink.obj.str(); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/SymbolTable.cpp000066400000000000000000000234431321746453100276530ustar00rootroot00000000000000// // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // // Symbol table for parsing. Most functionaliy and main ideas // are documented in the header file. // #if defined(_MSC_VER) #pragma warning(disable: 4718) #endif #include "compiler/translator/SymbolTable.h" #include "compiler/translator/Cache.h" #include #include int TSymbolTable::uniqueIdCounter = 0; // // Functions have buried pointers to delete. // TFunction::~TFunction() { for (TParamList::iterator i = parameters.begin(); i != parameters.end(); ++i) delete (*i).type; } const TString *TFunction::buildMangledName() const { std::string newName = mangleName(getName()).c_str(); for (const auto &p : parameters) { newName += p.type->getMangledName().c_str(); } return NewPoolTString(newName.c_str()); } // // Symbol table levels are a map of pointers to symbols that have to be deleted. // TSymbolTableLevel::~TSymbolTableLevel() { for (tLevel::iterator it = level.begin(); it != level.end(); ++it) delete (*it).second; } bool TSymbolTableLevel::insert(TSymbol *symbol) { symbol->setUniqueId(TSymbolTable::nextUniqueId()); // returning true means symbol was added to the table tInsertResult result = level.insert(tLevelPair(symbol->getMangledName(), symbol)); return result.second; } bool TSymbolTableLevel::insertUnmangled(TFunction *function) { function->setUniqueId(TSymbolTable::nextUniqueId()); // returning true means symbol was added to the table tInsertResult result = level.insert(tLevelPair(function->getName(), function)); return result.second; } TSymbol *TSymbolTableLevel::find(const TString &name) const { tLevel::const_iterator it = level.find(name); if (it == level.end()) return 0; else return (*it).second; } TSymbol *TSymbolTable::find(const TString &name, int shaderVersion, bool *builtIn, bool *sameScope) const { int level = currentLevel(); TSymbol *symbol; do { if (level == ESSL3_BUILTINS && shaderVersion != 300) level--; if (level == ESSL1_BUILTINS && shaderVersion != 100) level--; symbol = table[level]->find(name); } while (symbol == 0 && --level >= 0); if (builtIn) *builtIn = (level <= LAST_BUILTIN_LEVEL); if (sameScope) *sameScope = (level == currentLevel()); return symbol; } TSymbol *TSymbolTable::findBuiltIn( const TString &name, int shaderVersion) const { for (int level = LAST_BUILTIN_LEVEL; level >= 0; level--) { if (level == ESSL3_BUILTINS && shaderVersion != 300) level--; if (level == ESSL1_BUILTINS && shaderVersion != 100) level--; TSymbol *symbol = table[level]->find(name); if (symbol) return symbol; } return 0; } TSymbolTable::~TSymbolTable() { while (table.size() > 0) pop(); } bool IsGenType(const TType *type) { if (type) { TBasicType basicType = type->getBasicType(); return basicType == EbtGenType || basicType == EbtGenIType || basicType == EbtGenUType || basicType == EbtGenBType; } return false; } bool IsVecType(const TType *type) { if (type) { TBasicType basicType = type->getBasicType(); return basicType == EbtVec || basicType == EbtIVec || basicType == EbtUVec || basicType == EbtBVec; } return false; } const TType *SpecificType(const TType *type, int size) { ASSERT(size >= 1 && size <= 4); if (!type) { return nullptr; } ASSERT(!IsVecType(type)); switch(type->getBasicType()) { case EbtGenType: return TCache::getType(EbtFloat, static_cast(size)); case EbtGenIType: return TCache::getType(EbtInt, static_cast(size)); case EbtGenUType: return TCache::getType(EbtUInt, static_cast(size)); case EbtGenBType: return TCache::getType(EbtBool, static_cast(size)); default: return type; } } const TType *VectorType(const TType *type, int size) { ASSERT(size >= 2 && size <= 4); if (!type) { return nullptr; } ASSERT(!IsGenType(type)); switch(type->getBasicType()) { case EbtVec: return TCache::getType(EbtFloat, static_cast(size)); case EbtIVec: return TCache::getType(EbtInt, static_cast(size)); case EbtUVec: return TCache::getType(EbtUInt, static_cast(size)); case EbtBVec: return TCache::getType(EbtBool, static_cast(size)); default: return type; } } void TSymbolTable::insertBuiltIn(ESymbolLevel level, TOperator op, const char *ext, const TType *rvalue, const char *name, const TType *ptype1, const TType *ptype2, const TType *ptype3, const TType *ptype4, const TType *ptype5) { if (ptype1->getBasicType() == EbtGSampler2D) { bool gvec4 = (rvalue->getBasicType() == EbtGVec4); insertBuiltIn(level, gvec4 ? TCache::getType(EbtFloat, 4) : rvalue, name, TCache::getType(EbtSampler2D), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? TCache::getType(EbtInt, 4) : rvalue, name, TCache::getType(EbtISampler2D), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? TCache::getType(EbtUInt, 4) : rvalue, name, TCache::getType(EbtUSampler2D), ptype2, ptype3, ptype4, ptype5); } else if (ptype1->getBasicType() == EbtGSampler3D) { bool gvec4 = (rvalue->getBasicType() == EbtGVec4); insertBuiltIn(level, gvec4 ? TCache::getType(EbtFloat, 4) : rvalue, name, TCache::getType(EbtSampler3D), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? TCache::getType(EbtInt, 4) : rvalue, name, TCache::getType(EbtISampler3D), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? TCache::getType(EbtUInt, 4) : rvalue, name, TCache::getType(EbtUSampler3D), ptype2, ptype3, ptype4, ptype5); } else if (ptype1->getBasicType() == EbtGSamplerCube) { bool gvec4 = (rvalue->getBasicType() == EbtGVec4); insertBuiltIn(level, gvec4 ? TCache::getType(EbtFloat, 4) : rvalue, name, TCache::getType(EbtSamplerCube), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? TCache::getType(EbtInt, 4) : rvalue, name, TCache::getType(EbtISamplerCube), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? TCache::getType(EbtUInt, 4) : rvalue, name, TCache::getType(EbtUSamplerCube), ptype2, ptype3, ptype4, ptype5); } else if (ptype1->getBasicType() == EbtGSampler2DArray) { bool gvec4 = (rvalue->getBasicType() == EbtGVec4); insertBuiltIn(level, gvec4 ? TCache::getType(EbtFloat, 4) : rvalue, name, TCache::getType(EbtSampler2DArray), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? TCache::getType(EbtInt, 4) : rvalue, name, TCache::getType(EbtISampler2DArray), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? TCache::getType(EbtUInt, 4) : rvalue, name, TCache::getType(EbtUSampler2DArray), ptype2, ptype3, ptype4, ptype5); } else if (IsGenType(rvalue) || IsGenType(ptype1) || IsGenType(ptype2) || IsGenType(ptype3)) { ASSERT(!ptype4 && !ptype5); insertBuiltIn(level, op, ext, SpecificType(rvalue, 1), name, SpecificType(ptype1, 1), SpecificType(ptype2, 1), SpecificType(ptype3, 1)); insertBuiltIn(level, op, ext, SpecificType(rvalue, 2), name, SpecificType(ptype1, 2), SpecificType(ptype2, 2), SpecificType(ptype3, 2)); insertBuiltIn(level, op, ext, SpecificType(rvalue, 3), name, SpecificType(ptype1, 3), SpecificType(ptype2, 3), SpecificType(ptype3, 3)); insertBuiltIn(level, op, ext, SpecificType(rvalue, 4), name, SpecificType(ptype1, 4), SpecificType(ptype2, 4), SpecificType(ptype3, 4)); } else if (IsVecType(rvalue) || IsVecType(ptype1) || IsVecType(ptype2) || IsVecType(ptype3)) { ASSERT(!ptype4 && !ptype5); insertBuiltIn(level, op, ext, VectorType(rvalue, 2), name, VectorType(ptype1, 2), VectorType(ptype2, 2), VectorType(ptype3, 2)); insertBuiltIn(level, op, ext, VectorType(rvalue, 3), name, VectorType(ptype1, 3), VectorType(ptype2, 3), VectorType(ptype3, 3)); insertBuiltIn(level, op, ext, VectorType(rvalue, 4), name, VectorType(ptype1, 4), VectorType(ptype2, 4), VectorType(ptype3, 4)); } else { TFunction *function = new TFunction(NewPoolTString(name), rvalue, op, ext); function->addParameter(TConstParameter(ptype1)); if (ptype2) { function->addParameter(TConstParameter(ptype2)); } if (ptype3) { function->addParameter(TConstParameter(ptype3)); } if (ptype4) { function->addParameter(TConstParameter(ptype4)); } if (ptype5) { function->addParameter(TConstParameter(ptype5)); } insert(level, function); } } TPrecision TSymbolTable::getDefaultPrecision(TBasicType type) const { if (!SupportsPrecision(type)) return EbpUndefined; // unsigned integers use the same precision as signed TBasicType baseType = (type == EbtUInt) ? EbtInt : type; int level = static_cast(precisionStack.size()) - 1; assert(level >= 0); // Just to be safe. Should not happen. // If we don't find anything we return this. Should we error check this? TPrecision prec = EbpUndefined; while (level >= 0) { PrecisionStackLevel::iterator it = precisionStack[level]->find(baseType); if (it != precisionStack[level]->end()) { prec = (*it).second; break; } level--; } return prec; } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/SymbolTable.h000066400000000000000000000330551321746453100273200ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_SYMBOLTABLE_H_ #define COMPILER_TRANSLATOR_SYMBOLTABLE_H_ // // Symbol table for parsing. Has these design characteristics: // // * Same symbol table can be used to compile many shaders, to preserve // effort of creating and loading with the large numbers of built-in // symbols. // // * Name mangling will be used to give each function a unique name // so that symbol table lookups are never ambiguous. This allows // a simpler symbol table structure. // // * Pushing and popping of scope, so symbol table will really be a stack // of symbol tables. Searched from the top, with new inserts going into // the top. // // * Constants: Compile time constant symbols will keep their values // in the symbol table. The parser can substitute constants at parse // time, including doing constant folding and constant propagation. // // * No temporaries: Temporaries made from operations (+, --, .xy, etc.) // are tracked in the intermediate representation, not the symbol table. // #include #include #include "common/angleutils.h" #include "compiler/translator/InfoSink.h" #include "compiler/translator/IntermNode.h" // Symbol base class. (Can build functions or variables out of these...) class TSymbol : angle::NonCopyable { public: POOL_ALLOCATOR_NEW_DELETE(); TSymbol(const TString *n) : uniqueId(0), name(n) { } virtual ~TSymbol() { // don't delete name, it's from the pool } const TString &getName() const { return *name; } virtual const TString &getMangledName() const { return getName(); } virtual bool isFunction() const { return false; } virtual bool isVariable() const { return false; } void setUniqueId(int id) { uniqueId = id; } int getUniqueId() const { return uniqueId; } void relateToExtension(const TString &ext) { extension = ext; } const TString &getExtension() const { return extension; } private: int uniqueId; // For real comparing during code generation const TString *name; TString extension; }; // Variable class, meaning a symbol that's not a function. // // There could be a separate class hierarchy for Constant variables; // Only one of int, bool, or float, (or none) is correct for // any particular use, but it's easy to do this way, and doesn't // seem worth having separate classes, and "getConst" can't simply return // different values for different types polymorphically, so this is // just simple and pragmatic. class TVariable : public TSymbol { public: TVariable(const TString *name, const TType &t, bool uT = false) : TSymbol(name), type(t), userType(uT), unionArray(0) { } virtual ~TVariable() { } virtual bool isVariable() const { return true; } TType &getType() { return type; } const TType &getType() const { return type; } bool isUserType() const { return userType; } void setQualifier(TQualifier qualifier) { type.setQualifier(qualifier); } TConstantUnion *getConstPointer() { if (!unionArray) unionArray = new TConstantUnion[type.getObjectSize()]; return unionArray; } TConstantUnion *getConstPointer() const { return unionArray; } void shareConstPointer(TConstantUnion *constArray) { if (unionArray == constArray) return; delete[] unionArray; unionArray = constArray; } private: TType type; bool userType; // we are assuming that Pool Allocator will free the memory // allocated to unionArray when this object is destroyed. TConstantUnion *unionArray; }; // Immutable version of TParameter. struct TConstParameter { TConstParameter() : name(nullptr), type(nullptr) { } explicit TConstParameter(const TString *n) : name(n), type(nullptr) { } explicit TConstParameter(const TType *t) : name(nullptr), type(t) { } TConstParameter(const TString *n, const TType *t) : name(n), type(t) { } // Both constructor arguments must be const. TConstParameter(TString *n, TType *t) = delete; TConstParameter(const TString *n, TType *t) = delete; TConstParameter(TString *n, const TType *t) = delete; const TString *name; const TType *type; }; // The function sub-class of symbols and the parser will need to // share this definition of a function parameter. struct TParameter { // Destructively converts to TConstParameter. // This method resets name and type to nullptrs to make sure // their content cannot be modified after the call. TConstParameter turnToConst() { const TString *constName = name; const TType *constType = type; name = nullptr; type = nullptr; return TConstParameter(constName, constType); } TString *name; TType *type; }; // The function sub-class of a symbol. class TFunction : public TSymbol { public: TFunction(const TString *name, const TType *retType, TOperator tOp = EOpNull, const char *ext = "") : TSymbol(name), returnType(retType), mangledName(nullptr), op(tOp), defined(false) { relateToExtension(ext); } virtual ~TFunction(); virtual bool isFunction() const { return true; } static TString mangleName(const TString &name) { return name + '('; } static TString unmangleName(const TString &mangledName) { return TString(mangledName.c_str(), mangledName.find_first_of('(')); } void addParameter(const TConstParameter &p) { parameters.push_back(p); mangledName = nullptr; } const TString &getMangledName() const { if (mangledName == nullptr) { mangledName = buildMangledName(); } return *mangledName; } const TType &getReturnType() const { return *returnType; } TOperator getBuiltInOp() const { return op; } void setDefined() { defined = true; } bool isDefined() { return defined; } size_t getParamCount() const { return parameters.size(); } const TConstParameter &getParam(size_t i) const { return parameters[i]; } private: const TString *buildMangledName() const; typedef TVector TParamList; TParamList parameters; const TType *returnType; mutable const TString *mangledName; TOperator op; bool defined; }; // Interface block name sub-symbol class TInterfaceBlockName : public TSymbol { public: TInterfaceBlockName(const TString *name) : TSymbol(name) { } virtual ~TInterfaceBlockName() { } }; class TSymbolTableLevel { public: typedef TMap tLevel; typedef tLevel::const_iterator const_iterator; typedef const tLevel::value_type tLevelPair; typedef std::pair tInsertResult; TSymbolTableLevel() { } ~TSymbolTableLevel(); bool insert(TSymbol *symbol); // Insert a function using its unmangled name as the key. bool insertUnmangled(TFunction *function); TSymbol *find(const TString &name) const; protected: tLevel level; }; // Define ESymbolLevel as int rather than an enum since level can go // above GLOBAL_LEVEL and cause atBuiltInLevel() to fail if the // compiler optimizes the >= of the last element to ==. typedef int ESymbolLevel; const int COMMON_BUILTINS = 0; const int ESSL1_BUILTINS = 1; const int ESSL3_BUILTINS = 2; const int LAST_BUILTIN_LEVEL = ESSL3_BUILTINS; const int GLOBAL_LEVEL = 3; class TSymbolTable : angle::NonCopyable { public: TSymbolTable() : mGlobalInvariant(false) { // The symbol table cannot be used until push() is called, but // the lack of an initial call to push() can be used to detect // that the symbol table has not been preloaded with built-ins. } ~TSymbolTable(); // When the symbol table is initialized with the built-ins, there should // 'push' calls, so that built-ins are at level 0 and the shader // globals are at level 1. bool isEmpty() const { return table.empty(); } bool atBuiltInLevel() const { return currentLevel() <= LAST_BUILTIN_LEVEL; } bool atGlobalLevel() const { return currentLevel() <= GLOBAL_LEVEL; } void push() { table.push_back(new TSymbolTableLevel); precisionStack.push_back(new PrecisionStackLevel); } void pop() { delete table.back(); table.pop_back(); delete precisionStack.back(); precisionStack.pop_back(); } bool declare(TSymbol *symbol) { return insert(currentLevel(), symbol); } bool insert(ESymbolLevel level, TSymbol *symbol) { return table[level]->insert(symbol); } bool insert(ESymbolLevel level, const char *ext, TSymbol *symbol) { symbol->relateToExtension(ext); return table[level]->insert(symbol); } bool insertConstInt(ESymbolLevel level, const char *name, int value) { TVariable *constant = new TVariable( NewPoolTString(name), TType(EbtInt, EbpUndefined, EvqConst, 1)); constant->getConstPointer()->setIConst(value); return insert(level, constant); } bool insertConstIntExt(ESymbolLevel level, const char *ext, const char *name, int value) { TVariable *constant = new TVariable(NewPoolTString(name), TType(EbtInt, EbpUndefined, EvqConst, 1)); constant->getConstPointer()->setIConst(value); return insert(level, ext, constant); } void insertBuiltIn(ESymbolLevel level, TOperator op, const char *ext, const TType *rvalue, const char *name, const TType *ptype1, const TType *ptype2 = 0, const TType *ptype3 = 0, const TType *ptype4 = 0, const TType *ptype5 = 0); void insertBuiltIn(ESymbolLevel level, const TType *rvalue, const char *name, const TType *ptype1, const TType *ptype2 = 0, const TType *ptype3 = 0, const TType *ptype4 = 0, const TType *ptype5 = 0) { insertBuiltIn(level, EOpNull, "", rvalue, name, ptype1, ptype2, ptype3, ptype4, ptype5); } void insertBuiltIn(ESymbolLevel level, const char *ext, const TType *rvalue, const char *name, const TType *ptype1, const TType *ptype2 = 0, const TType *ptype3 = 0, const TType *ptype4 = 0, const TType *ptype5 = 0) { insertBuiltIn(level, EOpNull, ext, rvalue, name, ptype1, ptype2, ptype3, ptype4, ptype5); } void insertBuiltIn(ESymbolLevel level, TOperator op, const TType *rvalue, const char *name, const TType *ptype1, const TType *ptype2 = 0, const TType *ptype3 = 0, const TType *ptype4 = 0, const TType *ptype5 = 0) { insertBuiltIn(level, op, "", rvalue, name, ptype1, ptype2, ptype3, ptype4, ptype5); } TSymbol *find(const TString &name, int shaderVersion, bool *builtIn = NULL, bool *sameScope = NULL) const; TSymbol *findBuiltIn(const TString &name, int shaderVersion) const; TSymbolTableLevel *getOuterLevel() { assert(currentLevel() >= 1); return table[currentLevel() - 1]; } void dump(TInfoSink &infoSink) const; bool setDefaultPrecision(const TPublicType &type, TPrecision prec) { if (!SupportsPrecision(type.type)) return false; if (type.isAggregate()) return false; // Not allowed to set for aggregate types int indexOfLastElement = static_cast(precisionStack.size()) - 1; // Uses map operator [], overwrites the current value (*precisionStack[indexOfLastElement])[type.type] = prec; return true; } // Searches down the precisionStack for a precision qualifier // for the specified TBasicType TPrecision getDefaultPrecision(TBasicType type) const; // This records invariant varyings declared through // "invariant varying_name;". void addInvariantVarying(const std::string &originalName) { mInvariantVaryings.insert(originalName); } // If this returns false, the varying could still be invariant // if it is set as invariant during the varying variable // declaration - this piece of information is stored in the // variable's type, not here. bool isVaryingInvariant(const std::string &originalName) const { return (mGlobalInvariant || mInvariantVaryings.count(originalName) > 0); } void setGlobalInvariant() { mGlobalInvariant = true; } bool getGlobalInvariant() const { return mGlobalInvariant; } static int nextUniqueId() { return ++uniqueIdCounter; } private: ESymbolLevel currentLevel() const { return static_cast(table.size() - 1); } std::vector table; typedef TMap PrecisionStackLevel; std::vector< PrecisionStackLevel *> precisionStack; std::set mInvariantVaryings; bool mGlobalInvariant; static int uniqueIdCounter; }; #endif // COMPILER_TRANSLATOR_SYMBOLTABLE_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/TranslatorGLSL.cpp000066400000000000000000000065571321746453100302600ustar00rootroot00000000000000// // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/TranslatorGLSL.h" #include "angle_gl.h" #include "compiler/translator/BuiltInFunctionEmulatorGLSL.h" #include "compiler/translator/EmulatePrecision.h" #include "compiler/translator/OutputGLSL.h" #include "compiler/translator/VersionGLSL.h" TranslatorGLSL::TranslatorGLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output) : TCompiler(type, spec, output) { } void TranslatorGLSL::initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu, int compileOptions) { int targetGLSLVersion = ShaderOutputTypeToGLSLVersion(getOutputType()); InitBuiltInFunctionEmulatorForGLSLMissingFunctions(emu, getShaderType(), targetGLSLVersion); } void TranslatorGLSL::translate(TIntermNode *root, int) { TInfoSinkBase& sink = getInfoSink().obj; // Write GLSL version. writeVersion(root); writePragma(); // Write extension behaviour as needed writeExtensionBehavior(); bool precisionEmulation = getResources().WEBGL_debug_shader_precision && getPragma().debugShaderPrecision; if (precisionEmulation) { EmulatePrecision emulatePrecision(getSymbolTable(), getShaderVersion()); root->traverse(&emulatePrecision); emulatePrecision.updateTree(); emulatePrecision.writeEmulationHelpers(sink, getOutputType()); } // Write emulated built-in functions if needed. if (!getBuiltInFunctionEmulator().IsOutputEmpty()) { sink << "// BEGIN: Generated code for built-in function emulation\n\n"; sink << "#define webgl_emu_precision\n\n"; getBuiltInFunctionEmulator().OutputEmulatedFunctions(sink); sink << "// END: Generated code for built-in function emulation\n\n"; } // Write translated shader. TOutputGLSL outputGLSL(sink, getHashFunction(), getNameMap(), getSymbolTable(), getShaderVersion(), getOutputType()); root->traverse(&outputGLSL); } void TranslatorGLSL::writeVersion(TIntermNode *root) { TVersionGLSL versionGLSL(getShaderType(), getPragma(), getOutputType()); root->traverse(&versionGLSL); int version = versionGLSL.getVersion(); // We need to write version directive only if it is greater than 110. // If there is no version directive in the shader, 110 is implied. if (version > 110) { TInfoSinkBase& sink = getInfoSink().obj; sink << "#version " << version << "\n"; } } void TranslatorGLSL::writeExtensionBehavior() { TInfoSinkBase& sink = getInfoSink().obj; const TExtensionBehavior& extBehavior = getExtensionBehavior(); for (TExtensionBehavior::const_iterator iter = extBehavior.begin(); iter != extBehavior.end(); ++iter) { if (iter->second == EBhUndefined) continue; // For GLSL output, we don't need to emit most extensions explicitly, // but some we need to translate. if (iter->first == "GL_EXT_shader_texture_lod") { sink << "#extension GL_ARB_shader_texture_lod : " << getBehaviorString(iter->second) << "\n"; } } } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/TranslatorGLSL.h000066400000000000000000000014071321746453100277120ustar00rootroot00000000000000// // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_TRANSLATORGLSL_H_ #define COMPILER_TRANSLATOR_TRANSLATORGLSL_H_ #include "compiler/translator/Compiler.h" class TranslatorGLSL : public TCompiler { public: TranslatorGLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output); protected: void initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu, int compileOptions) override; void translate(TIntermNode *root, int compileOptions) override; private: void writeVersion(TIntermNode *root); void writeExtensionBehavior(); }; #endif // COMPILER_TRANSLATOR_TRANSLATORGLSL_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/Types.cpp000066400000000000000000000165601321746453100265440ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #if defined(_MSC_VER) #pragma warning(disable: 4718) #endif #include "compiler/translator/Types.h" #include #include const char* getBasicString(TBasicType t) { switch (t) { case EbtVoid: return "void"; break; case EbtFloat: return "float"; break; case EbtInt: return "int"; break; case EbtUInt: return "uint"; break; case EbtBool: return "bool"; break; case EbtSampler2D: return "sampler2D"; break; case EbtSampler3D: return "sampler3D"; break; case EbtSamplerCube: return "samplerCube"; break; case EbtSamplerExternalOES: return "samplerExternalOES"; break; case EbtSampler2DRect: return "sampler2DRect"; break; case EbtSampler2DArray: return "sampler2DArray"; break; case EbtISampler2D: return "isampler2D"; break; case EbtISampler3D: return "isampler3D"; break; case EbtISamplerCube: return "isamplerCube"; break; case EbtISampler2DArray: return "isampler2DArray"; break; case EbtUSampler2D: return "usampler2D"; break; case EbtUSampler3D: return "usampler3D"; break; case EbtUSamplerCube: return "usamplerCube"; break; case EbtUSampler2DArray: return "usampler2DArray"; break; case EbtSampler2DShadow: return "sampler2DShadow"; break; case EbtSamplerCubeShadow: return "samplerCubeShadow"; break; case EbtSampler2DArrayShadow: return "sampler2DArrayShadow"; break; case EbtStruct: return "structure"; break; case EbtInterfaceBlock: return "interface block"; break; default: UNREACHABLE(); return "unknown type"; } } TType::TType(const TPublicType &p) : type(p.type), precision(p.precision), qualifier(p.qualifier), invariant(p.invariant), layoutQualifier(p.layoutQualifier), primarySize(p.primarySize), secondarySize(p.secondarySize), array(p.array), arraySize(p.arraySize), interfaceBlock(0), structure(0) { if (p.userDef) structure = p.userDef->getStruct(); } bool TStructure::equals(const TStructure &other) const { return (uniqueId() == other.uniqueId()); } // // Recursively generate mangled names. // TString TType::buildMangledName() const { TString mangledName; if (isMatrix()) mangledName += 'm'; else if (isVector()) mangledName += 'v'; switch (type) { case EbtFloat: mangledName += 'f'; break; case EbtInt: mangledName += 'i'; break; case EbtUInt: mangledName += 'u'; break; case EbtBool: mangledName += 'b'; break; case EbtSampler2D: mangledName += "s2"; break; case EbtSampler3D: mangledName += "s3"; break; case EbtSamplerCube: mangledName += "sC"; break; case EbtSampler2DArray: mangledName += "s2a"; break; case EbtSamplerExternalOES: mangledName += "sext"; break; case EbtSampler2DRect: mangledName += "s2r"; break; case EbtISampler2D: mangledName += "is2"; break; case EbtISampler3D: mangledName += "is3"; break; case EbtISamplerCube: mangledName += "isC"; break; case EbtISampler2DArray: mangledName += "is2a"; break; case EbtUSampler2D: mangledName += "us2"; break; case EbtUSampler3D: mangledName += "us3"; break; case EbtUSamplerCube: mangledName += "usC"; break; case EbtUSampler2DArray: mangledName += "us2a"; break; case EbtSampler2DShadow: mangledName += "s2s"; break; case EbtSamplerCubeShadow: mangledName += "sCs"; break; case EbtSampler2DArrayShadow: mangledName += "s2as"; break; case EbtStruct: mangledName += structure->mangledName(); break; case EbtInterfaceBlock: mangledName += interfaceBlock->mangledName(); break; default: // EbtVoid, EbtAddress and non types break; } if (isMatrix()) { mangledName += static_cast('0' + getCols()); mangledName += static_cast('x'); mangledName += static_cast('0' + getRows()); } else { mangledName += static_cast('0' + getNominalSize()); } if (isArray()) { char buf[20]; snprintf(buf, sizeof(buf), "%d", arraySize); mangledName += '['; mangledName += buf; mangledName += ']'; } return mangledName; } size_t TType::getObjectSize() const { size_t totalSize; if (getBasicType() == EbtStruct) totalSize = structure->objectSize(); else totalSize = primarySize * secondarySize; if (isArray()) { // TODO: getArraySize() returns an int, not a size_t size_t currentArraySize = getArraySize(); if (currentArraySize > INT_MAX / totalSize) totalSize = INT_MAX; else totalSize *= currentArraySize; } return totalSize; } bool TStructure::containsArrays() const { for (size_t i = 0; i < mFields->size(); ++i) { const TType *fieldType = (*mFields)[i]->type(); if (fieldType->isArray() || fieldType->isStructureContainingArrays()) return true; } return false; } bool TStructure::containsType(TBasicType type) const { for (size_t i = 0; i < mFields->size(); ++i) { const TType *fieldType = (*mFields)[i]->type(); if (fieldType->getBasicType() == type || fieldType->isStructureContainingType(type)) return true; } return false; } bool TStructure::containsSamplers() const { for (size_t i = 0; i < mFields->size(); ++i) { const TType *fieldType = (*mFields)[i]->type(); if (IsSampler(fieldType->getBasicType()) || fieldType->isStructureContainingSamplers()) return true; } return false; } TString TFieldListCollection::buildMangledName() const { TString mangledName(mangledNamePrefix()); mangledName += *mName; for (size_t i = 0; i < mFields->size(); ++i) { mangledName += '-'; mangledName += (*mFields)[i]->type()->getMangledName(); } return mangledName; } size_t TFieldListCollection::calculateObjectSize() const { size_t size = 0; for (size_t i = 0; i < mFields->size(); ++i) { size_t fieldSize = (*mFields)[i]->type()->getObjectSize(); if (fieldSize > INT_MAX - size) size = INT_MAX; else size += fieldSize; } return size; } int TStructure::calculateDeepestNesting() const { int maxNesting = 0; for (size_t i = 0; i < mFields->size(); ++i) maxNesting = std::max(maxNesting, (*mFields)[i]->type()->getDeepestStructNesting()); return 1 + maxNesting; } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/Types.h000066400000000000000000000363671321746453100262200ustar00rootroot00000000000000// // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_TYPES_H_ #define COMPILER_TRANSLATOR_TYPES_H_ #include "common/angleutils.h" #include "common/debug.h" #include "compiler/translator/BaseTypes.h" #include "compiler/translator/Common.h" struct TPublicType; class TType; class TSymbol; class TField : angle::NonCopyable { public: POOL_ALLOCATOR_NEW_DELETE(); TField(TType *type, TString *name, const TSourceLoc &line) : mType(type), mName(name), mLine(line) { } // TODO(alokp): We should only return const type. // Fix it by tweaking grammar. TType *type() { return mType; } const TType *type() const { return mType; } const TString &name() const { return *mName; } const TSourceLoc &line() const { return mLine; } private: TType *mType; TString *mName; TSourceLoc mLine; }; typedef TVector TFieldList; inline TFieldList *NewPoolTFieldList() { void *memory = GetGlobalPoolAllocator()->allocate(sizeof(TFieldList)); return new(memory) TFieldList; } class TFieldListCollection : angle::NonCopyable { public: const TString &name() const { return *mName; } const TFieldList &fields() const { return *mFields; } const TString &mangledName() const { if (mMangledName.empty()) mMangledName = buildMangledName(); return mMangledName; } size_t objectSize() const { if (mObjectSize == 0) mObjectSize = calculateObjectSize(); return mObjectSize; }; protected: TFieldListCollection(const TString *name, TFieldList *fields) : mName(name), mFields(fields), mObjectSize(0) { } TString buildMangledName() const; size_t calculateObjectSize() const; virtual TString mangledNamePrefix() const = 0; const TString *mName; TFieldList *mFields; mutable TString mMangledName; mutable size_t mObjectSize; }; // May also represent interface blocks class TStructure : public TFieldListCollection { public: POOL_ALLOCATOR_NEW_DELETE(); TStructure(const TString *name, TFieldList *fields) : TFieldListCollection(name, fields), mDeepestNesting(0), mUniqueId(0), mAtGlobalScope(false) { } int deepestNesting() const { if (mDeepestNesting == 0) mDeepestNesting = calculateDeepestNesting(); return mDeepestNesting; } bool containsArrays() const; bool containsType(TBasicType t) const; bool containsSamplers() const; bool equals(const TStructure &other) const; void setUniqueId(int uniqueId) { mUniqueId = uniqueId; } int uniqueId() const { ASSERT(mUniqueId != 0); return mUniqueId; } void setAtGlobalScope(bool atGlobalScope) { mAtGlobalScope = atGlobalScope; } bool atGlobalScope() const { return mAtGlobalScope; } private: // TODO(zmo): Find a way to get rid of the const_cast in function // setName(). void setName(const TString &name) { TString *mutableName = const_cast(mName); *mutableName = name; } virtual TString mangledNamePrefix() const { return "struct-"; } int calculateDeepestNesting() const; mutable int mDeepestNesting; int mUniqueId; bool mAtGlobalScope; }; class TInterfaceBlock : public TFieldListCollection { public: POOL_ALLOCATOR_NEW_DELETE(); TInterfaceBlock(const TString *name, TFieldList *fields, const TString *instanceName, int arraySize, const TLayoutQualifier &layoutQualifier) : TFieldListCollection(name, fields), mInstanceName(instanceName), mArraySize(arraySize), mBlockStorage(layoutQualifier.blockStorage), mMatrixPacking(layoutQualifier.matrixPacking) { } const TString &instanceName() const { return *mInstanceName; } bool hasInstanceName() const { return mInstanceName != NULL; } bool isArray() const { return mArraySize > 0; } int arraySize() const { return mArraySize; } TLayoutBlockStorage blockStorage() const { return mBlockStorage; } TLayoutMatrixPacking matrixPacking() const { return mMatrixPacking; } private: virtual TString mangledNamePrefix() const { return "iblock-"; } const TString *mInstanceName; // for interface block instance names int mArraySize; // 0 if not an array TLayoutBlockStorage mBlockStorage; TLayoutMatrixPacking mMatrixPacking; }; // // Base class for things that have a type. // class TType { public: POOL_ALLOCATOR_NEW_DELETE(); TType() : type(EbtVoid), precision(EbpUndefined), qualifier(EvqGlobal), invariant(false), layoutQualifier(TLayoutQualifier::create()), primarySize(0), secondarySize(0), array(false), arraySize(0), interfaceBlock(nullptr), structure(nullptr) { } TType(TBasicType t, unsigned char ps = 1, unsigned char ss = 1) : type(t), precision(EbpUndefined), qualifier(EvqGlobal), invariant(false), layoutQualifier(TLayoutQualifier::create()), primarySize(ps), secondarySize(ss), array(false), arraySize(0), interfaceBlock(0), structure(0) { } TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, unsigned char ps = 1, unsigned char ss = 1, bool a = false) : type(t), precision(p), qualifier(q), invariant(false), layoutQualifier(TLayoutQualifier::create()), primarySize(ps), secondarySize(ss), array(a), arraySize(0), interfaceBlock(0), structure(0) { } explicit TType(const TPublicType &p); TType(TStructure *userDef, TPrecision p = EbpUndefined) : type(EbtStruct), precision(p), qualifier(EvqTemporary), invariant(false), layoutQualifier(TLayoutQualifier::create()), primarySize(1), secondarySize(1), array(false), arraySize(0), interfaceBlock(0), structure(userDef) { } TType(TInterfaceBlock *interfaceBlockIn, TQualifier qualifierIn, TLayoutQualifier layoutQualifierIn, int arraySizeIn) : type(EbtInterfaceBlock), precision(EbpUndefined), qualifier(qualifierIn), invariant(false), layoutQualifier(layoutQualifierIn), primarySize(1), secondarySize(1), array(arraySizeIn > 0), arraySize(arraySizeIn), interfaceBlock(interfaceBlockIn), structure(0) { } TBasicType getBasicType() const { return type; } void setBasicType(TBasicType t) { type = t; } TPrecision getPrecision() const { return precision; } void setPrecision(TPrecision p) { precision = p; } TQualifier getQualifier() const { return qualifier; } void setQualifier(TQualifier q) { qualifier = q; } bool isInvariant() const { return invariant; } TLayoutQualifier getLayoutQualifier() const { return layoutQualifier; } void setLayoutQualifier(TLayoutQualifier lq) { layoutQualifier = lq; } int getNominalSize() const { return primarySize; } int getSecondarySize() const { return secondarySize; } int getCols() const { ASSERT(isMatrix()); return primarySize; } int getRows() const { ASSERT(isMatrix()); return secondarySize; } void setPrimarySize(unsigned char ps) { primarySize = ps; } void setSecondarySize(unsigned char ss) { secondarySize = ss; } // Full size of single instance of type size_t getObjectSize() const; bool isMatrix() const { return primarySize > 1 && secondarySize > 1; } bool isNonSquareMatrix() const { return isMatrix() && primarySize != secondarySize; } bool isArray() const { return array; } bool isUnsizedArray() const { return array && arraySize == 0; } int getArraySize() const { return arraySize; } void setArraySize(int s) { array = true; arraySize = s; } void clearArrayness() { array = false; arraySize = 0; } TInterfaceBlock *getInterfaceBlock() const { return interfaceBlock; } void setInterfaceBlock(TInterfaceBlock *interfaceBlockIn) { interfaceBlock = interfaceBlockIn; } bool isInterfaceBlock() const { return type == EbtInterfaceBlock; } bool isVector() const { return primarySize > 1 && secondarySize == 1; } bool isScalar() const { return primarySize == 1 && secondarySize == 1 && !structure; } bool isScalarInt() const { return isScalar() && (type == EbtInt || type == EbtUInt); } TStructure *getStruct() const { return structure; } void setStruct(TStructure *s) { structure = s; } const TString &getMangledName() const { if (mangled.empty()) { mangled = buildMangledName(); mangled += ';'; } return mangled; } bool sameElementType(const TType &right) const { return type == right.type && primarySize == right.primarySize && secondarySize == right.secondarySize && structure == right.structure; } bool operator==(const TType &right) const { return type == right.type && primarySize == right.primarySize && secondarySize == right.secondarySize && array == right.array && (!array || arraySize == right.arraySize) && structure == right.structure; // don't check the qualifier, it's not ever what's being sought after } bool operator!=(const TType &right) const { return !operator==(right); } bool operator<(const TType &right) const { if (type != right.type) return type < right.type; if (primarySize != right.primarySize) return primarySize < right.primarySize; if (secondarySize != right.secondarySize) return secondarySize < right.secondarySize; if (array != right.array) return array < right.array; if (arraySize != right.arraySize) return arraySize < right.arraySize; if (structure != right.structure) return structure < right.structure; return false; } const char *getBasicString() const { return ::getBasicString(type); } const char *getPrecisionString() const { return ::getPrecisionString(precision); } const char *getQualifierString() const { return ::getQualifierString(qualifier); } TString getCompleteString() const; // If this type is a struct, returns the deepest struct nesting of // any field in the struct. For example: // struct nesting1 { // vec4 position; // }; // struct nesting2 { // nesting1 field1; // vec4 field2; // }; // For type "nesting2", this method would return 2 -- the number // of structures through which indirection must occur to reach the // deepest field (nesting2.field1.position). int getDeepestStructNesting() const { return structure ? structure->deepestNesting() : 0; } bool isStructureContainingArrays() const { return structure ? structure->containsArrays() : false; } bool isStructureContainingType(TBasicType t) const { return structure ? structure->containsType(t) : false; } bool isStructureContainingSamplers() const { return structure ? structure->containsSamplers() : false; } // Initializes all lazily-initialized members. void realize() { getMangledName(); } protected: TString buildMangledName() const; size_t getStructSize() const; TBasicType type; TPrecision precision; TQualifier qualifier; bool invariant; TLayoutQualifier layoutQualifier; unsigned char primarySize; // size of vector or cols matrix unsigned char secondarySize; // rows of a matrix bool array; int arraySize; // 0 unless this is an interface block, or interface block member variable TInterfaceBlock *interfaceBlock; // 0 unless this is a struct TStructure *structure; mutable TString mangled; }; // // This is a workaround for a problem with the yacc stack, It can't have // types that it thinks have non-trivial constructors. It should // just be used while recognizing the grammar, not anything else. Pointers // could be used, but also trying to avoid lots of memory management overhead. // // Not as bad as it looks, there is no actual assumption that the fields // match up or are name the same or anything like that. // struct TPublicType { TBasicType type; TLayoutQualifier layoutQualifier; TQualifier qualifier; bool invariant; TPrecision precision; unsigned char primarySize; // size of vector or cols of matrix unsigned char secondarySize; // rows of matrix bool array; int arraySize; TType *userDef; TSourceLoc line; void setBasic(TBasicType bt, TQualifier q, const TSourceLoc &ln) { type = bt; layoutQualifier = TLayoutQualifier::create(); qualifier = q; invariant = false; precision = EbpUndefined; primarySize = 1; secondarySize = 1; array = false; arraySize = 0; userDef = 0; line = ln; } void setAggregate(unsigned char size) { primarySize = size; } void setMatrix(unsigned char c, unsigned char r) { ASSERT(c > 1 && r > 1 && c <= 4 && r <= 4); primarySize = c; secondarySize = r; } bool isUnsizedArray() const { return array && arraySize == 0; } void setArraySize(int s) { array = true; arraySize = s; } void clearArrayness() { array = false; arraySize = 0; } bool isStructureContainingArrays() const { if (!userDef) { return false; } return userDef->isStructureContainingArrays(); } bool isStructureContainingType(TBasicType t) const { if (!userDef) { return false; } return userDef->isStructureContainingType(t); } bool isMatrix() const { return primarySize > 1 && secondarySize > 1; } bool isVector() const { return primarySize > 1 && secondarySize == 1; } int getCols() const { ASSERT(isMatrix()); return primarySize; } int getRows() const { ASSERT(isMatrix()); return secondarySize; } int getNominalSize() const { return primarySize; } bool isAggregate() const { return array || isMatrix() || isVector(); } }; #endif // COMPILER_TRANSLATOR_TYPES_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/ValidateGlobalInitializer.cpp000066400000000000000000000063111321746453100325070ustar00rootroot00000000000000// // Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/ValidateGlobalInitializer.h" #include "compiler/translator/ParseContext.h" namespace { class ValidateGlobalInitializerTraverser : public TIntermTraverser { public: ValidateGlobalInitializerTraverser(const TParseContext *context); void visitSymbol(TIntermSymbol *node) override; bool visitAggregate(Visit visit, TIntermAggregate *node) override; bool visitBinary(Visit visit, TIntermBinary *node) override; bool visitUnary(Visit visit, TIntermUnary *node) override; bool isValid() const { return mIsValid; } bool issueWarning() const { return mIssueWarning; } private: const TParseContext *mContext; bool mIsValid; bool mIssueWarning; }; void ValidateGlobalInitializerTraverser::visitSymbol(TIntermSymbol *node) { const TSymbol *sym = mContext->symbolTable.find(node->getSymbol(), mContext->getShaderVersion()); if (sym->isVariable()) { // ESSL 1.00 section 4.3 (or ESSL 3.00 section 4.3): // Global initializers must be constant expressions. const TVariable *var = static_cast(sym); switch (var->getType().getQualifier()) { case EvqConst: break; case EvqGlobal: case EvqTemporary: case EvqUniform: // We allow these cases to be compatible with legacy ESSL 1.00 content. // Implement stricter rules for ESSL 3.00 since there's no legacy content to deal with. if (mContext->getShaderVersion() >= 300) { mIsValid = false; } else { mIssueWarning = true; } break; default: mIsValid = false; } } } bool ValidateGlobalInitializerTraverser::visitAggregate(Visit visit, TIntermAggregate *node) { // Disallow calls to user-defined functions and texture lookup functions in global variable initializers. // This is done simply by disabling all function calls - built-in math functions don't use EOpFunctionCall. if (node->getOp() == EOpFunctionCall) { mIsValid = false; } return true; } bool ValidateGlobalInitializerTraverser::visitBinary(Visit visit, TIntermBinary *node) { if (node->isAssignment()) { mIsValid = false; } return true; } bool ValidateGlobalInitializerTraverser::visitUnary(Visit visit, TIntermUnary *node) { if (node->isAssignment()) { mIsValid = false; } return true; } ValidateGlobalInitializerTraverser::ValidateGlobalInitializerTraverser(const TParseContext *context) : TIntermTraverser(true, false, false), mContext(context), mIsValid(true), mIssueWarning(false) { } } // namespace bool ValidateGlobalInitializer(TIntermTyped *initializer, const TParseContext *context, bool *warning) { ValidateGlobalInitializerTraverser validate(context); initializer->traverse(&validate); ASSERT(warning != nullptr); *warning = validate.issueWarning(); return validate.isValid(); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/ValidateGlobalInitializer.h000066400000000000000000000010501321746453100321470ustar00rootroot00000000000000// // Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_VALIDATEGLOBALINITIALIZER_H_ #define COMPILER_TRANSLATOR_VALIDATEGLOBALINITIALIZER_H_ class TIntermTyped; class TParseContext; // Returns true if the initializer is valid. bool ValidateGlobalInitializer(TIntermTyped *initializer, const TParseContext *context, bool *warning); #endif // COMPILER_TRANSLATOR_VALIDATEGLOBALINITIALIZER_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/ValidateOutputs.cpp000066400000000000000000000067001321746453100305700ustar00rootroot00000000000000// // Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/ValidateOutputs.h" #include "compiler/translator/InfoSink.h" #include "compiler/translator/InitializeParseContext.h" #include "compiler/translator/ParseContext.h" namespace { void error(int *errorCount, TInfoSinkBase &sink, const TIntermSymbol &symbol, const char *reason) { sink.prefix(EPrefixError); sink.location(symbol.getLine()); sink << "'" << symbol.getSymbol() << "' : " << reason << "\n"; (*errorCount)++; } } // namespace ValidateOutputs::ValidateOutputs(const TExtensionBehavior &extBehavior, int maxDrawBuffers) : TIntermTraverser(true, false, false), mMaxDrawBuffers(maxDrawBuffers), mAllowUnspecifiedOutputLocationResolution( IsExtensionEnabled(extBehavior, "GL_EXT_blend_func_extended")) { } void ValidateOutputs::visitSymbol(TIntermSymbol *symbol) { TString name = symbol->getSymbol(); TQualifier qualifier = symbol->getQualifier(); if (mVisitedSymbols.count(name) == 1) return; mVisitedSymbols.insert(name); if (qualifier == EvqFragmentOut) { if (symbol->getType().getLayoutQualifier().location == -1) { mUnspecifiedLocationOutputs.push_back(symbol); } else { mOutputs.push_back(symbol); } } } int ValidateOutputs::validateAndCountErrors(TInfoSinkBase &sink) const { OutputVector validOutputs(mMaxDrawBuffers); int errorCount = 0; for (const auto &symbol : mOutputs) { const TType &type = symbol->getType(); const size_t elementCount = static_cast(type.isArray() ? type.getArraySize() : 1); const size_t location = static_cast(type.getLayoutQualifier().location); ASSERT(type.getLayoutQualifier().location != -1); if (location + elementCount <= validOutputs.size()) { for (size_t elementIndex = 0; elementIndex < elementCount; elementIndex++) { const size_t offsetLocation = location + elementIndex; if (validOutputs[offsetLocation]) { std::stringstream strstr; strstr << "conflicting output locations with previously defined output '" << validOutputs[offsetLocation]->getSymbol() << "'"; error(&errorCount, sink, *symbol, strstr.str().c_str()); } else { validOutputs[offsetLocation] = symbol; } } } else { if (elementCount > 0) { error(&errorCount, sink, *symbol, elementCount > 1 ? "output array locations would exceed MAX_DRAW_BUFFERS" : "output location must be < MAX_DRAW_BUFFERS"); } } } if (!mAllowUnspecifiedOutputLocationResolution && ((!mOutputs.empty() && !mUnspecifiedLocationOutputs.empty()) || mUnspecifiedLocationOutputs.size() > 1)) { for (const auto &symbol : mUnspecifiedLocationOutputs) { error(&errorCount, sink, *symbol, "must explicitly specify all locations when using multiple fragment outputs"); } } return errorCount; } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/ValidateOutputs.h000066400000000000000000000017071321746453100302370ustar00rootroot00000000000000// // Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_VALIDATEOUTPUTS_H_ #define COMPILER_TRANSLATOR_VALIDATEOUTPUTS_H_ #include "compiler/translator/ExtensionBehavior.h" #include "compiler/translator/IntermNode.h" #include class TInfoSinkBase; class ValidateOutputs : public TIntermTraverser { public: ValidateOutputs(const TExtensionBehavior &extBehavior, int maxDrawBuffers); int validateAndCountErrors(TInfoSinkBase &sink) const; virtual void visitSymbol(TIntermSymbol*); private: int mMaxDrawBuffers; bool mAllowUnspecifiedOutputLocationResolution; typedef std::vector OutputVector; OutputVector mOutputs; OutputVector mUnspecifiedLocationOutputs; std::set mVisitedSymbols; }; #endif // COMPILER_TRANSLATOR_VALIDATEOUTPUTS_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/ValidateSwitch.cpp000066400000000000000000000133131321746453100303440ustar00rootroot00000000000000// // Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/ValidateSwitch.h" #include "compiler/translator/ParseContext.h" bool ValidateSwitch::validate(TBasicType switchType, TParseContext *context, TIntermAggregate *statementList, const TSourceLoc &loc) { ValidateSwitch validate(switchType, context); ASSERT(statementList); statementList->traverse(&validate); return validate.validateInternal(loc); } ValidateSwitch::ValidateSwitch(TBasicType switchType, TParseContext *context) : TIntermTraverser(true, false, true), mSwitchType(switchType), mContext(context), mCaseTypeMismatch(false), mFirstCaseFound(false), mStatementBeforeCase(false), mLastStatementWasCase(false), mControlFlowDepth(0), mCaseInsideControlFlow(false), mDefaultCount(0), mDuplicateCases(false) {} void ValidateSwitch::visitSymbol(TIntermSymbol *) { if (!mFirstCaseFound) mStatementBeforeCase = true; mLastStatementWasCase = false; } void ValidateSwitch::visitConstantUnion(TIntermConstantUnion *) { // Conditions of case labels are not traversed, so this is some other constant // Could be just a statement like "0;" if (!mFirstCaseFound) mStatementBeforeCase = true; mLastStatementWasCase = false; } bool ValidateSwitch::visitBinary(Visit, TIntermBinary *) { if (!mFirstCaseFound) mStatementBeforeCase = true; mLastStatementWasCase = false; return true; } bool ValidateSwitch::visitUnary(Visit, TIntermUnary *) { if (!mFirstCaseFound) mStatementBeforeCase = true; mLastStatementWasCase = false; return true; } bool ValidateSwitch::visitSelection(Visit visit, TIntermSelection *) { if (visit == PreVisit) ++mControlFlowDepth; if (visit == PostVisit) --mControlFlowDepth; if (!mFirstCaseFound) mStatementBeforeCase = true; mLastStatementWasCase = false; return true; } bool ValidateSwitch::visitSwitch(Visit, TIntermSwitch *) { if (!mFirstCaseFound) mStatementBeforeCase = true; mLastStatementWasCase = false; // Don't go into nested switch statements return false; } bool ValidateSwitch::visitCase(Visit, TIntermCase *node) { const char *nodeStr = node->hasCondition() ? "case" : "default"; if (mControlFlowDepth > 0) { mContext->error(node->getLine(), "label statement nested inside control flow", nodeStr); mCaseInsideControlFlow = true; } mFirstCaseFound = true; mLastStatementWasCase = true; if (!node->hasCondition()) { ++mDefaultCount; if (mDefaultCount > 1) { mContext->error(node->getLine(), "duplicate default label", nodeStr); } } else { TIntermConstantUnion *condition = node->getCondition()->getAsConstantUnion(); if (condition == nullptr) { // This can happen in error cases. return false; } TBasicType conditionType = condition->getBasicType(); if (conditionType != mSwitchType) { mContext->error(condition->getLine(), "case label type does not match switch init-expression type", nodeStr); mCaseTypeMismatch = true; } if (conditionType == EbtInt) { int iConst = condition->getIConst(0); if (mCasesSigned.find(iConst) != mCasesSigned.end()) { mContext->error(condition->getLine(), "duplicate case label", nodeStr); mDuplicateCases = true; } else { mCasesSigned.insert(iConst); } } else if (conditionType == EbtUInt) { unsigned int uConst = condition->getUConst(0); if (mCasesUnsigned.find(uConst) != mCasesUnsigned.end()) { mContext->error(condition->getLine(), "duplicate case label", nodeStr); mDuplicateCases = true; } else { mCasesUnsigned.insert(uConst); } } // Other types are possible only in error cases, where the error has already been generated // when parsing the case statement. } // Don't traverse the condition of the case statement return false; } bool ValidateSwitch::visitAggregate(Visit visit, TIntermAggregate *) { if (getParentNode() != nullptr) { // This is not the statementList node, but some other node. if (!mFirstCaseFound) mStatementBeforeCase = true; mLastStatementWasCase = false; } return true; } bool ValidateSwitch::visitLoop(Visit visit, TIntermLoop *) { if (visit == PreVisit) ++mControlFlowDepth; if (visit == PostVisit) --mControlFlowDepth; if (!mFirstCaseFound) mStatementBeforeCase = true; mLastStatementWasCase = false; return true; } bool ValidateSwitch::visitBranch(Visit, TIntermBranch *) { if (!mFirstCaseFound) mStatementBeforeCase = true; mLastStatementWasCase = false; return true; } bool ValidateSwitch::validateInternal(const TSourceLoc &loc) { if (mStatementBeforeCase) { mContext->error(loc, "statement before the first label", "switch"); } if (mLastStatementWasCase) { mContext->error(loc, "no statement between the last label and the end of the switch statement", "switch"); } return !mStatementBeforeCase && !mLastStatementWasCase && !mCaseInsideControlFlow && !mCaseTypeMismatch && mDefaultCount <= 1 && !mDuplicateCases; } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/ValidateSwitch.h000066400000000000000000000033611321746453100300130ustar00rootroot00000000000000// // Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_VALIDATESWITCH_H_ #define COMPILER_TRANSLATOR_VALIDATESWITCH_H_ #include "compiler/translator/IntermNode.h" class TParseContext; class ValidateSwitch : public TIntermTraverser { public: // Check for errors and output messages any remaining errors on the context. // Returns true if there are no errors. static bool validate(TBasicType switchType, TParseContext *context, TIntermAggregate *statementList, const TSourceLoc &loc); void visitSymbol(TIntermSymbol *) override; void visitConstantUnion(TIntermConstantUnion *) override; bool visitBinary(Visit, TIntermBinary *) override; bool visitUnary(Visit, TIntermUnary *) override; bool visitSelection(Visit visit, TIntermSelection *) override; bool visitSwitch(Visit, TIntermSwitch *) override; bool visitCase(Visit, TIntermCase *node) override; bool visitAggregate(Visit, TIntermAggregate *) override; bool visitLoop(Visit visit, TIntermLoop *) override; bool visitBranch(Visit, TIntermBranch *) override; private: ValidateSwitch(TBasicType switchType, TParseContext *context); bool validateInternal(const TSourceLoc &loc); TBasicType mSwitchType; TParseContext *mContext; bool mCaseTypeMismatch; bool mFirstCaseFound; bool mStatementBeforeCase; bool mLastStatementWasCase; int mControlFlowDepth; bool mCaseInsideControlFlow; int mDefaultCount; std::set mCasesSigned; std::set mCasesUnsigned; bool mDuplicateCases; }; #endif // COMPILER_TRANSLATOR_VALIDATESWITCH_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/VersionGLSL.cpp000066400000000000000000000101571321746453100275430ustar00rootroot00000000000000// // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/VersionGLSL.h" int ShaderOutputTypeToGLSLVersion(ShShaderOutput output) { switch (output) { case SH_GLSL_COMPATIBILITY_OUTPUT: return GLSL_VERSION_110; default: UNREACHABLE(); return 0; } } // We need to scan for the following: // 1. "invariant" keyword: This can occur in both - vertex and fragment shaders // but only at the global scope. // 2. "gl_PointCoord" built-in variable: This can only occur in fragment shader // but inside any scope. // 3. Call to a matrix constructor with another matrix as argument. // (These constructors were reserved in GLSL version 1.10.) // 4. Arrays as "out" function parameters. // GLSL spec section 6.1.1: "When calling a function, expressions that do // not evaluate to l-values cannot be passed to parameters declared as // out or inout." // GLSL 1.1 section 5.8: "Other binary or unary expressions, // non-dereferenced arrays, function names, swizzles with repeated fields, // and constants cannot be l-values." // GLSL 1.2 relaxed the restriction on arrays, section 5.8: "Variables that // are built-in types, entire structures or arrays... are all l-values." // TVersionGLSL::TVersionGLSL(sh::GLenum type, const TPragma &pragma, ShShaderOutput output) : TIntermTraverser(true, false, false) { mVersion = ShaderOutputTypeToGLSLVersion(output); if (pragma.stdgl.invariantAll) { ensureVersionIsAtLeast(GLSL_VERSION_120); } } void TVersionGLSL::visitSymbol(TIntermSymbol *node) { if (node->getSymbol() == "gl_PointCoord") { ensureVersionIsAtLeast(GLSL_VERSION_120); } } bool TVersionGLSL::visitAggregate(Visit, TIntermAggregate *node) { bool visitChildren = true; switch (node->getOp()) { case EOpSequence: // We need to visit sequence children to get to global or inner scope. visitChildren = true; break; case EOpDeclaration: { const TIntermSequence &sequence = *(node->getSequence()); if (sequence.front()->getAsTyped()->getType().isInvariant()) { ensureVersionIsAtLeast(GLSL_VERSION_120); } break; } case EOpInvariantDeclaration: ensureVersionIsAtLeast(GLSL_VERSION_120); break; case EOpParameters: { const TIntermSequence ¶ms = *(node->getSequence()); for (TIntermSequence::const_iterator iter = params.begin(); iter != params.end(); ++iter) { const TIntermTyped *param = (*iter)->getAsTyped(); if (param->isArray()) { TQualifier qualifier = param->getQualifier(); if ((qualifier == EvqOut) || (qualifier == EvqInOut)) { ensureVersionIsAtLeast(GLSL_VERSION_120); break; } } } // Fully processed. No need to visit children. visitChildren = false; break; } case EOpConstructMat2: case EOpConstructMat2x3: case EOpConstructMat2x4: case EOpConstructMat3x2: case EOpConstructMat3: case EOpConstructMat3x4: case EOpConstructMat4x2: case EOpConstructMat4x3: case EOpConstructMat4: { const TIntermSequence &sequence = *(node->getSequence()); if (sequence.size() == 1) { TIntermTyped *typed = sequence.front()->getAsTyped(); if (typed && typed->isMatrix()) { ensureVersionIsAtLeast(GLSL_VERSION_120); } } break; } default: break; } return visitChildren; } void TVersionGLSL::ensureVersionIsAtLeast(int version) { mVersion = std::max(version, mVersion); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/VersionGLSL.h000066400000000000000000000045621321746453100272130ustar00rootroot00000000000000// // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_VERSIONGLSL_H_ #define COMPILER_TRANSLATOR_VERSIONGLSL_H_ #include "compiler/translator/IntermNode.h" #include "compiler/translator/Pragma.h" static const int GLSL_VERSION_110 = 110; static const int GLSL_VERSION_120 = 120; static const int GLSL_VERSION_130 = 130; static const int GLSL_VERSION_140 = 140; static const int GLSL_VERSION_150 = 150; static const int GLSL_VERSION_330 = 330; static const int GLSL_VERSION_400 = 400; static const int GLSL_VERSION_410 = 410; static const int GLSL_VERSION_420 = 420; static const int GLSL_VERSION_430 = 430; static const int GLSL_VERSION_440 = 440; static const int GLSL_VERSION_450 = 450; int ShaderOutputTypeToGLSLVersion(ShShaderOutput output); // Traverses the intermediate tree to return the minimum GLSL version // required to legally access all built-in features used in the shader. // GLSL 1.1 which is mandated by OpenGL 2.0 provides: // - #version and #extension to declare version and extensions. // - built-in functions refract, exp, and log. // - updated step() to compare x < edge instead of x <= edge. // GLSL 1.2 which is mandated by OpenGL 2.1 provides: // - many changes to reduce differences when compared to the ES specification. // - invariant keyword and its support. // - c++ style name hiding rules. // - built-in variable gl_PointCoord for fragment shaders. // - matrix constructors taking matrix as argument. // - array as "out" function parameters // // TODO: ES3 equivalent versions of GLSL class TVersionGLSL : public TIntermTraverser { public: TVersionGLSL(sh::GLenum type, const TPragma &pragma, ShShaderOutput output); // If output is core profile, returns 150. // If output is legacy profile, // Returns 120 if the following is used the shader: // - "invariant", // - "gl_PointCoord", // - matrix/matrix constructors // - array "out" parameters // Else 110 is returned. int getVersion() const { return mVersion; } virtual void visitSymbol(TIntermSymbol *); virtual bool visitAggregate(Visit, TIntermAggregate *); private: void ensureVersionIsAtLeast(int version); int mVersion; }; #endif // COMPILER_TRANSLATOR_VERSIONGLSL_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/generate_parser.sh000066400000000000000000000013611321746453100304270ustar00rootroot00000000000000#!/bin/bash # Copyright (c) 2010 The ANGLE Project Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # Generates GLSL ES parser - glslang_lex.cpp, glslang_tab.h, and glslang_tab.cpp run_flex() { input_file=$script_dir/$1.l output_source=$script_dir/$1_lex.cpp flex --noline --nounistd --outfile=$output_source $input_file } run_bison() { input_file=$script_dir/$1.y output_header=$script_dir/$1_tab.h output_source=$script_dir/$1_tab.cpp bison --no-lines --skeleton=yacc.c --defines=$output_header --output=$output_source $input_file } script_dir=$(dirname $0) # Generate Parser run_flex glslang run_bison glslang patch --silent --forward < 64bit-lexer-safety.patch freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/glslang.h000066400000000000000000000012311321746453100265210ustar00rootroot00000000000000// // Copyright (c) 2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_GLSLANG_H_ #define COMPILER_TRANSLATOR_GLSLANG_H_ class TParseContext; extern int glslang_initialize(TParseContext* context); extern int glslang_finalize(TParseContext* context); extern int glslang_scan(size_t count, const char* const string[], const int length[], TParseContext* context); extern int glslang_parse(TParseContext* context); #endif // COMPILER_TRANSLATOR_GLSLANG_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/glslang.l000066400000000000000000000421311321746453100265310ustar00rootroot00000000000000/* // // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file contains the Lex specification for GLSL ES. Based on ANSI C grammar, Lex specification: http://www.lysator.liu.se/c/ANSI-C-grammar-l.html IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh, WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp). */ %top{ // // Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // This file is auto-generated by generate_parser.sh. DO NOT EDIT! // Ignore errors in auto-generated code. #if defined(__GNUC__) #pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wswitch-enum" #elif defined(_MSC_VER) #pragma warning(disable: 4005) #pragma warning(disable: 4065) #pragma warning(disable: 4189) #pragma warning(disable: 4244) #pragma warning(disable: 4505) #pragma warning(disable: 4701) #pragma warning(disable: 4702) #endif } %{ #include "compiler/translator/glslang.h" #include "compiler/translator/ParseContext.h" #include "compiler/preprocessor/Token.h" #include "compiler/translator/util.h" #include "compiler/translator/length_limits.h" #include "glslang_tab.h" /* windows only pragma */ #ifdef _MSC_VER #pragma warning(disable : 4102) #endif // Workaround for flex using the register keyword, deprecated in C++11. #ifdef __cplusplus #if __cplusplus > 199711L #define register #endif #endif #define YY_USER_ACTION \ yylloc->first_file = yylloc->last_file = yycolumn; \ yylloc->first_line = yylloc->last_line = yylineno; #define YY_INPUT(buf, result, max_size) \ result = string_input(buf, max_size, yyscanner); static yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner); static int check_type(yyscan_t yyscanner); static int reserved_word(yyscan_t yyscanner); static int ES2_reserved_ES3_keyword(TParseContext *context, int token); static int ES2_keyword_ES3_reserved(TParseContext *context, int token); static int ES2_ident_ES3_keyword(TParseContext *context, int token); static int uint_constant(TParseContext *context); static int int_constant(yyscan_t yyscanner); static int float_constant(yyscan_t yyscanner); static int floatsuffix_check(TParseContext* context); %} %option noyywrap nounput never-interactive %option yylineno reentrant bison-bridge bison-locations %option extra-type="TParseContext*" %x FIELDS D [0-9] L [a-zA-Z_] H [a-fA-F0-9] E [Ee][+-]?{D}+ O [0-7] %% %{ TParseContext* context = yyextra; %} "invariant" { return INVARIANT; } "highp" { return HIGH_PRECISION; } "mediump" { return MEDIUM_PRECISION; } "lowp" { return LOW_PRECISION; } "precision" { return PRECISION; } "attribute" { return ES2_keyword_ES3_reserved(context, ATTRIBUTE); } "const" { return CONST_QUAL; } "uniform" { return UNIFORM; } "varying" { return ES2_keyword_ES3_reserved(context, VARYING); } "break" { return BREAK; } "continue" { return CONTINUE; } "do" { return DO; } "for" { return FOR; } "while" { return WHILE; } "if" { return IF; } "else" { return ELSE; } "switch" { return ES2_reserved_ES3_keyword(context, SWITCH); } "case" { return ES2_ident_ES3_keyword(context, CASE); } "default" { return ES2_reserved_ES3_keyword(context, DEFAULT); } "centroid" { return ES2_ident_ES3_keyword(context, CENTROID); } "flat" { return ES2_reserved_ES3_keyword(context, FLAT); } "smooth" { return ES2_ident_ES3_keyword(context, SMOOTH); } "in" { return IN_QUAL; } "out" { return OUT_QUAL; } "inout" { return INOUT_QUAL; } "float" { return FLOAT_TYPE; } "int" { return INT_TYPE; } "uint" { return ES2_ident_ES3_keyword(context, UINT_TYPE); } "void" { return VOID_TYPE; } "bool" { return BOOL_TYPE; } "true" { yylval->lex.b = true; return BOOLCONSTANT; } "false" { yylval->lex.b = false; return BOOLCONSTANT; } "discard" { return DISCARD; } "return" { return RETURN; } "mat2" { return MATRIX2; } "mat3" { return MATRIX3; } "mat4" { return MATRIX4; } "mat2x2" { return ES2_ident_ES3_keyword(context, MATRIX2); } "mat3x3" { return ES2_ident_ES3_keyword(context, MATRIX3); } "mat4x4" { return ES2_ident_ES3_keyword(context, MATRIX4); } "mat2x3" { return ES2_ident_ES3_keyword(context, MATRIX2x3); } "mat3x2" { return ES2_ident_ES3_keyword(context, MATRIX3x2); } "mat2x4" { return ES2_ident_ES3_keyword(context, MATRIX2x4); } "mat4x2" { return ES2_ident_ES3_keyword(context, MATRIX4x2); } "mat3x4" { return ES2_ident_ES3_keyword(context, MATRIX3x4); } "mat4x3" { return ES2_ident_ES3_keyword(context, MATRIX4x3); } "vec2" { return VEC2; } "vec3" { return VEC3; } "vec4" { return VEC4; } "ivec2" { return IVEC2; } "ivec3" { return IVEC3; } "ivec4" { return IVEC4; } "bvec2" { return BVEC2; } "bvec3" { return BVEC3; } "bvec4" { return BVEC4; } "uvec2" { return ES2_ident_ES3_keyword(context, UVEC2); } "uvec3" { return ES2_ident_ES3_keyword(context, UVEC3); } "uvec4" { return ES2_ident_ES3_keyword(context, UVEC4); } "sampler2D" { return SAMPLER2D; } "samplerCube" { return SAMPLERCUBE; } "samplerExternalOES" { return SAMPLER_EXTERNAL_OES; } "sampler3D" { return ES2_reserved_ES3_keyword(context, SAMPLER3D); } "sampler3DRect" { return ES2_reserved_ES3_keyword(context, SAMPLER3DRECT); } "sampler2DRect" { return SAMPLER2DRECT; } "sampler2DArray" { return ES2_ident_ES3_keyword(context, SAMPLER2DARRAY); } "isampler2D" { return ES2_ident_ES3_keyword(context, ISAMPLER2D); } "isampler3D" { return ES2_ident_ES3_keyword(context, ISAMPLER3D); } "isamplerCube" { return ES2_ident_ES3_keyword(context, ISAMPLERCUBE); } "isampler2DArray" { return ES2_ident_ES3_keyword(context, ISAMPLER2DARRAY); } "usampler2D" { return ES2_ident_ES3_keyword(context, USAMPLER2D); } "usampler3D" { return ES2_ident_ES3_keyword(context, USAMPLER3D); } "usamplerCube" { return ES2_ident_ES3_keyword(context, USAMPLERCUBE); } "usampler2DArray" { return ES2_ident_ES3_keyword(context, USAMPLER2DARRAY); } "sampler2DShadow" { return ES2_reserved_ES3_keyword(context, SAMPLER2DSHADOW); } "samplerCubeShadow" { return ES2_ident_ES3_keyword(context, SAMPLERCUBESHADOW); } "sampler2DArrayShadow" { return ES2_ident_ES3_keyword(context, SAMPLER2DARRAYSHADOW); } "struct" { return STRUCT; } "layout" { return ES2_ident_ES3_keyword(context, LAYOUT); } /* Reserved keywords for GLSL ES 3.00 that are not reserved for GLSL ES 1.00 */ "coherent" | "restrict" | "readonly" | "writeonly" | "resource" | "atomic_uint" | "noperspective" | "patch" | "sample" | "subroutine" | "common" | "partition" | "active" | "filter" | "image1D" | "image2D" | "image3D" | "imageCube" | "iimage1D" | "iimage2D" | "iimage3D" | "iimageCube" | "uimage1D" | "uimage2D" | "uimage3D" | "uimageCube" | "image1DArray" | "image2DArray" | "iimage1DArray" | "iimage2DArray" | "uimage1DArray" | "uimage2DArray" | "image1DShadow" | "image2DShadow" | "image1DArrayShadow" | "image2DArrayShadow" | "imageBuffer" | "iimageBuffer" | "uimageBuffer" | "sampler1DArray" | "sampler1DArrayShadow" | "isampler1D" | "isampler1DArray" | "usampler1D" | "usampler1DArray" | "isampler2DRect" | "usampler2DRect" | "samplerBuffer" | "isamplerBuffer" | "usamplerBuffer" | "sampler2DMS" | "isampler2DMS" | "usampler2DMS" | "sampler2DMSArray" | "isampler2DMSArray" | "usampler2DMSArray" { if (context->getShaderVersion() < 300) { yylval->lex.string = NewPoolTString(yytext); return check_type(yyscanner); } return reserved_word(yyscanner); } /* Reserved keywords in GLSL ES 1.00 that are not reserved in GLSL ES 3.00 */ "packed" { if (context->getShaderVersion() >= 300) { yylval->lex.string = NewPoolTString(yytext); return check_type(yyscanner); } return reserved_word(yyscanner); } /* Reserved keywords */ "asm" | "class" | "union" | "enum" | "typedef" | "template" | "this" | "goto" | "inline" | "noinline" | "volatile" | "public" | "static" | "extern" | "external" | "interface" | "long" | "short" | "double" | "half" | "fixed" | "unsigned" | "superp" | "input" | "output" | "hvec2" | "hvec3" | "hvec4" | "dvec2" | "dvec3" | "dvec4" | "fvec2" | "fvec3" | "fvec4" | "sampler1D" | "sampler1DShadow" | "sampler2DRectShadow" | "sizeof" | "cast" | "namespace" | "using" { return reserved_word(yyscanner); } {L}({L}|{D})* { yylval->lex.string = NewPoolTString(yytext); return check_type(yyscanner); } 0[xX]{H}+ { return int_constant(yyscanner); } 0{O}+ { return int_constant(yyscanner); } {D}+ { return int_constant(yyscanner); } 0[xX]{H}+[uU] { return uint_constant(context); } 0{O}+[uU] { return uint_constant(context); } {D}+[uU] { return uint_constant(context); } {D}+{E} { return float_constant(yyscanner); } {D}+"."{D}*({E})? { return float_constant(yyscanner); } "."{D}+({E})? { return float_constant(yyscanner); } {D}+{E}[fF] { return floatsuffix_check(context); } {D}+"."{D}*({E})?[fF] { return floatsuffix_check(context); } "."{D}+({E})?[fF] { return floatsuffix_check(context); } "+=" { return ADD_ASSIGN; } "-=" { return SUB_ASSIGN; } "*=" { return MUL_ASSIGN; } "/=" { return DIV_ASSIGN; } "%=" { return MOD_ASSIGN; } "<<=" { return LEFT_ASSIGN; } ">>=" { return RIGHT_ASSIGN; } "&=" { return AND_ASSIGN; } "^=" { return XOR_ASSIGN; } "|=" { return OR_ASSIGN; } "++" { return INC_OP; } "--" { return DEC_OP; } "&&" { return AND_OP; } "||" { return OR_OP; } "^^" { return XOR_OP; } "<=" { return LE_OP; } ">=" { return GE_OP; } "==" { return EQ_OP; } "!=" { return NE_OP; } "<<" { return LEFT_OP; } ">>" { return RIGHT_OP; } ";" { return SEMICOLON; } ("{"|"<%") { return LEFT_BRACE; } ("}"|"%>") { return RIGHT_BRACE; } "," { return COMMA; } ":" { return COLON; } "=" { return EQUAL; } "(" { return LEFT_PAREN; } ")" { return RIGHT_PAREN; } ("["|"<:") { return LEFT_BRACKET; } ("]"|":>") { return RIGHT_BRACKET; } "." { BEGIN(FIELDS); return DOT; } "!" { return BANG; } "-" { return DASH; } "~" { return TILDE; } "+" { return PLUS; } "*" { return STAR; } "/" { return SLASH; } "%" { return PERCENT; } "<" { return LEFT_ANGLE; } ">" { return RIGHT_ANGLE; } "|" { return VERTICAL_BAR; } "^" { return CARET; } "&" { return AMPERSAND; } "?" { return QUESTION; } {L}({L}|{D})* { BEGIN(INITIAL); yylval->lex.string = NewPoolTString(yytext); return FIELD_SELECTION; } [ \t\v\f\r] {} [ \t\v\n\f\r] { } <*><> { yyterminate(); } <*>. { assert(false); return 0; } %% yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner) { pp::Token token; yyget_extra(yyscanner)->getPreprocessor().lex(&token); yy_size_t len = token.type == pp::Token::LAST ? 0 : token.text.size(); if (len < max_size) memcpy(buf, token.text.c_str(), len); yyset_column(token.location.file, yyscanner); yyset_lineno(token.location.line, yyscanner); if (len >= max_size) YY_FATAL_ERROR("Input buffer overflow"); else if (len > 0) buf[len++] = ' '; return len; } int check_type(yyscan_t yyscanner) { struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; int token = IDENTIFIER; TSymbol* symbol = yyextra->symbolTable.find(yytext, yyextra->getShaderVersion()); if (symbol && symbol->isVariable()) { TVariable* variable = static_cast(symbol); if (variable->isUserType()) { token = TYPE_NAME; } } yylval->lex.symbol = symbol; return token; } int reserved_word(yyscan_t yyscanner) { struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; yyextra->error(*yylloc, "Illegal use of reserved word", yytext, ""); yyextra->recover(); return 0; } int ES2_reserved_ES3_keyword(TParseContext *context, int token) { yyscan_t yyscanner = (yyscan_t) context->getScanner(); if (context->getShaderVersion() < 300) { return reserved_word(yyscanner); } return token; } int ES2_keyword_ES3_reserved(TParseContext *context, int token) { yyscan_t yyscanner = (yyscan_t) context->getScanner(); if (context->getShaderVersion() >= 300) { return reserved_word(yyscanner); } return token; } int ES2_ident_ES3_keyword(TParseContext *context, int token) { struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); yyscan_t yyscanner = (yyscan_t) context->getScanner(); // not a reserved word in GLSL ES 1.00, so could be used as an identifier/type name if (context->getShaderVersion() < 300) { yylval->lex.string = NewPoolTString(yytext); return check_type(yyscanner); } return token; } int uint_constant(TParseContext *context) { struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); yyscan_t yyscanner = (yyscan_t) context->getScanner(); if (context->getShaderVersion() < 300) { context->error(*yylloc, "Unsigned integers are unsupported prior to GLSL ES 3.00", yytext, ""); context->recover(); return 0; } if (!atoi_clamp(yytext, &(yylval->lex.i))) yyextra->warning(*yylloc, "Integer overflow", yytext, ""); return UINTCONSTANT; } int floatsuffix_check(TParseContext* context) { struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); if (context->getShaderVersion() < 300) { context->error(*yylloc, "Floating-point suffix unsupported prior to GLSL ES 3.00", yytext); context->recover(); return 0; } std::string text = yytext; text.resize(text.size() - 1); if (!strtof_clamp(text, &(yylval->lex.f))) yyextra->warning(*yylloc, "Float overflow", yytext, ""); return(FLOATCONSTANT); } void yyerror(YYLTYPE* lloc, TParseContext* context, void *scanner, const char* reason) { context->error(*lloc, reason, yyget_text(scanner)); context->recover(); } int int_constant(yyscan_t yyscanner) { struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; if (!atoi_clamp(yytext, &(yylval->lex.i))) yyextra->warning(*yylloc, "Integer overflow", yytext, ""); return INTCONSTANT; } int float_constant(yyscan_t yyscanner) { struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; if (!strtof_clamp(yytext, &(yylval->lex.f))) yyextra->warning(*yylloc, "Float overflow", yytext, ""); return FLOATCONSTANT; } int glslang_initialize(TParseContext* context) { yyscan_t scanner = NULL; if (yylex_init_extra(context, &scanner)) return 1; context->setScanner(scanner); return 0; } int glslang_finalize(TParseContext* context) { yyscan_t scanner = context->getScanner(); if (scanner == NULL) return 0; context->setScanner(NULL); yylex_destroy(scanner); return 0; } int glslang_scan(size_t count, const char* const string[], const int length[], TParseContext* context) { yyrestart(NULL, context->getScanner()); yyset_column(0, context->getScanner()); yyset_lineno(1, context->getScanner()); // Initialize preprocessor. pp::Preprocessor *preprocessor = &context->getPreprocessor(); if (!preprocessor->init(count, string, length)) return 1; // Define extension macros. const TExtensionBehavior& extBehavior = context->extensionBehavior(); for (TExtensionBehavior::const_iterator iter = extBehavior.begin(); iter != extBehavior.end(); ++iter) { preprocessor->predefineMacro(iter->first.c_str(), 1); } if (context->getFragmentPrecisionHigh()) preprocessor->predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1); preprocessor->setMaxTokenSize(GetGlobalMaxTokenSize(context->getShaderSpec())); return 0; } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/glslang.y000066400000000000000000001533471321746453100265620ustar00rootroot00000000000000/* // // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file contains the Yacc grammar for GLSL ES. Based on ANSI C Yacc grammar: http://www.lysator.liu.se/c/ANSI-C-grammar-y.html IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh, WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h). */ %{ // // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // This file is auto-generated by generate_parser.sh. DO NOT EDIT! // Ignore errors in auto-generated code. #if defined(__GNUC__) #pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wswitch-enum" #elif defined(_MSC_VER) #pragma warning(disable: 4065) #pragma warning(disable: 4189) #pragma warning(disable: 4244) #pragma warning(disable: 4505) #pragma warning(disable: 4701) #pragma warning(disable: 4702) #endif #include "angle_gl.h" #include "compiler/translator/Cache.h" #include "compiler/translator/SymbolTable.h" #include "compiler/translator/ParseContext.h" #include "GLSLANG/ShaderLang.h" #define YYENABLE_NLS 0 %} %expect 1 /* One shift reduce conflict because of if | else */ %parse-param {TParseContext* context} %param {void *scanner} %define api.pure full %locations %code requires { #define YYLTYPE TSourceLoc #define YYLTYPE_IS_DECLARED 1 } %union { struct { union { TString *string; float f; int i; unsigned int u; bool b; }; TSymbol* symbol; } lex; struct { TOperator op; union { TIntermNode* intermNode; TIntermNodePair nodePair; TIntermTyped* intermTypedNode; TIntermAggregate* intermAggregate; TIntermSwitch* intermSwitch; TIntermCase* intermCase; }; union { TPublicType type; TPrecision precision; TLayoutQualifier layoutQualifier; TQualifier qualifier; TFunction* function; TParameter param; TField* field; TFieldList* fieldList; }; } interm; } %{ extern int yylex(YYSTYPE* yylval, YYLTYPE* yylloc, void* yyscanner); extern void yyerror(YYLTYPE* yylloc, TParseContext* context, void *scanner, const char* reason); #define YYLLOC_DEFAULT(Current, Rhs, N) \ do { \ if (N) { \ (Current).first_file = YYRHSLOC(Rhs, 1).first_file; \ (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ (Current).last_file = YYRHSLOC(Rhs, N).last_file; \ (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ } \ else { \ (Current).first_file = YYRHSLOC(Rhs, 0).last_file; \ (Current).first_line = YYRHSLOC(Rhs, 0).last_line; \ (Current).last_file = YYRHSLOC(Rhs, 0).last_file; \ (Current).last_line = YYRHSLOC(Rhs, 0).last_line; \ } \ } while (0) #define VERTEX_ONLY(S, L) { \ if (context->getShaderType() != GL_VERTEX_SHADER) { \ context->error(L, " supported in vertex shaders only ", S); \ context->recover(); \ } \ } #define FRAG_ONLY(S, L) { \ if (context->getShaderType() != GL_FRAGMENT_SHADER) { \ context->error(L, " supported in fragment shaders only ", S); \ context->recover(); \ } \ } #define ES2_ONLY(S, L) { \ if (context->getShaderVersion() != 100) { \ context->error(L, " supported in GLSL ES 1.00 only ", S); \ context->recover(); \ } \ } #define ES3_ONLY(TOKEN, LINE, REASON) { \ if (context->getShaderVersion() != 300) { \ context->error(LINE, REASON " supported in GLSL ES 3.00 only ", TOKEN); \ context->recover(); \ } \ } %} %token INVARIANT HIGH_PRECISION MEDIUM_PRECISION LOW_PRECISION PRECISION %token ATTRIBUTE CONST_QUAL BOOL_TYPE FLOAT_TYPE INT_TYPE UINT_TYPE %token BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT %token BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 VEC2 VEC3 VEC4 UVEC2 UVEC3 UVEC4 %token MATRIX2 MATRIX3 MATRIX4 IN_QUAL OUT_QUAL INOUT_QUAL UNIFORM VARYING %token MATRIX2x3 MATRIX3x2 MATRIX2x4 MATRIX4x2 MATRIX3x4 MATRIX4x3 %token CENTROID FLAT SMOOTH %token STRUCT VOID_TYPE WHILE %token SAMPLER2D SAMPLERCUBE SAMPLER_EXTERNAL_OES SAMPLER2DRECT SAMPLER2DARRAY %token ISAMPLER2D ISAMPLER3D ISAMPLERCUBE ISAMPLER2DARRAY %token USAMPLER2D USAMPLER3D USAMPLERCUBE USAMPLER2DARRAY %token SAMPLER3D SAMPLER3DRECT SAMPLER2DSHADOW SAMPLERCUBESHADOW SAMPLER2DARRAYSHADOW %token LAYOUT %token IDENTIFIER TYPE_NAME FLOATCONSTANT INTCONSTANT UINTCONSTANT BOOLCONSTANT %token FIELD_SELECTION %token LEFT_OP RIGHT_OP %token INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP %token AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN %token MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN %token SUB_ASSIGN %token LEFT_PAREN RIGHT_PAREN LEFT_BRACKET RIGHT_BRACKET LEFT_BRACE RIGHT_BRACE DOT %token COMMA COLON EQUAL SEMICOLON BANG DASH TILDE PLUS STAR SLASH PERCENT %token LEFT_ANGLE RIGHT_ANGLE VERTICAL_BAR CARET AMPERSAND QUESTION %type identifier %type assignment_operator unary_operator %type variable_identifier primary_expression postfix_expression %type expression integer_expression assignment_expression %type unary_expression multiplicative_expression additive_expression %type relational_expression equality_expression %type conditional_expression constant_expression %type logical_or_expression logical_xor_expression logical_and_expression %type shift_expression and_expression exclusive_or_expression inclusive_or_expression %type function_call initializer condition conditionopt %type translation_unit function_definition %type statement simple_statement %type statement_list compound_statement %type declaration_statement selection_statement expression_statement %type declaration external_declaration %type for_init_statement compound_statement_no_new_scope %type selection_rest_statement for_rest_statement %type switch_statement %type case_label %type iteration_statement jump_statement statement_no_new_scope statement_with_scope %type single_declaration init_declarator_list %type parameter_declaration parameter_declarator parameter_type_specifier %type parameter_qualifier parameter_type_qualifier %type layout_qualifier layout_qualifier_id_list layout_qualifier_id %type precision_qualifier %type type_qualifier fully_specified_type type_specifier storage_qualifier interpolation_qualifier %type type_specifier_no_prec type_specifier_nonarray %type struct_specifier %type struct_declarator %type struct_declarator_list struct_declaration struct_declaration_list %type function_header function_declarator function_identifier %type function_header_with_parameters function_call_header %type function_call_header_with_parameters function_call_header_no_parameters function_call_generic function_prototype %type function_call_or_method %type enter_struct %start translation_unit %% identifier : IDENTIFIER | TYPE_NAME variable_identifier : IDENTIFIER { // The symbol table search was done in the lexical phase const TVariable *variable = context->getNamedVariable(@1, $1.string, $1.symbol); if (variable->getType().getQualifier() == EvqConst) { TConstantUnion* constArray = variable->getConstPointer(); TType t(variable->getType()); $$ = context->intermediate.addConstantUnion(constArray, t, @1); } else { $$ = context->intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), @1); } // don't delete $1.string, it's used by error recovery, and the pool // pop will reclaim the memory } ; primary_expression : variable_identifier { $$ = $1; } | INTCONSTANT { TConstantUnion *unionArray = new TConstantUnion[1]; unionArray->setIConst($1.i); $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), @1); } | UINTCONSTANT { TConstantUnion *unionArray = new TConstantUnion[1]; unionArray->setUConst($1.u); $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtUInt, EbpUndefined, EvqConst), @1); } | FLOATCONSTANT { TConstantUnion *unionArray = new TConstantUnion[1]; unionArray->setFConst($1.f); $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), @1); } | BOOLCONSTANT { TConstantUnion *unionArray = new TConstantUnion[1]; unionArray->setBConst($1.b); $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), @1); } | LEFT_PAREN expression RIGHT_PAREN { $$ = $2; } ; postfix_expression : primary_expression { $$ = $1; } | postfix_expression LEFT_BRACKET integer_expression RIGHT_BRACKET { $$ = context->addIndexExpression($1, @2, $3); } | function_call { $$ = $1; } | postfix_expression DOT FIELD_SELECTION { $$ = context->addFieldSelectionExpression($1, @2, *$3.string, @3); } | postfix_expression INC_OP { $$ = context->addUnaryMathLValue(EOpPostIncrement, $1, @2); } | postfix_expression DEC_OP { $$ = context->addUnaryMathLValue(EOpPostDecrement, $1, @2); } ; integer_expression : expression { if (context->integerErrorCheck($1, "[]")) context->recover(); $$ = $1; } ; function_call : function_call_or_method { bool fatalError = false; $$ = context->addFunctionCallOrMethod($1.function, $1.nodePair.node1, $1.nodePair.node2, @1, &fatalError); if (fatalError) { YYERROR; } } ; function_call_or_method : function_call_generic { $$ = $1; $$.nodePair.node2 = nullptr; } | postfix_expression DOT function_call_generic { ES3_ONLY("", @3, "methods"); $$ = $3; $$.nodePair.node2 = $1; } ; function_call_generic : function_call_header_with_parameters RIGHT_PAREN { $$ = $1; } | function_call_header_no_parameters RIGHT_PAREN { $$ = $1; } ; function_call_header_no_parameters : function_call_header VOID_TYPE { $$.function = $1; $$.nodePair.node1 = nullptr; } | function_call_header { $$.function = $1; $$.nodePair.node1 = nullptr; } ; function_call_header_with_parameters : function_call_header assignment_expression { const TType *type = new TType($2->getType()); $1->addParameter(TConstParameter(type)); $$.function = $1; $$.nodePair.node1 = $2; } | function_call_header_with_parameters COMMA assignment_expression { const TType *type = new TType($3->getType()); $1.function->addParameter(TConstParameter(type)); $$.function = $1.function; $$.nodePair.node1 = context->intermediate.growAggregate($1.intermNode, $3, @2); } ; function_call_header : function_identifier LEFT_PAREN { $$ = $1; } ; // Grammar Note: Constructors look like functions, but are recognized as types. function_identifier : type_specifier_no_prec { if ($1.array) { ES3_ONLY("[]", @1, "array constructor"); } $$ = context->addConstructorFunc($1); } | IDENTIFIER { if (context->reservedErrorCheck(@1, *$1.string)) context->recover(); const TType *type = TCache::getType(EbtVoid, EbpUndefined); TFunction *function = new TFunction($1.string, type); $$ = function; } | FIELD_SELECTION { if (context->reservedErrorCheck(@1, *$1.string)) context->recover(); const TType *type = TCache::getType(EbtVoid, EbpUndefined); TFunction *function = new TFunction($1.string, type); $$ = function; } ; unary_expression : postfix_expression { $$ = $1; } | INC_OP unary_expression { $$ = context->addUnaryMathLValue(EOpPreIncrement, $2, @1); } | DEC_OP unary_expression { $$ = context->addUnaryMathLValue(EOpPreDecrement, $2, @1); } | unary_operator unary_expression { if ($1.op != EOpNull) { $$ = context->addUnaryMath($1.op, $2, @1); } else $$ = $2; } ; // Grammar Note: No traditional style type casts. unary_operator : PLUS { $$.op = EOpPositive; } | DASH { $$.op = EOpNegative; } | BANG { $$.op = EOpLogicalNot; } | TILDE { ES3_ONLY("~", @$, "bit-wise operator"); $$.op = EOpBitwiseNot; } ; // Grammar Note: No '*' or '&' unary ops. Pointers are not supported. multiplicative_expression : unary_expression { $$ = $1; } | multiplicative_expression STAR unary_expression { $$ = context->addBinaryMath(EOpMul, $1, $3, @2); } | multiplicative_expression SLASH unary_expression { $$ = context->addBinaryMath(EOpDiv, $1, $3, @2); } | multiplicative_expression PERCENT unary_expression { ES3_ONLY("%", @2, "integer modulus operator"); $$ = context->addBinaryMath(EOpIMod, $1, $3, @2); } ; additive_expression : multiplicative_expression { $$ = $1; } | additive_expression PLUS multiplicative_expression { $$ = context->addBinaryMath(EOpAdd, $1, $3, @2); } | additive_expression DASH multiplicative_expression { $$ = context->addBinaryMath(EOpSub, $1, $3, @2); } ; shift_expression : additive_expression { $$ = $1; } | shift_expression LEFT_OP additive_expression { ES3_ONLY("<<", @2, "bit-wise operator"); $$ = context->addBinaryMath(EOpBitShiftLeft, $1, $3, @2); } | shift_expression RIGHT_OP additive_expression { ES3_ONLY(">>", @2, "bit-wise operator"); $$ = context->addBinaryMath(EOpBitShiftRight, $1, $3, @2); } ; relational_expression : shift_expression { $$ = $1; } | relational_expression LEFT_ANGLE shift_expression { $$ = context->addBinaryMathBooleanResult(EOpLessThan, $1, $3, @2); } | relational_expression RIGHT_ANGLE shift_expression { $$ = context->addBinaryMathBooleanResult(EOpGreaterThan, $1, $3, @2); } | relational_expression LE_OP shift_expression { $$ = context->addBinaryMathBooleanResult(EOpLessThanEqual, $1, $3, @2); } | relational_expression GE_OP shift_expression { $$ = context->addBinaryMathBooleanResult(EOpGreaterThanEqual, $1, $3, @2); } ; equality_expression : relational_expression { $$ = $1; } | equality_expression EQ_OP relational_expression { $$ = context->addBinaryMathBooleanResult(EOpEqual, $1, $3, @2); } | equality_expression NE_OP relational_expression { $$ = context->addBinaryMathBooleanResult(EOpNotEqual, $1, $3, @2); } ; and_expression : equality_expression { $$ = $1; } | and_expression AMPERSAND equality_expression { ES3_ONLY("&", @2, "bit-wise operator"); $$ = context->addBinaryMath(EOpBitwiseAnd, $1, $3, @2); } ; exclusive_or_expression : and_expression { $$ = $1; } | exclusive_or_expression CARET and_expression { ES3_ONLY("^", @2, "bit-wise operator"); $$ = context->addBinaryMath(EOpBitwiseXor, $1, $3, @2); } ; inclusive_or_expression : exclusive_or_expression { $$ = $1; } | inclusive_or_expression VERTICAL_BAR exclusive_or_expression { ES3_ONLY("|", @2, "bit-wise operator"); $$ = context->addBinaryMath(EOpBitwiseOr, $1, $3, @2); } ; logical_and_expression : inclusive_or_expression { $$ = $1; } | logical_and_expression AND_OP inclusive_or_expression { $$ = context->addBinaryMathBooleanResult(EOpLogicalAnd, $1, $3, @2); } ; logical_xor_expression : logical_and_expression { $$ = $1; } | logical_xor_expression XOR_OP logical_and_expression { $$ = context->addBinaryMathBooleanResult(EOpLogicalXor, $1, $3, @2); } ; logical_or_expression : logical_xor_expression { $$ = $1; } | logical_or_expression OR_OP logical_xor_expression { $$ = context->addBinaryMathBooleanResult(EOpLogicalOr, $1, $3, @2); } ; conditional_expression : logical_or_expression { $$ = $1; } | logical_or_expression QUESTION expression COLON assignment_expression { $$ = context->addTernarySelection($1, $3, $5, @2); } ; assignment_expression : conditional_expression { $$ = $1; } | unary_expression assignment_operator assignment_expression { if (context->lValueErrorCheck(@2, "assign", $1)) context->recover(); $$ = context->addAssign($2.op, $1, $3, @2); } ; assignment_operator : EQUAL { $$.op = EOpAssign; } | MUL_ASSIGN { $$.op = EOpMulAssign; } | DIV_ASSIGN { $$.op = EOpDivAssign; } | MOD_ASSIGN { ES3_ONLY("%=", @$, "integer modulus operator"); $$.op = EOpIModAssign; } | ADD_ASSIGN { $$.op = EOpAddAssign; } | SUB_ASSIGN { $$.op = EOpSubAssign; } | LEFT_ASSIGN { ES3_ONLY("<<=", @$, "bit-wise operator"); $$.op = EOpBitShiftLeftAssign; } | RIGHT_ASSIGN { ES3_ONLY(">>=", @$, "bit-wise operator"); $$.op = EOpBitShiftRightAssign; } | AND_ASSIGN { ES3_ONLY("&=", @$, "bit-wise operator"); $$.op = EOpBitwiseAndAssign; } | XOR_ASSIGN { ES3_ONLY("^=", @$, "bit-wise operator"); $$.op = EOpBitwiseXorAssign; } | OR_ASSIGN { ES3_ONLY("|=", @$, "bit-wise operator"); $$.op = EOpBitwiseOrAssign; } ; expression : assignment_expression { $$ = $1; } | expression COMMA assignment_expression { $$ = context->intermediate.addComma($1, $3, @2); if ($$ == 0) { context->binaryOpError(@2, ",", $1->getCompleteString(), $3->getCompleteString()); context->recover(); $$ = $3; } } ; constant_expression : conditional_expression { if (context->constErrorCheck($1)) context->recover(); $$ = $1; } ; enter_struct : IDENTIFIER LEFT_BRACE { if (context->enterStructDeclaration(@1, *$1.string)) context->recover(); $$ = $1; } ; declaration : function_prototype SEMICOLON { TFunction &function = *($1.function); TIntermAggregate *prototype = new TIntermAggregate; prototype->setType(function.getReturnType()); prototype->setName(function.getMangledName()); prototype->setFunctionId(function.getUniqueId()); for (size_t i = 0; i < function.getParamCount(); i++) { const TConstParameter ¶m = function.getParam(i); if (param.name != 0) { TVariable variable(param.name, *param.type); prototype = context->intermediate.growAggregate(prototype, context->intermediate.addSymbol(variable.getUniqueId(), variable.getName(), variable.getType(), @1), @1); } else { prototype = context->intermediate.growAggregate(prototype, context->intermediate.addSymbol(0, "", *param.type, @1), @1); } } prototype->setOp(EOpPrototype); $$ = prototype; context->symbolTable.pop(); } | init_declarator_list SEMICOLON { TIntermAggregate *aggNode = $1.intermAggregate; if (aggNode && aggNode->getOp() == EOpNull) aggNode->setOp(EOpDeclaration); $$ = aggNode; } | PRECISION precision_qualifier type_specifier_no_prec SEMICOLON { if (($2 == EbpHigh) && (context->getShaderType() == GL_FRAGMENT_SHADER) && !context->getFragmentPrecisionHigh()) { context->error(@1, "precision is not supported in fragment shader", "highp"); context->recover(); } if (!context->symbolTable.setDefaultPrecision( $3, $2 )) { context->error(@1, "illegal type argument for default precision qualifier", getBasicString($3.type)); context->recover(); } $$ = 0; } | type_qualifier enter_struct struct_declaration_list RIGHT_BRACE SEMICOLON { ES3_ONLY(getQualifierString($1.qualifier), @1, "interface blocks"); $$ = context->addInterfaceBlock($1, @2, *$2.string, $3, NULL, @$, NULL, @$); } | type_qualifier enter_struct struct_declaration_list RIGHT_BRACE IDENTIFIER SEMICOLON { ES3_ONLY(getQualifierString($1.qualifier), @1, "interface blocks"); $$ = context->addInterfaceBlock($1, @2, *$2.string, $3, $5.string, @5, NULL, @$); } | type_qualifier enter_struct struct_declaration_list RIGHT_BRACE IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET SEMICOLON { ES3_ONLY(getQualifierString($1.qualifier), @1, "interface blocks"); $$ = context->addInterfaceBlock($1, @2, *$2.string, $3, $5.string, @5, $7, @6); } | type_qualifier SEMICOLON { context->parseGlobalLayoutQualifier($1); $$ = 0; } ; function_prototype : function_declarator RIGHT_PAREN { $$.function = context->parseFunctionDeclarator(@2, $1); } ; function_declarator : function_header { $$ = $1; } | function_header_with_parameters { $$ = $1; } ; function_header_with_parameters : function_header parameter_declaration { // Add the parameter $$ = $1; if ($2.param.type->getBasicType() != EbtVoid) $1->addParameter($2.param.turnToConst()); else delete $2.param.type; } | function_header_with_parameters COMMA parameter_declaration { // // Only first parameter of one-parameter functions can be void // The check for named parameters not being void is done in parameter_declarator // if ($3.param.type->getBasicType() == EbtVoid) { // // This parameter > first is void // context->error(@2, "cannot be an argument type except for '(void)'", "void"); context->recover(); delete $3.param.type; } else { // Add the parameter $$ = $1; $1->addParameter($3.param.turnToConst()); } } ; function_header : fully_specified_type IDENTIFIER LEFT_PAREN { if ($1.qualifier != EvqGlobal && $1.qualifier != EvqTemporary) { context->error(@2, "no qualifiers allowed for function return", getQualifierString($1.qualifier)); context->recover(); } if (!$1.layoutQualifier.isEmpty()) { context->error(@2, "no qualifiers allowed for function return", "layout"); context->recover(); } // make sure a sampler is not involved as well... if (context->samplerErrorCheck(@2, $1, "samplers can't be function return values")) context->recover(); // Add the function as a prototype after parsing it (we do not support recursion) TFunction *function; const TType *type = new TType($1); function = new TFunction($2.string, type); $$ = function; context->symbolTable.push(); } ; parameter_declarator // Type + name : type_specifier identifier { if ($1.type == EbtVoid) { context->error(@2, "illegal use of type 'void'", $2.string->c_str()); context->recover(); } if (context->reservedErrorCheck(@2, *$2.string)) context->recover(); TParameter param = {$2.string, new TType($1)}; $$.param = param; } | type_specifier identifier LEFT_BRACKET constant_expression RIGHT_BRACKET { // Check that we can make an array out of this type if (context->arrayTypeErrorCheck(@3, $1)) context->recover(); if (context->reservedErrorCheck(@2, *$2.string)) context->recover(); int size; if (context->arraySizeErrorCheck(@3, $4, size)) context->recover(); $1.setArraySize(size); TType* type = new TType($1); TParameter param = { $2.string, type }; $$.param = param; } ; parameter_declaration // // The only parameter qualifier a parameter can have are // IN_QUAL, OUT_QUAL, INOUT_QUAL, or CONST. // // // Type + name // : parameter_type_qualifier parameter_qualifier parameter_declarator { $$ = $3; if (context->paramErrorCheck(@3, $1, $2, $$.param.type)) context->recover(); } | parameter_qualifier parameter_declarator { $$ = $2; if (context->parameterSamplerErrorCheck(@2, $1, *$2.param.type)) context->recover(); if (context->paramErrorCheck(@2, EvqTemporary, $1, $$.param.type)) context->recover(); } // // Only type // | parameter_type_qualifier parameter_qualifier parameter_type_specifier { $$ = $3; if (context->paramErrorCheck(@3, $1, $2, $$.param.type)) context->recover(); } | parameter_qualifier parameter_type_specifier { $$ = $2; if (context->parameterSamplerErrorCheck(@2, $1, *$2.param.type)) context->recover(); if (context->paramErrorCheck(@2, EvqTemporary, $1, $$.param.type)) context->recover(); } ; parameter_qualifier : /* empty */ { $$ = EvqIn; } | IN_QUAL { $$ = EvqIn; } | OUT_QUAL { $$ = EvqOut; } | INOUT_QUAL { $$ = EvqInOut; } ; parameter_type_specifier : type_specifier { TParameter param = { 0, new TType($1) }; $$.param = param; } ; init_declarator_list : single_declaration { $$ = $1; } | init_declarator_list COMMA identifier { $$ = $1; $$.intermAggregate = context->parseDeclarator($$.type, $1.intermAggregate, @3, *$3.string); } | init_declarator_list COMMA identifier LEFT_BRACKET constant_expression RIGHT_BRACKET { $$ = $1; $$.intermAggregate = context->parseArrayDeclarator($$.type, $1.intermAggregate, @3, *$3.string, @4, $5); } | init_declarator_list COMMA identifier LEFT_BRACKET RIGHT_BRACKET EQUAL initializer { ES3_ONLY("[]", @3, "implicitly sized array"); $$ = $1; $$.intermAggregate = context->parseArrayInitDeclarator($$.type, $1.intermAggregate, @3, *$3.string, @4, nullptr, @6, $7); } | init_declarator_list COMMA identifier LEFT_BRACKET constant_expression RIGHT_BRACKET EQUAL initializer { ES3_ONLY("=", @7, "first-class arrays (array initializer)"); $$ = $1; $$.intermAggregate = context->parseArrayInitDeclarator($$.type, $1.intermAggregate, @3, *$3.string, @4, $5, @7, $8); } | init_declarator_list COMMA identifier EQUAL initializer { $$ = $1; $$.intermAggregate = context->parseInitDeclarator($$.type, $1.intermAggregate, @3, *$3.string, @4, $5); } ; single_declaration : fully_specified_type { $$.type = $1; $$.intermAggregate = context->parseSingleDeclaration($$.type, @1, ""); } | fully_specified_type identifier { $$.type = $1; $$.intermAggregate = context->parseSingleDeclaration($$.type, @2, *$2.string); } | fully_specified_type identifier LEFT_BRACKET constant_expression RIGHT_BRACKET { $$.type = $1; $$.intermAggregate = context->parseSingleArrayDeclaration($$.type, @2, *$2.string, @3, $4); } | fully_specified_type identifier LEFT_BRACKET RIGHT_BRACKET EQUAL initializer { ES3_ONLY("[]", @3, "implicitly sized array"); $$.type = $1; $$.intermAggregate = context->parseSingleArrayInitDeclaration($$.type, @2, *$2.string, @3, nullptr, @5, $6); } | fully_specified_type identifier LEFT_BRACKET constant_expression RIGHT_BRACKET EQUAL initializer { ES3_ONLY("=", @6, "first-class arrays (array initializer)"); $$.type = $1; $$.intermAggregate = context->parseSingleArrayInitDeclaration($$.type, @2, *$2.string, @3, $4, @6, $7); } | fully_specified_type identifier EQUAL initializer { $$.type = $1; $$.intermAggregate = context->parseSingleInitDeclaration($$.type, @2, *$2.string, @3, $4); } | INVARIANT IDENTIFIER { // $$.type is not used in invariant declarations. $$.intermAggregate = context->parseInvariantDeclaration(@1, @2, $2.string, $2.symbol); } ; fully_specified_type : type_specifier { $$ = $1; if ($1.array) { ES3_ONLY("[]", @1, "first-class-array"); if (context->getShaderVersion() != 300) { $1.clearArrayness(); } } } | type_qualifier type_specifier { $$ = context->addFullySpecifiedType($1.qualifier, $1.invariant, $1.layoutQualifier, $2); } ; interpolation_qualifier : SMOOTH { $$.qualifier = EvqSmooth; } | FLAT { $$.qualifier = EvqFlat; } ; parameter_type_qualifier : CONST_QUAL { $$ = EvqConst; } ; type_qualifier : ATTRIBUTE { VERTEX_ONLY("attribute", @1); ES2_ONLY("attribute", @1); if (context->globalErrorCheck(@1, context->symbolTable.atGlobalLevel(), "attribute")) context->recover(); $$.setBasic(EbtVoid, EvqAttribute, @1); } | VARYING { ES2_ONLY("varying", @1); if (context->globalErrorCheck(@1, context->symbolTable.atGlobalLevel(), "varying")) context->recover(); if (context->getShaderType() == GL_VERTEX_SHADER) $$.setBasic(EbtVoid, EvqVaryingOut, @1); else $$.setBasic(EbtVoid, EvqVaryingIn, @1); } | INVARIANT VARYING { ES2_ONLY("varying", @1); if (context->globalErrorCheck(@1, context->symbolTable.atGlobalLevel(), "invariant varying")) context->recover(); if (context->getShaderType() == GL_VERTEX_SHADER) $$.setBasic(EbtVoid, EvqVaryingOut, @1); else $$.setBasic(EbtVoid, EvqVaryingIn, @1); $$.invariant = true; } | storage_qualifier { if ($1.qualifier != EvqConst && !context->symbolTable.atGlobalLevel()) { context->error(@1, "Local variables can only use the const storage qualifier.", getQualifierString($1.qualifier)); context->recover(); } else { $$.setBasic(EbtVoid, $1.qualifier, @1); } } | interpolation_qualifier storage_qualifier { $$ = context->joinInterpolationQualifiers(@1, $1.qualifier, @2, $2.qualifier); } | interpolation_qualifier { context->error(@1, "interpolation qualifier requires a fragment 'in' or vertex 'out' storage qualifier", getInterpolationString($1.qualifier)); context->recover(); TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtVoid, qual, @1); } | layout_qualifier { $$.qualifier = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.layoutQualifier = $1; } | layout_qualifier storage_qualifier { $$.setBasic(EbtVoid, $2.qualifier, @2); $$.layoutQualifier = $1; } | INVARIANT storage_qualifier { context->es3InvariantErrorCheck($2.qualifier, @1); $$.setBasic(EbtVoid, $2.qualifier, @2); $$.invariant = true; } | INVARIANT interpolation_qualifier storage_qualifier { context->es3InvariantErrorCheck($3.qualifier, @1); $$ = context->joinInterpolationQualifiers(@2, $2.qualifier, @3, $3.qualifier); $$.invariant = true; } ; storage_qualifier : CONST_QUAL { $$.qualifier = EvqConst; } | IN_QUAL { ES3_ONLY("in", @1, "storage qualifier"); $$.qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentIn : EvqVertexIn; } | OUT_QUAL { ES3_ONLY("out", @1, "storage qualifier"); $$.qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqVertexOut; } | CENTROID IN_QUAL { ES3_ONLY("centroid in", @1, "storage qualifier"); if (context->getShaderType() == GL_VERTEX_SHADER) { context->error(@1, "invalid storage qualifier", "it is an error to use 'centroid in' in the vertex shader"); context->recover(); } $$.qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqCentroidIn : EvqVertexIn; } | CENTROID OUT_QUAL { ES3_ONLY("centroid out", @1, "storage qualifier"); if (context->getShaderType() == GL_FRAGMENT_SHADER) { context->error(@1, "invalid storage qualifier", "it is an error to use 'centroid out' in the fragment shader"); context->recover(); } $$.qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqCentroidOut; } | UNIFORM { if (context->globalErrorCheck(@1, context->symbolTable.atGlobalLevel(), "uniform")) context->recover(); $$.qualifier = EvqUniform; } ; type_specifier : type_specifier_no_prec { $$ = $1; if ($$.precision == EbpUndefined) { $$.precision = context->symbolTable.getDefaultPrecision($1.type); if (context->precisionErrorCheck(@1, $$.precision, $1.type)) { context->recover(); } } } | precision_qualifier type_specifier_no_prec { $$ = $2; $$.precision = $1; if (!SupportsPrecision($2.type)) { context->error(@1, "illegal type for precision qualifier", getBasicString($2.type)); context->recover(); } } ; precision_qualifier : HIGH_PRECISION { $$ = EbpHigh; } | MEDIUM_PRECISION { $$ = EbpMedium; } | LOW_PRECISION { $$ = EbpLow; } ; layout_qualifier : LAYOUT LEFT_PAREN layout_qualifier_id_list RIGHT_PAREN { ES3_ONLY("layout", @1, "qualifier"); $$ = $3; } ; layout_qualifier_id_list : layout_qualifier_id { $$ = $1; } | layout_qualifier_id_list COMMA layout_qualifier_id { $$ = context->joinLayoutQualifiers($1, $3); } ; layout_qualifier_id : IDENTIFIER { $$ = context->parseLayoutQualifier(*$1.string, @1); } | IDENTIFIER EQUAL INTCONSTANT { $$ = context->parseLayoutQualifier(*$1.string, @1, *$3.string, $3.i, @3); } | IDENTIFIER EQUAL UINTCONSTANT { $$ = context->parseLayoutQualifier(*$1.string, @1, *$3.string, $3.i, @3); } ; type_specifier_no_prec : type_specifier_nonarray { $$ = $1; } | type_specifier_nonarray LEFT_BRACKET RIGHT_BRACKET { ES3_ONLY("[]", @2, "implicitly sized array"); $$ = $1; $$.setArraySize(0); } | type_specifier_nonarray LEFT_BRACKET constant_expression RIGHT_BRACKET { $$ = $1; if (context->arrayTypeErrorCheck(@2, $1)) context->recover(); else { int size; if (context->arraySizeErrorCheck(@2, $3, size)) context->recover(); $$.setArraySize(size); } } ; type_specifier_nonarray : VOID_TYPE { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtVoid, qual, @1); } | FLOAT_TYPE { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, @1); } | INT_TYPE { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtInt, qual, @1); } | UINT_TYPE { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtUInt, qual, @1); } | BOOL_TYPE { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtBool, qual, @1); } | VEC2 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, @1); $$.setAggregate(2); } | VEC3 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, @1); $$.setAggregate(3); } | VEC4 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, @1); $$.setAggregate(4); } | BVEC2 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtBool, qual, @1); $$.setAggregate(2); } | BVEC3 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtBool, qual, @1); $$.setAggregate(3); } | BVEC4 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtBool, qual, @1); $$.setAggregate(4); } | IVEC2 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtInt, qual, @1); $$.setAggregate(2); } | IVEC3 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtInt, qual, @1); $$.setAggregate(3); } | IVEC4 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtInt, qual, @1); $$.setAggregate(4); } | UVEC2 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtUInt, qual, @1); $$.setAggregate(2); } | UVEC3 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtUInt, qual, @1); $$.setAggregate(3); } | UVEC4 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtUInt, qual, @1); $$.setAggregate(4); } | MATRIX2 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, @1); $$.setMatrix(2, 2); } | MATRIX3 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, @1); $$.setMatrix(3, 3); } | MATRIX4 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, @1); $$.setMatrix(4, 4); } | MATRIX2x3 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, @1); $$.setMatrix(2, 3); } | MATRIX3x2 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, @1); $$.setMatrix(3, 2); } | MATRIX2x4 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, @1); $$.setMatrix(2, 4); } | MATRIX4x2 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, @1); $$.setMatrix(4, 2); } | MATRIX3x4 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, @1); $$.setMatrix(3, 4); } | MATRIX4x3 { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, @1); $$.setMatrix(4, 3); } | SAMPLER2D { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtSampler2D, qual, @1); } | SAMPLER3D { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtSampler3D, qual, @1); } | SAMPLERCUBE { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtSamplerCube, qual, @1); } | SAMPLER2DARRAY { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtSampler2DArray, qual, @1); } | ISAMPLER2D { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtISampler2D, qual, @1); } | ISAMPLER3D { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtISampler3D, qual, @1); } | ISAMPLERCUBE { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtISamplerCube, qual, @1); } | ISAMPLER2DARRAY { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtISampler2DArray, qual, @1); } | USAMPLER2D { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtUSampler2D, qual, @1); } | USAMPLER3D { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtUSampler3D, qual, @1); } | USAMPLERCUBE { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtUSamplerCube, qual, @1); } | USAMPLER2DARRAY { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtUSampler2DArray, qual, @1); } | SAMPLER2DSHADOW { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtSampler2DShadow, qual, @1); } | SAMPLERCUBESHADOW { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtSamplerCubeShadow, qual, @1); } | SAMPLER2DARRAYSHADOW { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtSampler2DArrayShadow, qual, @1); } | SAMPLER_EXTERNAL_OES { if (!context->supportsExtension("GL_OES_EGL_image_external")) { context->error(@1, "unsupported type", "samplerExternalOES"); context->recover(); } TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtSamplerExternalOES, qual, @1); } | SAMPLER2DRECT { if (!context->supportsExtension("GL_ARB_texture_rectangle")) { context->error(@1, "unsupported type", "sampler2DRect"); context->recover(); } TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtSampler2DRect, qual, @1); } | struct_specifier { $$ = $1; $$.qualifier = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; } | TYPE_NAME { // // This is for user defined type names. The lexical phase looked up the // type. // TType& structure = static_cast($1.symbol)->getType(); TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtStruct, qual, @1); $$.userDef = &structure; } ; struct_specifier : STRUCT identifier LEFT_BRACE { if (context->enterStructDeclaration(@2, *$2.string)) context->recover(); } struct_declaration_list RIGHT_BRACE { $$ = context->addStructure(@1, @2, $2.string, $5); } | STRUCT LEFT_BRACE { if (context->enterStructDeclaration(@2, *$2.string)) context->recover(); } struct_declaration_list RIGHT_BRACE { $$ = context->addStructure(@1, @$, NewPoolTString(""), $4); } ; struct_declaration_list : struct_declaration { $$ = $1; } | struct_declaration_list struct_declaration { $$ = $1; for (size_t i = 0; i < $2->size(); ++i) { TField* field = (*$2)[i]; for (size_t j = 0; j < $$->size(); ++j) { if ((*$$)[j]->name() == field->name()) { context->error(@2, "duplicate field name in structure:", "struct", field->name().c_str()); context->recover(); } } $$->push_back(field); } } ; struct_declaration : type_specifier struct_declarator_list SEMICOLON { $$ = context->addStructDeclaratorList($1, $2); } | type_qualifier type_specifier struct_declarator_list SEMICOLON { // ES3 Only, but errors should be handled elsewhere $2.qualifier = $1.qualifier; $2.layoutQualifier = $1.layoutQualifier; $$ = context->addStructDeclaratorList($2, $3); } ; struct_declarator_list : struct_declarator { $$ = NewPoolTFieldList(); $$->push_back($1); } | struct_declarator_list COMMA struct_declarator { $$->push_back($3); } ; struct_declarator : identifier { if (context->reservedErrorCheck(@1, *$1.string)) context->recover(); TType* type = new TType(EbtVoid, EbpUndefined); $$ = new TField(type, $1.string, @1); } | identifier LEFT_BRACKET constant_expression RIGHT_BRACKET { if (context->reservedErrorCheck(@1, *$1.string)) context->recover(); TType* type = new TType(EbtVoid, EbpUndefined); int size; if (context->arraySizeErrorCheck(@3, $3, size)) context->recover(); type->setArraySize(size); $$ = new TField(type, $1.string, @1); } ; initializer : assignment_expression { $$ = $1; } ; declaration_statement : declaration { $$ = $1; } ; statement : compound_statement { $$ = $1; } | simple_statement { $$ = $1; } ; // Grammar Note: Labeled statements for SWITCH only; 'goto' is not supported. simple_statement : declaration_statement { $$ = $1; } | expression_statement { $$ = $1; } | selection_statement { $$ = $1; } | switch_statement { $$ = $1; } | case_label { $$ = $1; } | iteration_statement { $$ = $1; } | jump_statement { $$ = $1; } ; compound_statement : LEFT_BRACE RIGHT_BRACE { $$ = 0; } | LEFT_BRACE { context->symbolTable.push(); } statement_list { context->symbolTable.pop(); } RIGHT_BRACE { if ($3 != 0) { $3->setOp(EOpSequence); $3->setLine(@$); } $$ = $3; } ; statement_no_new_scope : compound_statement_no_new_scope { $$ = $1; } | simple_statement { $$ = $1; } ; statement_with_scope : { context->symbolTable.push(); } compound_statement_no_new_scope { context->symbolTable.pop(); $$ = $2; } | { context->symbolTable.push(); } simple_statement { context->symbolTable.pop(); $$ = $2; } ; compound_statement_no_new_scope // Statement that doesn't create a new scope, for selection_statement, iteration_statement : LEFT_BRACE RIGHT_BRACE { $$ = 0; } | LEFT_BRACE statement_list RIGHT_BRACE { if ($2) { $2->setOp(EOpSequence); $2->setLine(@$); } $$ = $2; } ; statement_list : statement { $$ = context->intermediate.makeAggregate($1, @$); } | statement_list statement { $$ = context->intermediate.growAggregate($1, $2, @$); } ; expression_statement : SEMICOLON { $$ = 0; } | expression SEMICOLON { $$ = static_cast($1); } ; selection_statement : IF LEFT_PAREN expression RIGHT_PAREN selection_rest_statement { if (context->boolErrorCheck(@1, $3)) context->recover(); $$ = context->intermediate.addSelection($3, $5, @1); } ; selection_rest_statement : statement_with_scope ELSE statement_with_scope { $$.node1 = $1; $$.node2 = $3; } | statement_with_scope { $$.node1 = $1; $$.node2 = 0; } ; switch_statement : SWITCH LEFT_PAREN expression RIGHT_PAREN { context->incrSwitchNestingLevel(); } compound_statement { $$ = context->addSwitch($3, $6, @1); context->decrSwitchNestingLevel(); } ; case_label : CASE constant_expression COLON { $$ = context->addCase($2, @1); } | DEFAULT COLON { $$ = context->addDefault(@1); } ; condition // In 1996 c++ draft, conditions can include single declarations : expression { $$ = $1; if (context->boolErrorCheck($1->getLine(), $1)) context->recover(); } | fully_specified_type identifier EQUAL initializer { TIntermNode *intermNode; if (context->boolErrorCheck(@2, $1)) context->recover(); if (!context->executeInitializer(@2, *$2.string, $1, $4, &intermNode)) $$ = $4; else { context->recover(); $$ = 0; } } ; iteration_statement : WHILE LEFT_PAREN { context->symbolTable.push(); context->incrLoopNestingLevel(); } condition RIGHT_PAREN statement_no_new_scope { context->symbolTable.pop(); $$ = context->intermediate.addLoop(ELoopWhile, 0, $4, 0, $6, @1); context->decrLoopNestingLevel(); } | DO { context->incrLoopNestingLevel(); } statement_with_scope WHILE LEFT_PAREN expression RIGHT_PAREN SEMICOLON { if (context->boolErrorCheck(@8, $6)) context->recover(); $$ = context->intermediate.addLoop(ELoopDoWhile, 0, $6, 0, $3, @4); context->decrLoopNestingLevel(); } | FOR LEFT_PAREN { context->symbolTable.push(); context->incrLoopNestingLevel(); } for_init_statement for_rest_statement RIGHT_PAREN statement_no_new_scope { context->symbolTable.pop(); $$ = context->intermediate.addLoop(ELoopFor, $4, reinterpret_cast($5.node1), reinterpret_cast($5.node2), $7, @1); context->decrLoopNestingLevel(); } ; for_init_statement : expression_statement { $$ = $1; } | declaration_statement { $$ = $1; } ; conditionopt : condition { $$ = $1; } | /* May be null */ { $$ = 0; } ; for_rest_statement : conditionopt SEMICOLON { $$.node1 = $1; $$.node2 = 0; } | conditionopt SEMICOLON expression { $$.node1 = $1; $$.node2 = $3; } ; jump_statement : CONTINUE SEMICOLON { $$ = context->addBranch(EOpContinue, @1); } | BREAK SEMICOLON { $$ = context->addBranch(EOpBreak, @1); } | RETURN SEMICOLON { $$ = context->addBranch(EOpReturn, @1); } | RETURN expression SEMICOLON { $$ = context->addBranch(EOpReturn, $2, @1); } | DISCARD SEMICOLON { FRAG_ONLY("discard", @1); $$ = context->addBranch(EOpKill, @1); } ; // Grammar Note: No 'goto'. Gotos are not supported. translation_unit : external_declaration { $$ = $1; context->setTreeRoot($$); } | translation_unit external_declaration { $$ = context->intermediate.growAggregate($1, $2, @$); context->setTreeRoot($$); } ; external_declaration : function_definition { $$ = $1; } | declaration { $$ = $1; } ; function_definition : function_prototype { context->parseFunctionPrototype(@1, $1.function, &$1.intermAggregate); } compound_statement_no_new_scope { //?? Check that all paths return a value if return type != void ? // May be best done as post process phase on intermediate code if (context->getCurrentFunctionType()->getBasicType() != EbtVoid && !context->getFunctionReturnsValue()) { context->error(@1, "function does not return a value:", "", $1.function->getName().c_str()); context->recover(); } $$ = context->intermediate.growAggregate($1.intermAggregate, $3, @$); context->intermediate.setAggregateOperator($$, EOpFunction, @1); $$->getAsAggregate()->setName($1.function->getMangledName().c_str()); $$->getAsAggregate()->setType($1.function->getReturnType()); $$->getAsAggregate()->setFunctionId($1.function->getUniqueId()); // store the pragma information for debug and optimize and other vendor specific // information. This information can be queried from the parse tree $$->getAsAggregate()->setOptimize(context->pragma().optimize); $$->getAsAggregate()->setDebug(context->pragma().debug); context->symbolTable.pop(); } ; %% int glslang_parse(TParseContext* context) { return yyparse(context, context->getScanner()); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/glslang_lex.cpp000066400000000000000000003116201321746453100277320ustar00rootroot00000000000000#line 17 "./glslang.l" // // Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // This file is auto-generated by generate_parser.sh. DO NOT EDIT! // Ignore errors in auto-generated code. #if defined(__GNUC__) #pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wswitch-enum" #elif defined(_MSC_VER) #pragma warning(disable: 4005) #pragma warning(disable: 4065) #pragma warning(disable: 4189) #pragma warning(disable: 4244) #pragma warning(disable: 4505) #pragma warning(disable: 4701) #pragma warning(disable: 4702) #endif #line 28 "./glslang_lex.cpp" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_SUBMINOR_VERSION 39 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ #include #include #include #include /* end standard C headers. */ /* flex integer type definitions */ #ifndef FLEXINT_H #define FLEXINT_H /* C99 systems have . Non-C99 systems may or may not. */ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 #endif #include typedef int8_t flex_int8_t; typedef uint8_t flex_uint8_t; typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; /* Limits of integral types. */ #ifndef INT8_MIN #define INT8_MIN (-128) #endif #ifndef INT16_MIN #define INT16_MIN (-32767-1) #endif #ifndef INT32_MIN #define INT32_MIN (-2147483647-1) #endif #ifndef INT8_MAX #define INT8_MAX (127) #endif #ifndef INT16_MAX #define INT16_MAX (32767) #endif #ifndef INT32_MAX #define INT32_MAX (2147483647) #endif #ifndef UINT8_MAX #define UINT8_MAX (255U) #endif #ifndef UINT16_MAX #define UINT16_MAX (65535U) #endif #ifndef UINT32_MAX #define UINT32_MAX (4294967295U) #endif #endif /* ! C99 */ #endif /* ! FLEXINT_H */ #ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ /* C99 requires __STDC__ to be defined as 1. */ #if defined (__STDC__) #define YY_USE_CONST #endif /* defined (__STDC__) */ #endif /* ! __cplusplus */ #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif /* Returned upon end-of-file. */ #define YY_NULL 0 /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* An opaque pointer. */ #ifndef YY_TYPEDEF_YY_SCANNER_T #define YY_TYPEDEF_YY_SCANNER_T typedef void* yyscan_t; #endif /* For convenience, these vars (plus the bison vars far below) are macros in the reentrant scanner. */ #define yyin yyg->yyin_r #define yyout yyg->yyout_r #define yyextra yyg->yyextra_r #define yyleng yyg->yyleng_r #define yytext yyg->yytext_r #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) #define yy_flex_debug yyg->yy_flex_debug_r /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN yyg->yy_start = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START ((yyg->yy_start - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ #define YY_NEW_FILE yyrestart(yyin ,yyscanner ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #ifndef YY_BUF_SIZE #define YY_BUF_SIZE 16384 #endif /* The state buf must be large enough to hold one state per character in the main buffer. */ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; #endif #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; #endif #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires * access to the local variable yy_act. Since yyless() is a macro, it would break * existing scanners that call yyless() from OUTSIDE yylex. * One obvious solution it to make yy_act a global. I tried that, and saw * a 5% performance hit in a non-yylineno scanner, because yy_act is * normally declared as a register variable-- so it is not worth it. */ #define YY_LESS_LINENO(n) \ do { \ yy_size_t yyl;\ for ( yyl = n; yyl < yyleng; ++yyl )\ if ( yytext[yyl] == '\n' )\ --yylineno;\ }while(0) #define YY_LINENO_REWIND_TO(dst) \ do {\ const char *p;\ for ( p = yy_cp-1; p >= (dst); --p)\ if ( *p == '\n' )\ --yylineno;\ }while(0) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = yyg->yy_hold_char; \ YY_RESTORE_YY_MORE_OFFSET \ yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { FILE *yy_input_file; char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ yy_size_t yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to * delete it. */ int yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after * each newline. */ int yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might * still have a bunch of tokens to match, though, because of * possible backing-up. * * When we actually see the EOF, we change the status to "new" * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". * * Returns the top of the stack, or NULL. */ #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ : NULL) /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] void yyrestart (FILE *input_file ,yyscan_t yyscanner ); void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); void yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); void yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); void yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); void yypop_buffer_state (yyscan_t yyscanner ); static void yyensure_buffer_stack (yyscan_t yyscanner ); static void yy_load_buffer_state (yyscan_t yyscanner ); static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner ); void *yyalloc (yy_size_t ,yyscan_t yyscanner ); void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); void yyfree (void * ,yyscan_t yyscanner ); #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ yyensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ yyensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ #define yywrap(yyscanner) 1 #define YY_SKIP_YYWRAP typedef unsigned char YY_CHAR; typedef int yy_state_type; #define yytext_ptr yytext_r static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); static int yy_get_next_buffer (yyscan_t yyscanner ); static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ yyg->yytext_ptr = yy_bp; \ yyleng = (yy_size_t) (yy_cp - yy_bp); \ yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; #define YY_NUM_RULES 239 #define YY_END_OF_BUFFER 240 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info { flex_int32_t yy_verify; flex_int32_t yy_nxt; }; static yyconst flex_int16_t yy_accept[819] = { 0, 0, 0, 0, 0, 240, 238, 237, 237, 222, 228, 233, 217, 218, 226, 225, 214, 223, 221, 227, 180, 180, 215, 211, 229, 216, 230, 234, 177, 219, 220, 232, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 212, 231, 213, 224, 236, 239, 235, 208, 194, 213, 202, 197, 192, 200, 190, 201, 191, 186, 193, 185, 179, 180, 0, 183, 0, 220, 212, 219, 209, 205, 207, 206, 210, 177, 198, 204, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 12, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 15, 177, 177, 23, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 199, 203, 235, 0, 189, 185, 0, 188, 182, 0, 184, 178, 195, 196, 177, 136, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 13, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 27, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 24, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 0, 186, 0, 185, 187, 181, 177, 177, 177, 30, 177, 177, 18, 174, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 16, 139, 177, 177, 177, 177, 21, 177, 177, 143, 155, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 152, 4, 35, 36, 37, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 142, 31, 177, 177, 28, 177, 177, 177, 177, 177, 177, 177, 47, 48, 49, 29, 177, 177, 177, 177, 177, 177, 10, 53, 54, 55, 177, 137, 177, 177, 7, 177, 177, 177, 177, 164, 165, 166, 177, 32, 177, 156, 26, 167, 168, 169, 2, 161, 162, 163, 177, 177, 177, 25, 159, 177, 177, 177, 50, 51, 52, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 86, 177, 177, 177, 177, 177, 177, 177, 153, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 138, 177, 177, 176, 56, 57, 58, 177, 177, 14, 177, 91, 177, 177, 177, 177, 89, 177, 177, 177, 154, 149, 92, 177, 177, 177, 177, 177, 177, 144, 177, 177, 177, 78, 38, 41, 43, 42, 39, 45, 44, 46, 40, 177, 177, 177, 177, 160, 135, 177, 177, 147, 177, 177, 177, 34, 87, 173, 22, 148, 77, 177, 158, 17, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 19, 33, 177, 177, 177, 177, 177, 177, 93, 94, 95, 177, 177, 177, 177, 177, 3, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 140, 177, 177, 177, 177, 177, 8, 177, 177, 9, 177, 177, 177, 177, 20, 79, 11, 150, 97, 98, 99, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 145, 177, 177, 177, 81, 83, 80, 177, 177, 177, 177, 177, 177, 177, 141, 101, 102, 103, 177, 177, 157, 177, 146, 177, 177, 6, 177, 177, 177, 177, 177, 177, 177, 177, 177, 96, 151, 1, 177, 177, 177, 177, 177, 175, 177, 90, 5, 170, 59, 62, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 82, 177, 177, 177, 177, 100, 177, 177, 177, 177, 177, 120, 66, 67, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 88, 177, 177, 177, 104, 122, 70, 71, 177, 177, 84, 177, 177, 177, 177, 177, 177, 177, 115, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 129, 177, 177, 177, 177, 60, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 116, 105, 177, 106, 177, 177, 177, 130, 177, 177, 68, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 117, 177, 177, 131, 177, 177, 72, 107, 108, 177, 111, 177, 112, 177, 177, 177, 177, 177, 85, 177, 177, 177, 177, 64, 177, 63, 126, 177, 177, 109, 110, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 124, 127, 118, 177, 65, 177, 177, 177, 177, 177, 177, 177, 177, 125, 128, 177, 177, 121, 69, 177, 177, 171, 177, 177, 177, 74, 177, 177, 123, 73, 177, 177, 177, 177, 177, 177, 132, 177, 177, 177, 177, 177, 177, 133, 177, 177, 177, 75, 177, 134, 113, 114, 177, 177, 177, 61, 177, 177, 172, 119, 76, 0 } ; static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 1, 1, 1, 5, 6, 1, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 20, 21, 21, 22, 23, 24, 25, 26, 27, 1, 28, 29, 30, 31, 32, 33, 34, 34, 34, 34, 34, 34, 35, 34, 36, 34, 34, 37, 38, 34, 39, 34, 34, 40, 34, 34, 41, 1, 42, 43, 44, 1, 45, 46, 47, 48, 49, 50, 51, 52, 53, 34, 54, 55, 56, 57, 58, 59, 34, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; static yyconst flex_int32_t yy_meta[73] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 2, 2, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 4, 3, 3, 3, 3, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1 } ; static yyconst flex_int16_t yy_base[824] = { 0, 0, 0, 72, 0, 1016, 1017, 1017, 1017, 990, 120, 141, 1017, 1017, 989, 138, 1017, 137, 135, 988, 154, 208, 986, 1017, 154, 986, 132, 1017, 0, 1017, 1017, 139, 130, 123, 140, 147, 133, 177, 952, 186, 151, 139, 116, 161, 946, 173, 959, 193, 199, 208, 215, 108, 1017, 184, 1017, 1017, 1017, 1017, 0, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 230, 1017, 235, 235, 0, 271, 1017, 0, 1017, 1017, 1017, 982, 1017, 1017, 1017, 981, 0, 1017, 1017, 943, 948, 152, 945, 953, 952, 939, 942, 953, 243, 947, 935, 932, 945, 932, 929, 929, 935, 147, 248, 929, 939, 925, 931, 934, 935, 0, 927, 937, 249, 936, 931, 912, 177, 916, 929, 920, 184, 913, 250, 925, 927, 257, 916, 913, 902, 911, 249, 257, 915, 911, 913, 902, 905, 196, 217, 269, 914, 902, 914, 262, 907, 906, 1017, 1017, 0, 311, 1017, 292, 328, 1017, 1017, 335, 342, 257, 1017, 1017, 905, 0, 901, 896, 900, 909, 906, 315, 890, 890, 901, 893, 215, 903, 900, 900, 898, 895, 887, 893, 880, 878, 890, 876, 892, 0, 889, 877, 884, 881, 885, 886, 879, 876, 865, 864, 877, 880, 868, 876, 864, 870, 861, 316, 866, 869, 860, 867, 856, 860, 851, 865, 864, 855, 861, 307, 845, 848, 846, 856, 846, 841, 839, 841, 851, 837, 839, 836, 847, 846, 849, 831, 316, 839, 835, 833, 842, 821, 353, 839, 841, 830, 822, 363, 370, 378, 389, 1017, 1017, 819, 829, 828, 0, 826, 383, 0, 0, 819, 817, 817, 818, 813, 821, 810, 827, 816, 394, 0, 0, 810, 820, 819, 819, 0, 804, 397, 0, 0, 806, 400, 813, 814, 805, 799, 798, 799, 798, 798, 406, 793, 0, 0, 789, 788, 787, 789, 790, 795, 789, 785, 798, 793, 793, 791, 790, 784, 778, 780, 779, 783, 775, 778, 773, 781, 786, 774, 771, 783, 774, 0, 0, 780, 776, 0, 768, 768, 773, 764, 771, 409, 768, 0, 0, 0, 0, 758, 770, 769, 768, 769, 769, 0, 0, 0, 0, 756, 0, 764, 755, 0, 754, 755, 749, 759, 0, 0, 0, 750, 0, 746, 0, 0, 0, 0, 0, 0, 0, 0, 0, 756, 413, 755, 0, 0, 753, 749, 746, 0, 0, 0, 738, 415, 418, 427, 743, 739, 744, 735, 733, 746, 731, 0, 731, 744, 733, 729, 735, 730, 737, 0, 735, 732, 736, 720, 718, 721, 727, 733, 728, 727, 715, 0, 717, 718, 0, 0, 0, 0, 715, 718, 0, 712, 0, 725, 705, 714, 709, 0, 702, 702, 715, 0, 717, 0, 431, 730, 729, 728, 695, 694, 0, 711, 710, 705, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 694, 707, 694, 691, 0, 0, 696, 695, 0, 692, 699, 698, 0, 684, 0, 0, 0, 0, 681, 0, 0, 680, 691, 434, 684, 690, 689, 686, 681, 678, 671, 671, 684, 669, 681, 0, 0, 674, 697, 696, 695, 662, 661, 427, 428, 0, 673, 676, 674, 663, 659, 0, 671, 668, 667, 657, 656, 646, 663, 649, 441, 657, 660, 0, 677, 676, 675, 642, 641, 0, 655, 642, 0, 652, 645, 646, 649, 0, 0, 0, 0, 669, 668, 0, 645, 648, 633, 640, 631, 638, 639, 639, 638, 624, 451, 636, 0, 637, 626, 625, 0, 0, 0, 650, 649, 648, 615, 614, 610, 618, 0, 646, 645, 0, 622, 625, 0, 458, 0, 603, 612, 0, 608, 607, 616, 616, 604, 618, 602, 616, 611, 0, 0, 0, 628, 627, 626, 593, 592, 0, 592, 0, 0, 434, 454, 616, 602, 605, 588, 600, 588, 587, 596, 596, 613, 612, 611, 578, 577, 0, 577, 578, 577, 587, 0, 590, 586, 588, 584, 571, 602, 449, 0, 579, 582, 574, 566, 573, 564, 585, 573, 569, 571, 569, 569, 568, 0, 556, 555, 565, 0, 585, 462, 0, 562, 565, 0, 565, 564, 548, 540, 548, 538, 546, 0, 543, 542, 563, 551, 549, 549, 533, 536, 550, 534, 565, 545, 546, 543, 540, 550, 527, 541, 540, 524, 523, 522, 543, 531, 529, 529, 510, 509, 0, 537, 509, 535, 507, 511, 510, 541, 521, 518, 0, 517, 520, 516, 518, 502, 499, 512, 497, 498, 505, 499, 488, 487, 0, 493, 492, 523, 503, 500, 0, 0, 0, 496, 0, 495, 0, 501, 500, 484, 481, 482, 0, 474, 482, 472, 478, 499, 478, 0, 0, 490, 489, 0, 0, 488, 487, 471, 468, 469, 483, 482, 459, 458, 464, 0, 0, 485, 457, 483, 475, 467, 453, 132, 161, 177, 215, 245, 0, 0, 288, 289, 0, 0, 294, 315, 0, 316, 306, 331, 0, 363, 402, 0, 0, 395, 383, 395, 387, 433, 434, 0, 435, 420, 461, 427, 430, 431, 0, 450, 452, 443, 0, 464, 0, 0, 0, 445, 446, 440, 0, 441, 442, 0, 0, 0, 1017, 506, 509, 512, 513, 514 } ; static yyconst flex_int16_t yy_def[824] = { 0, 818, 1, 818, 3, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 819, 818, 818, 818, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 818, 818, 818, 818, 818, 818, 820, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 821, 818, 822, 20, 21, 818, 818, 823, 818, 818, 818, 818, 818, 818, 818, 818, 819, 818, 818, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 818, 818, 820, 818, 818, 822, 818, 818, 818, 818, 818, 823, 818, 818, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 818, 818, 818, 818, 818, 818, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, 0, 818, 818, 818, 818, 818 } ; static yyconst flex_int16_t yy_nxt[1090] = { 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 21, 21, 21, 21, 21, 22, 23, 24, 25, 26, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 30, 31, 28, 32, 33, 34, 35, 36, 37, 38, 39, 40, 28, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 28, 28, 28, 52, 53, 54, 55, 6, 56, 57, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 6, 6, 6, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 6, 6, 6, 6, 60, 61, 62, 65, 67, 69, 69, 69, 69, 69, 69, 69, 83, 84, 78, 149, 122, 68, 66, 86, 123, 63, 71, 150, 72, 72, 72, 72, 72, 72, 73, 79, 88, 80, 81, 783, 91, 87, 92, 120, 94, 74, 93, 102, 95, 103, 89, 90, 75, 76, 96, 98, 121, 97, 104, 99, 114, 186, 74, 115, 100, 124, 116, 117, 151, 167, 101, 118, 187, 168, 119, 784, 75, 127, 125, 76, 71, 105, 73, 73, 73, 73, 73, 73, 73, 106, 111, 107, 128, 206, 108, 129, 211, 131, 112, 74, 109, 207, 212, 785, 132, 133, 75, 138, 134, 113, 139, 235, 236, 152, 135, 136, 74, 137, 140, 146, 142, 154, 155, 147, 143, 141, 157, 158, 144, 237, 75, 145, 148, 159, 818, 266, 267, 238, 154, 155, 160, 786, 160, 157, 158, 161, 161, 161, 161, 161, 161, 161, 188, 226, 175, 253, 214, 159, 176, 177, 818, 219, 228, 198, 787, 189, 199, 200, 227, 215, 201, 216, 202, 239, 244, 229, 245, 220, 221, 253, 248, 240, 248, 157, 158, 249, 249, 249, 249, 249, 249, 249, 297, 298, 299, 788, 789, 250, 790, 250, 157, 158, 251, 251, 251, 251, 251, 251, 251, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 260, 311, 329, 791, 792, 312, 336, 337, 338, 793, 330, 252, 794, 261, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 252, 251, 251, 251, 251, 251, 251, 251, 347, 348, 349, 155, 251, 251, 251, 251, 251, 251, 251, 359, 360, 361, 367, 368, 369, 371, 372, 373, 155, 795, 158, 382, 383, 384, 420, 421, 422, 440, 441, 442, 450, 451, 452, 453, 454, 455, 796, 158, 797, 798, 443, 444, 456, 457, 458, 497, 498, 499, 523, 524, 525, 799, 800, 545, 547, 562, 563, 564, 500, 501, 635, 526, 527, 546, 548, 593, 594, 595, 565, 566, 636, 567, 613, 614, 615, 665, 801, 802, 596, 597, 637, 803, 666, 804, 667, 616, 617, 638, 685, 639, 640, 805, 806, 807, 808, 686, 809, 687, 810, 811, 812, 813, 814, 815, 816, 817, 85, 85, 85, 153, 153, 153, 69, 156, 162, 162, 782, 781, 780, 779, 778, 777, 776, 775, 774, 773, 772, 771, 770, 769, 768, 767, 766, 765, 764, 763, 762, 761, 760, 759, 758, 757, 756, 755, 754, 753, 752, 751, 750, 749, 748, 747, 746, 745, 744, 743, 742, 741, 740, 739, 738, 737, 736, 735, 734, 733, 732, 731, 730, 729, 728, 727, 726, 725, 724, 723, 722, 721, 720, 719, 718, 717, 716, 715, 714, 713, 712, 711, 710, 709, 708, 707, 706, 705, 704, 703, 702, 701, 700, 699, 698, 697, 696, 695, 694, 693, 692, 691, 690, 689, 688, 684, 683, 682, 681, 680, 679, 678, 677, 676, 675, 674, 673, 672, 671, 670, 669, 668, 664, 663, 662, 661, 660, 659, 658, 657, 656, 655, 654, 653, 652, 651, 650, 649, 648, 647, 646, 645, 644, 643, 642, 641, 634, 633, 632, 631, 630, 629, 628, 627, 626, 625, 624, 623, 622, 621, 620, 619, 618, 612, 611, 610, 609, 608, 607, 606, 605, 604, 603, 602, 601, 600, 599, 598, 592, 591, 590, 589, 588, 587, 586, 585, 584, 583, 582, 581, 580, 579, 578, 577, 576, 575, 574, 573, 572, 571, 570, 569, 568, 561, 560, 559, 558, 557, 556, 555, 554, 553, 552, 551, 550, 549, 544, 543, 542, 541, 540, 539, 538, 537, 536, 535, 534, 533, 532, 531, 530, 529, 528, 522, 521, 520, 519, 518, 517, 516, 515, 514, 513, 512, 511, 510, 509, 508, 507, 506, 505, 504, 503, 502, 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, 486, 485, 484, 483, 482, 481, 480, 479, 478, 477, 476, 475, 474, 473, 472, 471, 470, 469, 468, 467, 466, 465, 464, 463, 462, 461, 460, 459, 449, 448, 447, 446, 445, 439, 438, 437, 436, 435, 434, 433, 432, 431, 430, 429, 428, 427, 426, 425, 424, 423, 419, 418, 417, 416, 415, 414, 413, 412, 411, 410, 409, 408, 407, 406, 405, 404, 403, 402, 401, 400, 399, 398, 397, 396, 395, 394, 393, 392, 391, 390, 389, 388, 387, 386, 385, 381, 380, 379, 378, 377, 376, 375, 374, 370, 366, 365, 364, 363, 362, 358, 357, 356, 355, 354, 353, 352, 351, 350, 346, 345, 344, 343, 342, 341, 340, 339, 335, 334, 333, 332, 331, 328, 327, 326, 325, 324, 323, 322, 321, 320, 319, 318, 317, 316, 315, 314, 313, 310, 309, 308, 307, 306, 305, 304, 303, 302, 301, 300, 296, 295, 294, 293, 292, 291, 290, 289, 288, 287, 286, 285, 284, 283, 282, 281, 280, 279, 278, 277, 276, 275, 274, 273, 272, 271, 270, 269, 268, 265, 264, 263, 262, 259, 258, 257, 256, 255, 254, 247, 246, 243, 242, 241, 234, 233, 232, 231, 230, 225, 224, 223, 222, 218, 217, 213, 210, 209, 208, 205, 204, 203, 197, 196, 195, 194, 193, 192, 191, 190, 185, 184, 183, 182, 181, 180, 179, 178, 174, 173, 172, 171, 170, 169, 166, 165, 164, 163, 130, 126, 110, 82, 77, 70, 64, 59, 818, 5, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818 } ; static yyconst flex_int16_t yy_chk[1090] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 10, 10, 11, 15, 17, 18, 18, 18, 18, 18, 18, 18, 26, 26, 24, 51, 42, 17, 15, 31, 42, 11, 20, 51, 20, 20, 20, 20, 20, 20, 20, 24, 32, 24, 24, 765, 33, 31, 33, 41, 34, 20, 33, 36, 34, 36, 32, 32, 20, 20, 34, 35, 41, 34, 36, 35, 40, 106, 20, 40, 35, 43, 40, 40, 53, 90, 35, 40, 106, 90, 40, 766, 20, 45, 43, 20, 21, 37, 21, 21, 21, 21, 21, 21, 21, 37, 39, 37, 45, 121, 37, 45, 125, 47, 39, 21, 37, 121, 125, 767, 47, 47, 21, 48, 47, 39, 48, 142, 142, 53, 47, 47, 21, 47, 48, 50, 49, 69, 69, 50, 49, 48, 71, 71, 49, 143, 21, 49, 50, 72, 72, 177, 177, 143, 69, 69, 74, 768, 74, 71, 71, 74, 74, 74, 74, 74, 74, 74, 107, 135, 97, 162, 127, 72, 97, 97, 72, 130, 136, 117, 769, 107, 117, 117, 135, 127, 117, 127, 117, 144, 148, 136, 148, 130, 130, 162, 154, 144, 154, 156, 156, 154, 154, 154, 154, 154, 154, 154, 208, 208, 208, 772, 773, 157, 776, 157, 156, 156, 157, 157, 157, 157, 157, 157, 157, 160, 160, 160, 160, 160, 160, 160, 161, 161, 161, 161, 161, 161, 161, 172, 220, 237, 777, 779, 220, 243, 243, 243, 780, 237, 161, 781, 172, 248, 248, 248, 248, 248, 248, 248, 249, 249, 249, 249, 249, 249, 249, 161, 250, 250, 250, 250, 250, 250, 250, 259, 259, 259, 249, 251, 251, 251, 251, 251, 251, 251, 271, 271, 271, 280, 280, 280, 284, 284, 284, 249, 783, 251, 293, 293, 293, 334, 334, 334, 375, 375, 375, 386, 386, 386, 387, 387, 387, 784, 251, 787, 788, 375, 375, 388, 388, 388, 439, 439, 439, 482, 482, 482, 789, 790, 502, 503, 519, 519, 519, 439, 439, 602, 482, 482, 502, 503, 553, 553, 553, 519, 519, 602, 519, 576, 576, 576, 630, 791, 792, 553, 553, 603, 794, 630, 795, 630, 576, 576, 603, 651, 603, 603, 796, 797, 798, 799, 651, 801, 651, 802, 803, 805, 809, 810, 811, 813, 814, 819, 819, 819, 820, 820, 820, 821, 822, 823, 823, 764, 763, 762, 761, 760, 759, 756, 755, 754, 753, 752, 751, 750, 749, 748, 747, 744, 743, 740, 739, 738, 737, 736, 735, 733, 732, 731, 730, 729, 727, 725, 721, 720, 719, 718, 717, 715, 714, 713, 712, 711, 710, 709, 708, 707, 706, 705, 704, 703, 701, 700, 699, 698, 697, 696, 695, 694, 693, 691, 690, 689, 688, 687, 686, 685, 684, 683, 682, 681, 680, 679, 678, 677, 676, 675, 674, 673, 672, 671, 670, 669, 668, 667, 666, 665, 664, 662, 661, 660, 659, 658, 657, 656, 654, 653, 650, 648, 647, 646, 644, 643, 642, 641, 640, 639, 638, 637, 636, 635, 634, 633, 632, 629, 628, 627, 626, 625, 624, 622, 621, 620, 619, 617, 616, 615, 614, 613, 612, 611, 610, 609, 608, 607, 606, 605, 604, 599, 597, 596, 595, 594, 593, 589, 588, 587, 586, 585, 584, 583, 582, 581, 579, 578, 574, 573, 571, 570, 568, 567, 566, 565, 564, 563, 562, 558, 557, 556, 554, 552, 551, 550, 549, 548, 547, 546, 545, 544, 543, 541, 540, 535, 534, 533, 532, 530, 529, 527, 526, 525, 524, 523, 521, 520, 518, 517, 516, 515, 514, 513, 512, 511, 509, 508, 507, 506, 505, 501, 500, 499, 498, 497, 496, 493, 492, 491, 490, 489, 488, 487, 486, 485, 484, 483, 481, 480, 477, 472, 470, 469, 468, 466, 465, 462, 461, 460, 459, 448, 447, 446, 444, 443, 442, 441, 440, 437, 435, 434, 433, 431, 430, 429, 428, 426, 424, 423, 418, 417, 415, 414, 413, 412, 411, 410, 409, 408, 407, 406, 405, 403, 402, 401, 400, 399, 398, 397, 395, 394, 393, 392, 391, 390, 389, 385, 381, 380, 379, 376, 374, 364, 362, 358, 357, 356, 355, 353, 352, 350, 345, 344, 343, 342, 341, 340, 335, 333, 332, 331, 330, 329, 327, 326, 323, 322, 321, 320, 319, 318, 317, 316, 315, 314, 313, 312, 311, 310, 309, 308, 307, 306, 305, 304, 303, 302, 301, 300, 299, 298, 297, 294, 292, 291, 290, 289, 288, 287, 286, 285, 283, 279, 277, 276, 275, 274, 270, 269, 268, 267, 266, 265, 264, 263, 262, 258, 256, 255, 254, 247, 246, 245, 244, 242, 241, 240, 239, 238, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210, 209, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 176, 175, 174, 173, 171, 170, 169, 168, 167, 165, 150, 149, 147, 146, 145, 141, 140, 139, 138, 137, 134, 133, 132, 131, 129, 128, 126, 124, 123, 122, 120, 119, 118, 116, 115, 113, 112, 111, 110, 109, 108, 105, 104, 103, 102, 101, 100, 99, 98, 96, 95, 94, 93, 92, 91, 89, 88, 84, 80, 46, 44, 38, 25, 22, 19, 14, 9, 5, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818 } ; /* Table of booleans, true if rule could match eol. */ static yyconst flex_int32_t yy_rule_can_match_eol[240] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ #define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET /* // // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file contains the Lex specification for GLSL ES. Based on ANSI C grammar, Lex specification: http://www.lysator.liu.se/c/ANSI-C-grammar-l.html IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh, WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp). */ #include "compiler/translator/glslang.h" #include "compiler/translator/ParseContext.h" #include "compiler/preprocessor/Token.h" #include "compiler/translator/util.h" #include "compiler/translator/length_limits.h" #include "glslang_tab.h" /* windows only pragma */ #ifdef _MSC_VER #pragma warning(disable : 4102) #endif // Workaround for flex using the register keyword, deprecated in C++11. #ifdef __cplusplus #if __cplusplus > 199711L #define register #endif #endif #define YY_USER_ACTION \ yylloc->first_file = yylloc->last_file = yycolumn; \ yylloc->first_line = yylloc->last_line = yylineno; #define YY_INPUT(buf, result, max_size) \ result = string_input(buf, max_size, yyscanner); static yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner); static int check_type(yyscan_t yyscanner); static int reserved_word(yyscan_t yyscanner); static int ES2_reserved_ES3_keyword(TParseContext *context, int token); static int ES2_keyword_ES3_reserved(TParseContext *context, int token); static int ES2_ident_ES3_keyword(TParseContext *context, int token); static int uint_constant(TParseContext *context); static int int_constant(yyscan_t yyscanner); static int float_constant(yyscan_t yyscanner); static int floatsuffix_check(TParseContext* context); #define INITIAL 0 #define FIELDS 1 #define YY_EXTRA_TYPE TParseContext* /* Holds the entire state of the reentrant scanner. */ struct yyguts_t { /* User-defined. Not touched by flex. */ YY_EXTRA_TYPE yyextra_r; /* The rest are the same as the globals declared in the non-reentrant scanner. */ FILE *yyin_r, *yyout_r; size_t yy_buffer_stack_top; /**< index of top of stack. */ size_t yy_buffer_stack_max; /**< capacity of stack. */ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ char yy_hold_char; yy_size_t yy_n_chars; yy_size_t yyleng_r; char *yy_c_buf_p; int yy_init; int yy_start; int yy_did_buffer_switch_on_eof; int yy_start_stack_ptr; int yy_start_stack_depth; int *yy_start_stack; yy_state_type yy_last_accepting_state; char* yy_last_accepting_cpos; int yylineno_r; int yy_flex_debug_r; char *yytext_r; int yy_more_flag; int yy_more_len; YYSTYPE * yylval_r; YYLTYPE * yylloc_r; }; /* end struct yyguts_t */ static int yy_init_globals (yyscan_t yyscanner ); /* This must go here because YYSTYPE and YYLTYPE are included * from bison output in section 1.*/ # define yylval yyg->yylval_r # define yylloc yyg->yylloc_r int yylex_init (yyscan_t* scanner); int yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ int yylex_destroy (yyscan_t yyscanner ); int yyget_debug (yyscan_t yyscanner ); void yyset_debug (int debug_flag ,yyscan_t yyscanner ); YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner ); void yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); FILE *yyget_in (yyscan_t yyscanner ); void yyset_in (FILE * in_str ,yyscan_t yyscanner ); FILE *yyget_out (yyscan_t yyscanner ); void yyset_out (FILE * out_str ,yyscan_t yyscanner ); yy_size_t yyget_leng (yyscan_t yyscanner ); char *yyget_text (yyscan_t yyscanner ); int yyget_lineno (yyscan_t yyscanner ); void yyset_lineno (int line_number ,yyscan_t yyscanner ); int yyget_column (yyscan_t yyscanner ); void yyset_column (int column_no ,yyscan_t yyscanner ); YYSTYPE * yyget_lval (yyscan_t yyscanner ); void yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); YYLTYPE *yyget_lloc (yyscan_t yyscanner ); void yyset_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner ); /* Macros after this point can all be overridden by user definitions in * section 1. */ #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus extern "C" int yywrap (yyscan_t yyscanner ); #else extern int yywrap (yyscan_t yyscanner ); #endif #endif #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (yyscan_t yyscanner ); #else static int input (yyscan_t yyscanner ); #endif #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #define YY_READ_BUF_SIZE 8192 #endif /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else \ { \ errno=0; \ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ break; \ } \ errno=0; \ clearerr(yyin); \ } \ }\ \ #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */ #ifndef yyterminate #define yyterminate() return YY_NULL #endif /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif /* Report a fatal error. */ #ifndef YY_FATAL_ERROR #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) #endif /* end tables serialization structures and prototypes */ /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 extern int yylex \ (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner); #define YY_DECL int yylex \ (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner) #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif /* Code executed at the end of each rule. */ #ifndef YY_BREAK #define YY_BREAK break; #endif #define YY_RULE_SETUP \ YY_USER_ACTION /** The main scanner function which does all the work. */ YY_DECL { register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylval = yylval_param; yylloc = yylloc_param; if ( !yyg->yy_init ) { yyg->yy_init = 1; #ifdef YY_USER_INIT YY_USER_INIT; #endif if ( ! yyg->yy_start ) yyg->yy_start = 1; /* first start state */ if ( ! yyin ) yyin = stdin; if ( ! yyout ) yyout = stdout; if ( ! YY_CURRENT_BUFFER ) { yyensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); } yy_load_buffer_state(yyscanner ); } { TParseContext* context = yyextra; while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = yyg->yy_c_buf_p; /* Support of yytext. */ *yy_cp = yyg->yy_hold_char; /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; yy_current_state = yyg->yy_start; yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 819 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } while ( yy_current_state != 818 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; yy_find_action: yy_act = yy_accept[yy_current_state]; YY_DO_BEFORE_ACTION; if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { yy_size_t yyl; for ( yyl = 0; yyl < yyleng; ++yyl ) if ( yytext[yyl] == '\n' ) do{ yylineno++; yycolumn=0; }while(0) ; } do_action: /* This label is used only to access EOF actions. */ switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = yyg->yy_hold_char; yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; goto yy_find_action; case 1: YY_RULE_SETUP { return INVARIANT; } YY_BREAK case 2: YY_RULE_SETUP { return HIGH_PRECISION; } YY_BREAK case 3: YY_RULE_SETUP { return MEDIUM_PRECISION; } YY_BREAK case 4: YY_RULE_SETUP { return LOW_PRECISION; } YY_BREAK case 5: YY_RULE_SETUP { return PRECISION; } YY_BREAK case 6: YY_RULE_SETUP { return ES2_keyword_ES3_reserved(context, ATTRIBUTE); } YY_BREAK case 7: YY_RULE_SETUP { return CONST_QUAL; } YY_BREAK case 8: YY_RULE_SETUP { return UNIFORM; } YY_BREAK case 9: YY_RULE_SETUP { return ES2_keyword_ES3_reserved(context, VARYING); } YY_BREAK case 10: YY_RULE_SETUP { return BREAK; } YY_BREAK case 11: YY_RULE_SETUP { return CONTINUE; } YY_BREAK case 12: YY_RULE_SETUP { return DO; } YY_BREAK case 13: YY_RULE_SETUP { return FOR; } YY_BREAK case 14: YY_RULE_SETUP { return WHILE; } YY_BREAK case 15: YY_RULE_SETUP { return IF; } YY_BREAK case 16: YY_RULE_SETUP { return ELSE; } YY_BREAK case 17: YY_RULE_SETUP { return ES2_reserved_ES3_keyword(context, SWITCH); } YY_BREAK case 18: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, CASE); } YY_BREAK case 19: YY_RULE_SETUP { return ES2_reserved_ES3_keyword(context, DEFAULT); } YY_BREAK case 20: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, CENTROID); } YY_BREAK case 21: YY_RULE_SETUP { return ES2_reserved_ES3_keyword(context, FLAT); } YY_BREAK case 22: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, SMOOTH); } YY_BREAK case 23: YY_RULE_SETUP { return IN_QUAL; } YY_BREAK case 24: YY_RULE_SETUP { return OUT_QUAL; } YY_BREAK case 25: YY_RULE_SETUP { return INOUT_QUAL; } YY_BREAK case 26: YY_RULE_SETUP { return FLOAT_TYPE; } YY_BREAK case 27: YY_RULE_SETUP { return INT_TYPE; } YY_BREAK case 28: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, UINT_TYPE); } YY_BREAK case 29: YY_RULE_SETUP { return VOID_TYPE; } YY_BREAK case 30: YY_RULE_SETUP { return BOOL_TYPE; } YY_BREAK case 31: YY_RULE_SETUP { yylval->lex.b = true; return BOOLCONSTANT; } YY_BREAK case 32: YY_RULE_SETUP { yylval->lex.b = false; return BOOLCONSTANT; } YY_BREAK case 33: YY_RULE_SETUP { return DISCARD; } YY_BREAK case 34: YY_RULE_SETUP { return RETURN; } YY_BREAK case 35: YY_RULE_SETUP { return MATRIX2; } YY_BREAK case 36: YY_RULE_SETUP { return MATRIX3; } YY_BREAK case 37: YY_RULE_SETUP { return MATRIX4; } YY_BREAK case 38: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, MATRIX2); } YY_BREAK case 39: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, MATRIX3); } YY_BREAK case 40: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, MATRIX4); } YY_BREAK case 41: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, MATRIX2x3); } YY_BREAK case 42: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, MATRIX3x2); } YY_BREAK case 43: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, MATRIX2x4); } YY_BREAK case 44: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, MATRIX4x2); } YY_BREAK case 45: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, MATRIX3x4); } YY_BREAK case 46: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, MATRIX4x3); } YY_BREAK case 47: YY_RULE_SETUP { return VEC2; } YY_BREAK case 48: YY_RULE_SETUP { return VEC3; } YY_BREAK case 49: YY_RULE_SETUP { return VEC4; } YY_BREAK case 50: YY_RULE_SETUP { return IVEC2; } YY_BREAK case 51: YY_RULE_SETUP { return IVEC3; } YY_BREAK case 52: YY_RULE_SETUP { return IVEC4; } YY_BREAK case 53: YY_RULE_SETUP { return BVEC2; } YY_BREAK case 54: YY_RULE_SETUP { return BVEC3; } YY_BREAK case 55: YY_RULE_SETUP { return BVEC4; } YY_BREAK case 56: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, UVEC2); } YY_BREAK case 57: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, UVEC3); } YY_BREAK case 58: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, UVEC4); } YY_BREAK case 59: YY_RULE_SETUP { return SAMPLER2D; } YY_BREAK case 60: YY_RULE_SETUP { return SAMPLERCUBE; } YY_BREAK case 61: YY_RULE_SETUP { return SAMPLER_EXTERNAL_OES; } YY_BREAK case 62: YY_RULE_SETUP { return ES2_reserved_ES3_keyword(context, SAMPLER3D); } YY_BREAK case 63: YY_RULE_SETUP { return ES2_reserved_ES3_keyword(context, SAMPLER3DRECT); } YY_BREAK case 64: YY_RULE_SETUP { return SAMPLER2DRECT; } YY_BREAK case 65: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, SAMPLER2DARRAY); } YY_BREAK case 66: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, ISAMPLER2D); } YY_BREAK case 67: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, ISAMPLER3D); } YY_BREAK case 68: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, ISAMPLERCUBE); } YY_BREAK case 69: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, ISAMPLER2DARRAY); } YY_BREAK case 70: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, USAMPLER2D); } YY_BREAK case 71: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, USAMPLER3D); } YY_BREAK case 72: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, USAMPLERCUBE); } YY_BREAK case 73: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, USAMPLER2DARRAY); } YY_BREAK case 74: YY_RULE_SETUP { return ES2_reserved_ES3_keyword(context, SAMPLER2DSHADOW); } YY_BREAK case 75: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, SAMPLERCUBESHADOW); } YY_BREAK case 76: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, SAMPLER2DARRAYSHADOW); } YY_BREAK case 77: YY_RULE_SETUP { return STRUCT; } YY_BREAK case 78: YY_RULE_SETUP { return ES2_ident_ES3_keyword(context, LAYOUT); } YY_BREAK /* Reserved keywords for GLSL ES 3.00 that are not reserved for GLSL ES 1.00 */ case 79: case 80: case 81: case 82: case 83: case 84: case 85: case 86: case 87: case 88: case 89: case 90: case 91: case 92: case 93: case 94: case 95: case 96: case 97: case 98: case 99: case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107: case 108: case 109: case 110: case 111: case 112: case 113: case 114: case 115: case 116: case 117: case 118: case 119: case 120: case 121: case 122: case 123: case 124: case 125: case 126: case 127: case 128: case 129: case 130: case 131: case 132: case 133: case 134: YY_RULE_SETUP { if (context->getShaderVersion() < 300) { yylval->lex.string = NewPoolTString(yytext); return check_type(yyscanner); } return reserved_word(yyscanner); } YY_BREAK /* Reserved keywords in GLSL ES 1.00 that are not reserved in GLSL ES 3.00 */ case 135: YY_RULE_SETUP { if (context->getShaderVersion() >= 300) { yylval->lex.string = NewPoolTString(yytext); return check_type(yyscanner); } return reserved_word(yyscanner); } YY_BREAK /* Reserved keywords */ case 136: case 137: case 138: case 139: case 140: case 141: case 142: case 143: case 144: case 145: case 146: case 147: case 148: case 149: case 150: case 151: case 152: case 153: case 154: case 155: case 156: case 157: case 158: case 159: case 160: case 161: case 162: case 163: case 164: case 165: case 166: case 167: case 168: case 169: case 170: case 171: case 172: case 173: case 174: case 175: case 176: YY_RULE_SETUP { return reserved_word(yyscanner); } YY_BREAK case 177: YY_RULE_SETUP { yylval->lex.string = NewPoolTString(yytext); return check_type(yyscanner); } YY_BREAK case 178: YY_RULE_SETUP { return int_constant(yyscanner); } YY_BREAK case 179: YY_RULE_SETUP { return int_constant(yyscanner); } YY_BREAK case 180: YY_RULE_SETUP { return int_constant(yyscanner); } YY_BREAK case 181: YY_RULE_SETUP { return uint_constant(context); } YY_BREAK case 182: YY_RULE_SETUP { return uint_constant(context); } YY_BREAK case 183: YY_RULE_SETUP { return uint_constant(context); } YY_BREAK case 184: YY_RULE_SETUP { return float_constant(yyscanner); } YY_BREAK case 185: YY_RULE_SETUP { return float_constant(yyscanner); } YY_BREAK case 186: YY_RULE_SETUP { return float_constant(yyscanner); } YY_BREAK case 187: YY_RULE_SETUP { return floatsuffix_check(context); } YY_BREAK case 188: YY_RULE_SETUP { return floatsuffix_check(context); } YY_BREAK case 189: YY_RULE_SETUP { return floatsuffix_check(context); } YY_BREAK case 190: YY_RULE_SETUP { return ADD_ASSIGN; } YY_BREAK case 191: YY_RULE_SETUP { return SUB_ASSIGN; } YY_BREAK case 192: YY_RULE_SETUP { return MUL_ASSIGN; } YY_BREAK case 193: YY_RULE_SETUP { return DIV_ASSIGN; } YY_BREAK case 194: YY_RULE_SETUP { return MOD_ASSIGN; } YY_BREAK case 195: YY_RULE_SETUP { return LEFT_ASSIGN; } YY_BREAK case 196: YY_RULE_SETUP { return RIGHT_ASSIGN; } YY_BREAK case 197: YY_RULE_SETUP { return AND_ASSIGN; } YY_BREAK case 198: YY_RULE_SETUP { return XOR_ASSIGN; } YY_BREAK case 199: YY_RULE_SETUP { return OR_ASSIGN; } YY_BREAK case 200: YY_RULE_SETUP { return INC_OP; } YY_BREAK case 201: YY_RULE_SETUP { return DEC_OP; } YY_BREAK case 202: YY_RULE_SETUP { return AND_OP; } YY_BREAK case 203: YY_RULE_SETUP { return OR_OP; } YY_BREAK case 204: YY_RULE_SETUP { return XOR_OP; } YY_BREAK case 205: YY_RULE_SETUP { return LE_OP; } YY_BREAK case 206: YY_RULE_SETUP { return GE_OP; } YY_BREAK case 207: YY_RULE_SETUP { return EQ_OP; } YY_BREAK case 208: YY_RULE_SETUP { return NE_OP; } YY_BREAK case 209: YY_RULE_SETUP { return LEFT_OP; } YY_BREAK case 210: YY_RULE_SETUP { return RIGHT_OP; } YY_BREAK case 211: YY_RULE_SETUP { return SEMICOLON; } YY_BREAK case 212: YY_RULE_SETUP { return LEFT_BRACE; } YY_BREAK case 213: YY_RULE_SETUP { return RIGHT_BRACE; } YY_BREAK case 214: YY_RULE_SETUP { return COMMA; } YY_BREAK case 215: YY_RULE_SETUP { return COLON; } YY_BREAK case 216: YY_RULE_SETUP { return EQUAL; } YY_BREAK case 217: YY_RULE_SETUP { return LEFT_PAREN; } YY_BREAK case 218: YY_RULE_SETUP { return RIGHT_PAREN; } YY_BREAK case 219: YY_RULE_SETUP { return LEFT_BRACKET; } YY_BREAK case 220: YY_RULE_SETUP { return RIGHT_BRACKET; } YY_BREAK case 221: YY_RULE_SETUP { BEGIN(FIELDS); return DOT; } YY_BREAK case 222: YY_RULE_SETUP { return BANG; } YY_BREAK case 223: YY_RULE_SETUP { return DASH; } YY_BREAK case 224: YY_RULE_SETUP { return TILDE; } YY_BREAK case 225: YY_RULE_SETUP { return PLUS; } YY_BREAK case 226: YY_RULE_SETUP { return STAR; } YY_BREAK case 227: YY_RULE_SETUP { return SLASH; } YY_BREAK case 228: YY_RULE_SETUP { return PERCENT; } YY_BREAK case 229: YY_RULE_SETUP { return LEFT_ANGLE; } YY_BREAK case 230: YY_RULE_SETUP { return RIGHT_ANGLE; } YY_BREAK case 231: YY_RULE_SETUP { return VERTICAL_BAR; } YY_BREAK case 232: YY_RULE_SETUP { return CARET; } YY_BREAK case 233: YY_RULE_SETUP { return AMPERSAND; } YY_BREAK case 234: YY_RULE_SETUP { return QUESTION; } YY_BREAK case 235: YY_RULE_SETUP { BEGIN(INITIAL); yylval->lex.string = NewPoolTString(yytext); return FIELD_SELECTION; } YY_BREAK case 236: YY_RULE_SETUP {} YY_BREAK case 237: /* rule 237 can match eol */ YY_RULE_SETUP { } YY_BREAK case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(FIELDS): { yyterminate(); } YY_BREAK case 238: YY_RULE_SETUP { assert(false); return 0; } YY_BREAK case 239: YY_RULE_SETUP ECHO; YY_BREAK case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ *yy_cp = yyg->yy_hold_char; YY_RESTORE_YY_MORE_OFFSET if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position * of the first EOB in the buffer, since yy_c_buf_p will * already have been incremented past the NUL character * (since all states make transitions on EOB to the * end-of-buffer state). Contrast this with the test * in input(). */ if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) { /* This was really a NUL. */ yy_state_type yy_next_state; yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( yyscanner ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have * yy_get_previous_state() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we don't * want to build jamming into it because then it * will run more slowly). */ yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ yy_cp = ++yyg->yy_c_buf_p; yy_current_state = yy_next_state; goto yy_match; } else { yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; goto yy_find_action; } } else switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_END_OF_FILE: { yyg->yy_did_buffer_switch_on_eof = 0; if ( yywrap(yyscanner ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; } else { if ( ! yyg->yy_did_buffer_switch_on_eof ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( yyscanner ); yy_cp = yyg->yy_c_buf_p; yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: yyg->yy_c_buf_p = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; yy_current_state = yy_get_previous_state( yyscanner ); yy_cp = yyg->yy_c_buf_p; yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; goto yy_find_action; } break; } default: YY_FATAL_ERROR( "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ } /* end of user's declarations */ } /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ static int yy_get_next_buffer (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; register char *source = yyg->yytext_ptr; register int number_to_move, i; int ret_val; if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; } else { /* We matched some text prior to the EOB, first * process it. */ return EOB_ACT_LAST_MATCH; } } /* Try to read more data. */ /* First move last chars to start of buffer. */ number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; else { yy_size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; int yy_c_buf_p_offset = (int) (yyg->yy_c_buf_p - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { yy_size_t new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; else b->yy_buf_size *= 2; b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); } else /* Can't grow it, we don't own it. */ b->yy_ch_buf = 0; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), yyg->yy_n_chars, num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } if ( yyg->yy_n_chars == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; yyrestart(yyin ,yyscanner); } else { ret_val = EOB_ACT_LAST_MATCH; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); } yyg->yy_n_chars += number_to_move; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { register yy_state_type yy_current_state; register char *yy_cp; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_current_state = yyg->yy_start; for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 819 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; } return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) { register int yy_is_jam; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ register char *yy_cp = yyg->yy_c_buf_p; register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 819 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 818); (void)yyg; return yy_is_jam ? 0 : yy_current_state; } #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (yyscan_t yyscanner) #else static int input (yyscan_t yyscanner) #endif { int c; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; *yyg->yy_c_buf_p = yyg->yy_hold_char; if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) /* This was really a NUL. */ *yyg->yy_c_buf_p = '\0'; else { /* need more input */ yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; ++yyg->yy_c_buf_p; switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a * token and flags that we need to * try matching the token before * proceeding. But for input(), * there's no matching to consider. * So convert the EOB_ACT_LAST_MATCH * to EOB_ACT_END_OF_FILE. */ /* Reset buffer status. */ yyrestart(yyin ,yyscanner); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { if ( yywrap(yyscanner ) ) return EOF; if ( ! yyg->yy_did_buffer_switch_on_eof ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(yyscanner); #else return input(yyscanner); #endif } case EOB_ACT_CONTINUE_SCAN: yyg->yy_c_buf_p = yyg->yytext_ptr + offset; break; } } } c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ yyg->yy_hold_char = *++yyg->yy_c_buf_p; if ( c == '\n' ) do{ yylineno++; yycolumn=0; }while(0) ; return c; } #endif /* ifndef YY_NO_INPUT */ /** Immediately switch to a different input stream. * @param input_file A readable stream. * @param yyscanner The scanner object. * @note This function does not reset the start condition to @c INITIAL . */ void yyrestart (FILE * input_file , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); } yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); yy_load_buffer_state(yyscanner ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * @param yyscanner The scanner object. */ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* TODO. We should be able to replace this entire function body * with * yypop_buffer_state(); * yypush_buffer_state(new_buffer); */ yyensure_buffer_stack (yyscanner); if ( YY_CURRENT_BUFFER == new_buffer ) return; if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *yyg->yy_c_buf_p = yyg->yy_hold_char; YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } YY_CURRENT_BUFFER_LVALUE = new_buffer; yy_load_buffer_state(yyscanner ); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ yyg->yy_did_buffer_switch_on_eof = 1; } static void yy_load_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; yyg->yy_hold_char = *yyg->yy_c_buf_p; } /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. * @param yyscanner The scanner object. * @return the allocated buffer state. */ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ,yyscanner ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; yy_init_buffer(b,file ,yyscanner); return b; } /** Destroy the buffer. * @param b a buffer created with yy_create_buffer() * @param yyscanner The scanner object. */ void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! b ) return; if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) yyfree((void *) b->yy_ch_buf ,yyscanner ); yyfree((void *) b ,yyscanner ); } /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. */ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) { int oerrno = errno; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_flush_buffer(b ,yyscanner); b->yy_input_file = file; b->yy_fill_buffer = 1; /* If b is the current buffer, then yy_init_buffer was _probably_ * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ b->yy_bs_lineno = 1; b->yy_bs_column = 0; } b->yy_is_interactive = 0; errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * @param yyscanner The scanner object. */ void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! b ) return; b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes * a jam in that state. */ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; b->yy_buf_pos = &b->yy_ch_buf[0]; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) yy_load_buffer_state(yyscanner ); } /** Pushes the new state onto the stack. The new state becomes * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. * @param yyscanner The scanner object. */ void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (new_buffer == NULL) return; yyensure_buffer_stack(yyscanner); /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *yyg->yy_c_buf_p = yyg->yy_hold_char; YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } /* Only push if top exists. Otherwise, replace top. */ if (YY_CURRENT_BUFFER) yyg->yy_buffer_stack_top++; YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from yy_switch_to_buffer. */ yy_load_buffer_state(yyscanner ); yyg->yy_did_buffer_switch_on_eof = 1; } /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. * @param yyscanner The scanner object. */ void yypop_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!YY_CURRENT_BUFFER) return; yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); YY_CURRENT_BUFFER_LVALUE = NULL; if (yyg->yy_buffer_stack_top > 0) --yyg->yy_buffer_stack_top; if (YY_CURRENT_BUFFER) { yy_load_buffer_state(yyscanner ); yyg->yy_did_buffer_switch_on_eof = 1; } } /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ static void yyensure_buffer_stack (yyscan_t yyscanner) { yy_size_t num_to_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!yyg->yy_buffer_stack) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ num_to_alloc = 1; yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); if ( ! yyg->yy_buffer_stack ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); yyg->yy_buffer_stack_max = num_to_alloc; yyg->yy_buffer_stack_top = 0; return; } if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; num_to_alloc = yyg->yy_buffer_stack_max + grow_size; yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc (yyg->yy_buffer_stack, num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); if ( ! yyg->yy_buffer_stack ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); yyg->yy_buffer_stack_max = num_to_alloc; } } /** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ return 0; b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = 0; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; yy_switch_to_buffer(b ,yyscanner ); return b; } /** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * @param yyscanner The scanner object. * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) { return yy_scan_bytes(yystr,strlen(yystr) ,yyscanner); } /** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) { YY_BUFFER_STATE b; char *buf; yy_size_t n; yy_size_t i; /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; buf = (char *) yyalloc(n ,yyscanner ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; b = yy_scan_buffer(buf,n ,yyscanner); if ( ! b ) YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. */ b->yy_is_our_buffer = 1; return b; } #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = yyg->yy_hold_char; \ yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ yyg->yy_hold_char = *yyg->yy_c_buf_p; \ *yyg->yy_c_buf_p = '\0'; \ yyleng = yyless_macro_arg; \ } \ while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ /** Get the user-defined data for this scanner. * @param yyscanner The scanner object. */ YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyextra; } /** Get the current line number. * @param yyscanner The scanner object. */ int yyget_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (! YY_CURRENT_BUFFER) return 0; return yylineno; } /** Get the current column number. * @param yyscanner The scanner object. */ int yyget_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (! YY_CURRENT_BUFFER) return 0; return yycolumn; } /** Get the input stream. * @param yyscanner The scanner object. */ FILE *yyget_in (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyin; } /** Get the output stream. * @param yyscanner The scanner object. */ FILE *yyget_out (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyout; } /** Get the length of the current token. * @param yyscanner The scanner object. */ yy_size_t yyget_leng (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyleng; } /** Get the current token. * @param yyscanner The scanner object. */ char *yyget_text (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yytext; } /** Set the user-defined data. This data is never touched by the scanner. * @param user_defined The data to be associated with this scanner. * @param yyscanner The scanner object. */ void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyextra = user_defined ; } /** Set the current line number. * @param line_number * @param yyscanner The scanner object. */ void yyset_lineno (int line_number , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); yylineno = line_number; } /** Set the current column. * @param line_number * @param yyscanner The scanner object. */ void yyset_column (int column_no , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) YY_FATAL_ERROR( "yyset_column called with no buffer" ); yycolumn = column_no; } /** Set the input stream. This does not discard the current * input buffer. * @param in_str A readable stream. * @param yyscanner The scanner object. * @see yy_switch_to_buffer */ void yyset_in (FILE * in_str , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyin = in_str ; } void yyset_out (FILE * out_str , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyout = out_str ; } int yyget_debug (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yy_flex_debug; } void yyset_debug (int bdebug , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_flex_debug = bdebug ; } /* Accessor methods for yylval and yylloc */ YYSTYPE * yyget_lval (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yylval; } void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylval = yylval_param; } YYLTYPE *yyget_lloc (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yylloc; } void yyset_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylloc = yylloc_param; } /* User-visible API */ /* yylex_init is special because it creates the scanner itself, so it is * the ONLY reentrant function that doesn't take the scanner as the last argument. * That's why we explicitly handle the declaration, instead of using our macros. */ int yylex_init(yyscan_t* ptr_yy_globals) { if (ptr_yy_globals == NULL){ errno = EINVAL; return 1; } *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); if (*ptr_yy_globals == NULL){ errno = ENOMEM; return 1; } /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); return yy_init_globals ( *ptr_yy_globals ); } /* yylex_init_extra has the same functionality as yylex_init, but follows the * convention of taking the scanner as the last argument. Note however, that * this is a *pointer* to a scanner, as it will be allocated by this call (and * is the reason, too, why this function also must handle its own declaration). * The user defined value in the first argument will be available to yyalloc in * the yyextra field. */ int yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) { struct yyguts_t dummy_yyguts; yyset_extra (yy_user_defined, &dummy_yyguts); if (ptr_yy_globals == NULL){ errno = EINVAL; return 1; } *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); if (*ptr_yy_globals == NULL){ errno = ENOMEM; return 1; } /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); yyset_extra (yy_user_defined, *ptr_yy_globals); return yy_init_globals ( *ptr_yy_globals ); } static int yy_init_globals (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Initialization is the same as for the non-reentrant scanner. * This function is called from yylex_destroy(), so don't allocate here. */ yyg->yy_buffer_stack = 0; yyg->yy_buffer_stack_top = 0; yyg->yy_buffer_stack_max = 0; yyg->yy_c_buf_p = (char *) 0; yyg->yy_init = 0; yyg->yy_start = 0; yyg->yy_start_stack_ptr = 0; yyg->yy_start_stack_depth = 0; yyg->yy_start_stack = NULL; /* Defined in main.c */ #ifdef YY_STDINIT yyin = stdin; yyout = stdout; #else yyin = (FILE *) 0; yyout = (FILE *) 0; #endif /* For future reference: Set errno on error, since we are called by * yylex_init() */ return 0; } /* yylex_destroy is for both reentrant and non-reentrant scanners. */ int yylex_destroy (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); YY_CURRENT_BUFFER_LVALUE = NULL; yypop_buffer_state(yyscanner); } /* Destroy the stack itself. */ yyfree(yyg->yy_buffer_stack ,yyscanner); yyg->yy_buffer_stack = NULL; /* Destroy the start condition stack. */ yyfree(yyg->yy_start_stack ,yyscanner ); yyg->yy_start_stack = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time * yylex() is called, initialization will occur. */ yy_init_globals( yyscanner); /* Destroy the main struct (reentrant only). */ yyfree ( yyscanner , yyscanner ); yyscanner = NULL; return 0; } /* * Internal utility routines. */ #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) { register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) { register int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif void *yyalloc (yy_size_t size , yyscan_t yyscanner) { return (void *) malloc( size ); } void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter * because both ANSI C and C++ allow castless assignment from * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); } void yyfree (void * ptr , yyscan_t yyscanner) { free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner) { pp::Token token; yyget_extra(yyscanner)->getPreprocessor().lex(&token); yy_size_t len = token.type == pp::Token::LAST ? 0 : token.text.size(); if (len < max_size) memcpy(buf, token.text.c_str(), len); yyset_column(token.location.file,yyscanner); yyset_lineno(token.location.line,yyscanner); if (len >= max_size) YY_FATAL_ERROR("Input buffer overflow"); else if (len > 0) buf[len++] = ' '; return len; } int check_type(yyscan_t yyscanner) { struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; int token = IDENTIFIER; TSymbol* symbol = yyextra->symbolTable.find(yytext, yyextra->getShaderVersion()); if (symbol && symbol->isVariable()) { TVariable* variable = static_cast(symbol); if (variable->isUserType()) { token = TYPE_NAME; } } yylval->lex.symbol = symbol; return token; } int reserved_word(yyscan_t yyscanner) { struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; yyextra->error(*yylloc, "Illegal use of reserved word", yytext, ""); yyextra->recover(); return 0; } int ES2_reserved_ES3_keyword(TParseContext *context, int token) { yyscan_t yyscanner = (yyscan_t) context->getScanner(); if (context->getShaderVersion() < 300) { return reserved_word(yyscanner); } return token; } int ES2_keyword_ES3_reserved(TParseContext *context, int token) { yyscan_t yyscanner = (yyscan_t) context->getScanner(); if (context->getShaderVersion() >= 300) { return reserved_word(yyscanner); } return token; } int ES2_ident_ES3_keyword(TParseContext *context, int token) { struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); yyscan_t yyscanner = (yyscan_t) context->getScanner(); // not a reserved word in GLSL ES 1.00, so could be used as an identifier/type name if (context->getShaderVersion() < 300) { yylval->lex.string = NewPoolTString(yytext); return check_type(yyscanner); } return token; } int uint_constant(TParseContext *context) { struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); yyscan_t yyscanner = (yyscan_t) context->getScanner(); if (context->getShaderVersion() < 300) { context->error(*yylloc, "Unsigned integers are unsupported prior to GLSL ES 3.00", yytext, ""); context->recover(); return 0; } if (!atoi_clamp(yytext, &(yylval->lex.i))) yyextra->warning(*yylloc, "Integer overflow", yytext, ""); return UINTCONSTANT; } int floatsuffix_check(TParseContext* context) { struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); if (context->getShaderVersion() < 300) { context->error(*yylloc, "Floating-point suffix unsupported prior to GLSL ES 3.00", yytext); context->recover(); return 0; } std::string text = yytext; text.resize(text.size() - 1); if (!strtof_clamp(text, &(yylval->lex.f))) yyextra->warning(*yylloc, "Float overflow", yytext, ""); return(FLOATCONSTANT); } void yyerror(YYLTYPE* lloc, TParseContext* context, void *scanner, const char* reason) { context->error(*lloc, reason, yyget_text(scanner)); context->recover(); } int int_constant(yyscan_t yyscanner) { struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; if (!atoi_clamp(yytext, &(yylval->lex.i))) yyextra->warning(*yylloc, "Integer overflow", yytext, ""); return INTCONSTANT; } int float_constant(yyscan_t yyscanner) { struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; if (!strtof_clamp(yytext, &(yylval->lex.f))) yyextra->warning(*yylloc, "Float overflow", yytext, ""); return FLOATCONSTANT; } int glslang_initialize(TParseContext* context) { yyscan_t scanner = NULL; if (yylex_init_extra(context,&scanner)) return 1; context->setScanner(scanner); return 0; } int glslang_finalize(TParseContext* context) { yyscan_t scanner = context->getScanner(); if (scanner == NULL) return 0; context->setScanner(NULL); yylex_destroy(scanner); return 0; } int glslang_scan(size_t count, const char* const string[], const int length[], TParseContext* context) { yyrestart(NULL,context->getScanner()); yyset_column(0,context->getScanner()); yyset_lineno(1,context->getScanner()); // Initialize preprocessor. pp::Preprocessor *preprocessor = &context->getPreprocessor(); if (!preprocessor->init(count, string, length)) return 1; // Define extension macros. const TExtensionBehavior& extBehavior = context->extensionBehavior(); for (TExtensionBehavior::const_iterator iter = extBehavior.begin(); iter != extBehavior.end(); ++iter) { preprocessor->predefineMacro(iter->first.c_str(), 1); } if (context->getFragmentPrecisionHigh()) preprocessor->predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1); preprocessor->setMaxTokenSize(GetGlobalMaxTokenSize(context->getShaderSpec())); return 0; } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/glslang_tab.cpp000066400000000000000000005210261321746453100277130ustar00rootroot00000000000000/* A Bison parser, made by GNU Bison 3.0.4. */ /* Bison implementation for Yacc-like parsers in C Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. 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 . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ #define YYBISON_VERSION "3.0.4" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 2 /* Push parsers. */ #define YYPUSH 0 /* Pull parsers. */ #define YYPULL 1 /* Copy the first part of user declarations. */ // // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // This file is auto-generated by generate_parser.sh. DO NOT EDIT! // Ignore errors in auto-generated code. #if defined(__GNUC__) #pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wswitch-enum" #elif defined(_MSC_VER) #pragma warning(disable: 4065) #pragma warning(disable: 4189) #pragma warning(disable: 4244) #pragma warning(disable: 4505) #pragma warning(disable: 4701) #pragma warning(disable: 4702) #endif #include "angle_gl.h" #include "compiler/translator/Cache.h" #include "compiler/translator/SymbolTable.h" #include "compiler/translator/ParseContext.h" #include "GLSLANG/ShaderLang.h" #define YYENABLE_NLS 0 # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus # define YY_NULLPTR nullptr # else # define YY_NULLPTR 0 # endif # endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif /* In a future release of Bison, this section will be replaced by #include "glslang_tab.h". */ #ifndef YY_YY_GLSLANG_TAB_H_INCLUDED # define YY_YY_GLSLANG_TAB_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif #if YYDEBUG extern int yydebug; #endif /* "%code requires" blocks. */ #define YYLTYPE TSourceLoc #define YYLTYPE_IS_DECLARED 1 /* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { INVARIANT = 258, HIGH_PRECISION = 259, MEDIUM_PRECISION = 260, LOW_PRECISION = 261, PRECISION = 262, ATTRIBUTE = 263, CONST_QUAL = 264, BOOL_TYPE = 265, FLOAT_TYPE = 266, INT_TYPE = 267, UINT_TYPE = 268, BREAK = 269, CONTINUE = 270, DO = 271, ELSE = 272, FOR = 273, IF = 274, DISCARD = 275, RETURN = 276, SWITCH = 277, CASE = 278, DEFAULT = 279, BVEC2 = 280, BVEC3 = 281, BVEC4 = 282, IVEC2 = 283, IVEC3 = 284, IVEC4 = 285, VEC2 = 286, VEC3 = 287, VEC4 = 288, UVEC2 = 289, UVEC3 = 290, UVEC4 = 291, MATRIX2 = 292, MATRIX3 = 293, MATRIX4 = 294, IN_QUAL = 295, OUT_QUAL = 296, INOUT_QUAL = 297, UNIFORM = 298, VARYING = 299, MATRIX2x3 = 300, MATRIX3x2 = 301, MATRIX2x4 = 302, MATRIX4x2 = 303, MATRIX3x4 = 304, MATRIX4x3 = 305, CENTROID = 306, FLAT = 307, SMOOTH = 308, STRUCT = 309, VOID_TYPE = 310, WHILE = 311, SAMPLER2D = 312, SAMPLERCUBE = 313, SAMPLER_EXTERNAL_OES = 314, SAMPLER2DRECT = 315, SAMPLER2DARRAY = 316, ISAMPLER2D = 317, ISAMPLER3D = 318, ISAMPLERCUBE = 319, ISAMPLER2DARRAY = 320, USAMPLER2D = 321, USAMPLER3D = 322, USAMPLERCUBE = 323, USAMPLER2DARRAY = 324, SAMPLER3D = 325, SAMPLER3DRECT = 326, SAMPLER2DSHADOW = 327, SAMPLERCUBESHADOW = 328, SAMPLER2DARRAYSHADOW = 329, LAYOUT = 330, IDENTIFIER = 331, TYPE_NAME = 332, FLOATCONSTANT = 333, INTCONSTANT = 334, UINTCONSTANT = 335, BOOLCONSTANT = 336, FIELD_SELECTION = 337, LEFT_OP = 338, RIGHT_OP = 339, INC_OP = 340, DEC_OP = 341, LE_OP = 342, GE_OP = 343, EQ_OP = 344, NE_OP = 345, AND_OP = 346, OR_OP = 347, XOR_OP = 348, MUL_ASSIGN = 349, DIV_ASSIGN = 350, ADD_ASSIGN = 351, MOD_ASSIGN = 352, LEFT_ASSIGN = 353, RIGHT_ASSIGN = 354, AND_ASSIGN = 355, XOR_ASSIGN = 356, OR_ASSIGN = 357, SUB_ASSIGN = 358, LEFT_PAREN = 359, RIGHT_PAREN = 360, LEFT_BRACKET = 361, RIGHT_BRACKET = 362, LEFT_BRACE = 363, RIGHT_BRACE = 364, DOT = 365, COMMA = 366, COLON = 367, EQUAL = 368, SEMICOLON = 369, BANG = 370, DASH = 371, TILDE = 372, PLUS = 373, STAR = 374, SLASH = 375, PERCENT = 376, LEFT_ANGLE = 377, RIGHT_ANGLE = 378, VERTICAL_BAR = 379, CARET = 380, AMPERSAND = 381, QUESTION = 382 }; #endif /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { struct { union { TString *string; float f; int i; unsigned int u; bool b; }; TSymbol* symbol; } lex; struct { TOperator op; union { TIntermNode* intermNode; TIntermNodePair nodePair; TIntermTyped* intermTypedNode; TIntermAggregate* intermAggregate; TIntermSwitch* intermSwitch; TIntermCase* intermCase; }; union { TPublicType type; TPrecision precision; TLayoutQualifier layoutQualifier; TQualifier qualifier; TFunction* function; TParameter param; TField* field; TFieldList* fieldList; }; } interm; }; typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 #endif /* Location type. */ #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED typedef struct YYLTYPE YYLTYPE; struct YYLTYPE { int first_line; int first_column; int last_line; int last_column; }; # define YYLTYPE_IS_DECLARED 1 # define YYLTYPE_IS_TRIVIAL 1 #endif int yyparse (TParseContext* context, void *scanner); #endif /* !YY_YY_GLSLANG_TAB_H_INCLUDED */ /* Copy the second part of user declarations. */ extern int yylex(YYSTYPE* yylval, YYLTYPE* yylloc, void* yyscanner); extern void yyerror(YYLTYPE* yylloc, TParseContext* context, void *scanner, const char* reason); #define YYLLOC_DEFAULT(Current, Rhs, N) \ do { \ if (N) { \ (Current).first_file = YYRHSLOC(Rhs, 1).first_file; \ (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ (Current).last_file = YYRHSLOC(Rhs, N).last_file; \ (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ } \ else { \ (Current).first_file = YYRHSLOC(Rhs, 0).last_file; \ (Current).first_line = YYRHSLOC(Rhs, 0).last_line; \ (Current).last_file = YYRHSLOC(Rhs, 0).last_file; \ (Current).last_line = YYRHSLOC(Rhs, 0).last_line; \ } \ } while (0) #define VERTEX_ONLY(S, L) { \ if (context->getShaderType() != GL_VERTEX_SHADER) { \ context->error(L, " supported in vertex shaders only ", S); \ context->recover(); \ } \ } #define FRAG_ONLY(S, L) { \ if (context->getShaderType() != GL_FRAGMENT_SHADER) { \ context->error(L, " supported in fragment shaders only ", S); \ context->recover(); \ } \ } #define ES2_ONLY(S, L) { \ if (context->getShaderVersion() != 100) { \ context->error(L, " supported in GLSL ES 1.00 only ", S); \ context->recover(); \ } \ } #define ES3_ONLY(TOKEN, LINE, REASON) { \ if (context->getShaderVersion() != 300) { \ context->error(LINE, REASON " supported in GLSL ES 3.00 only ", TOKEN); \ context->recover(); \ } \ } #ifdef short # undef short #endif #ifdef YYTYPE_UINT8 typedef YYTYPE_UINT8 yytype_uint8; #else typedef unsigned char yytype_uint8; #endif #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; #else typedef signed char yytype_int8; #endif #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else typedef unsigned short int yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else typedef short int yytype_int16; #endif #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t # elif ! defined YYSIZE_T # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else # define YYSIZE_T unsigned int # endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ # define YY_(Msgid) Msgid # endif #endif #ifndef YY_ATTRIBUTE # if (defined __GNUC__ \ && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C # define YY_ATTRIBUTE(Spec) __attribute__(Spec) # else # define YY_ATTRIBUTE(Spec) /* empty */ # endif #endif #ifndef YY_ATTRIBUTE_PURE # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) #endif #ifndef YY_ATTRIBUTE_UNUSED # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) #endif #if !defined _Noreturn \ && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) # if defined _MSC_VER && 1200 <= _MSC_VER # define _Noreturn __declspec (noreturn) # else # define _Noreturn YY_ATTRIBUTE ((__noreturn__)) # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) #else # define YYUSE(E) /* empty */ #endif #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value #endif #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_END #endif #ifndef YY_INITIAL_VALUE # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # elif defined __BUILTIN_VA_ARG_INCR # include /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS # include /* INFRINGES ON USER NAME SPACE */ /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's 'empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined EXIT_SUCCESS void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free # if ! defined free && ! defined EXIT_SUCCESS void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { yytype_int16 yyss_alloc; YYSTYPE yyvs_alloc; YYLTYPE yyls_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) #endif #if defined YYCOPY_NEEDED && YYCOPY_NEEDED /* Copy COUNT objects from SRC to DST. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ while (0) # endif # endif #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ #define YYFINAL 116 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 2516 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 128 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 94 /* YYNRULES -- Number of rules. */ #define YYNRULES 275 /* YYNSTATES -- Number of states. */ #define YYNSTATES 417 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 382 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM as returned by yylex, without out-of-bounds checking. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127 }; #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 212, 212, 213, 216, 240, 243, 248, 253, 258, 263, 269, 272, 275, 278, 281, 284, 290, 298, 309, 313, 321, 324, 330, 334, 341, 347, 356, 364, 370, 377, 387, 390, 393, 396, 406, 407, 408, 409, 417, 418, 421, 424, 431, 432, 435, 441, 442, 446, 453, 454, 457, 460, 463, 469, 470, 473, 479, 480, 487, 488, 495, 496, 503, 504, 510, 511, 517, 518, 524, 525, 531, 532, 540, 541, 542, 543, 547, 548, 549, 553, 557, 561, 565, 572, 575, 586, 594, 602, 630, 636, 647, 651, 655, 659, 666, 672, 675, 682, 690, 711, 738, 748, 776, 781, 791, 796, 806, 809, 812, 815, 821, 828, 831, 835, 839, 844, 849, 856, 860, 864, 868, 873, 878, 882, 889, 899, 905, 908, 914, 920, 927, 936, 946, 954, 957, 964, 968, 972, 977, 985, 988, 992, 996, 1005, 1014, 1022, 1032, 1044, 1047, 1050, 1056, 1063, 1066, 1072, 1075, 1078, 1084, 1087, 1092, 1107, 1111, 1115, 1119, 1123, 1127, 1132, 1137, 1142, 1147, 1152, 1157, 1162, 1167, 1172, 1177, 1182, 1187, 1192, 1197, 1202, 1207, 1212, 1217, 1222, 1227, 1232, 1236, 1240, 1244, 1248, 1252, 1256, 1260, 1264, 1268, 1272, 1276, 1280, 1284, 1288, 1292, 1300, 1308, 1312, 1325, 1325, 1328, 1328, 1334, 1337, 1353, 1356, 1365, 1369, 1375, 1382, 1397, 1401, 1405, 1406, 1412, 1413, 1414, 1415, 1416, 1417, 1418, 1422, 1423, 1423, 1423, 1433, 1434, 1438, 1438, 1439, 1439, 1444, 1447, 1457, 1460, 1466, 1467, 1471, 1479, 1483, 1490, 1490, 1497, 1500, 1507, 1512, 1527, 1527, 1532, 1532, 1539, 1539, 1547, 1550, 1556, 1559, 1565, 1569, 1576, 1579, 1582, 1585, 1588, 1597, 1601, 1608, 1611, 1617, 1617 }; #endif #if YYDEBUG || YYERROR_VERBOSE || 0 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "INVARIANT", "HIGH_PRECISION", "MEDIUM_PRECISION", "LOW_PRECISION", "PRECISION", "ATTRIBUTE", "CONST_QUAL", "BOOL_TYPE", "FLOAT_TYPE", "INT_TYPE", "UINT_TYPE", "BREAK", "CONTINUE", "DO", "ELSE", "FOR", "IF", "DISCARD", "RETURN", "SWITCH", "CASE", "DEFAULT", "BVEC2", "BVEC3", "BVEC4", "IVEC2", "IVEC3", "IVEC4", "VEC2", "VEC3", "VEC4", "UVEC2", "UVEC3", "UVEC4", "MATRIX2", "MATRIX3", "MATRIX4", "IN_QUAL", "OUT_QUAL", "INOUT_QUAL", "UNIFORM", "VARYING", "MATRIX2x3", "MATRIX3x2", "MATRIX2x4", "MATRIX4x2", "MATRIX3x4", "MATRIX4x3", "CENTROID", "FLAT", "SMOOTH", "STRUCT", "VOID_TYPE", "WHILE", "SAMPLER2D", "SAMPLERCUBE", "SAMPLER_EXTERNAL_OES", "SAMPLER2DRECT", "SAMPLER2DARRAY", "ISAMPLER2D", "ISAMPLER3D", "ISAMPLERCUBE", "ISAMPLER2DARRAY", "USAMPLER2D", "USAMPLER3D", "USAMPLERCUBE", "USAMPLER2DARRAY", "SAMPLER3D", "SAMPLER3DRECT", "SAMPLER2DSHADOW", "SAMPLERCUBESHADOW", "SAMPLER2DARRAYSHADOW", "LAYOUT", "IDENTIFIER", "TYPE_NAME", "FLOATCONSTANT", "INTCONSTANT", "UINTCONSTANT", "BOOLCONSTANT", "FIELD_SELECTION", "LEFT_OP", "RIGHT_OP", "INC_OP", "DEC_OP", "LE_OP", "GE_OP", "EQ_OP", "NE_OP", "AND_OP", "OR_OP", "XOR_OP", "MUL_ASSIGN", "DIV_ASSIGN", "ADD_ASSIGN", "MOD_ASSIGN", "LEFT_ASSIGN", "RIGHT_ASSIGN", "AND_ASSIGN", "XOR_ASSIGN", "OR_ASSIGN", "SUB_ASSIGN", "LEFT_PAREN", "RIGHT_PAREN", "LEFT_BRACKET", "RIGHT_BRACKET", "LEFT_BRACE", "RIGHT_BRACE", "DOT", "COMMA", "COLON", "EQUAL", "SEMICOLON", "BANG", "DASH", "TILDE", "PLUS", "STAR", "SLASH", "PERCENT", "LEFT_ANGLE", "RIGHT_ANGLE", "VERTICAL_BAR", "CARET", "AMPERSAND", "QUESTION", "$accept", "identifier", "variable_identifier", "primary_expression", "postfix_expression", "integer_expression", "function_call", "function_call_or_method", "function_call_generic", "function_call_header_no_parameters", "function_call_header_with_parameters", "function_call_header", "function_identifier", "unary_expression", "unary_operator", "multiplicative_expression", "additive_expression", "shift_expression", "relational_expression", "equality_expression", "and_expression", "exclusive_or_expression", "inclusive_or_expression", "logical_and_expression", "logical_xor_expression", "logical_or_expression", "conditional_expression", "assignment_expression", "assignment_operator", "expression", "constant_expression", "enter_struct", "declaration", "function_prototype", "function_declarator", "function_header_with_parameters", "function_header", "parameter_declarator", "parameter_declaration", "parameter_qualifier", "parameter_type_specifier", "init_declarator_list", "single_declaration", "fully_specified_type", "interpolation_qualifier", "parameter_type_qualifier", "type_qualifier", "storage_qualifier", "type_specifier", "precision_qualifier", "layout_qualifier", "layout_qualifier_id_list", "layout_qualifier_id", "type_specifier_no_prec", "type_specifier_nonarray", "struct_specifier", "$@1", "$@2", "struct_declaration_list", "struct_declaration", "struct_declarator_list", "struct_declarator", "initializer", "declaration_statement", "statement", "simple_statement", "compound_statement", "$@3", "$@4", "statement_no_new_scope", "statement_with_scope", "$@5", "$@6", "compound_statement_no_new_scope", "statement_list", "expression_statement", "selection_statement", "selection_rest_statement", "switch_statement", "$@7", "case_label", "condition", "iteration_statement", "$@8", "$@9", "$@10", "for_init_statement", "conditionopt", "for_rest_statement", "jump_statement", "translation_unit", "external_declaration", "function_definition", "$@11", YY_NULLPTR }; #endif # ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382 }; # endif #define YYPACT_NINF -361 #define yypact_value_is_default(Yystate) \ (!!((Yystate) == (-361))) #define YYTABLE_NINF -235 #define yytable_value_is_error(Yytable_value) \ 0 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ static const yytype_int16 yypact[] = { 2154, 224, -361, -361, -361, 130, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, 145, -361, -361, -46, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -82, -361, -361, -68, -41, -45, 9, 7, -361, 117, 16, 1173, -361, -361, 2439, 16, -361, -9, -361, 2079, -361, -361, -361, -361, 16, -361, 2439, -361, -361, -361, -361, -361, -31, 23, -361, 11, -361, 63, -361, -361, -361, -361, -361, 2303, 168, 120, -361, 13, -66, -361, 31, -361, 2229, -361, -361, -361, 1243, -361, -361, -361, 56, 2229, -361, 17, -50, -361, 401, -361, -361, -361, -361, 120, 2303, -18, -361, 1341, 1632, -361, 179, 2303, 120, 1824, -361, 70, -361, -361, -361, -361, -361, 1632, 1632, 1632, -361, -361, -361, -361, -361, -361, -361, 22, -361, -361, -361, 101, -29, 1727, 114, -361, 1632, 96, -97, 128, -54, 111, 118, 102, 115, 154, 153, -69, -361, 140, -361, -361, 1909, 2229, 124, -361, 23, 134, 136, -361, 147, 149, 143, 1439, 155, 1632, 148, 157, 160, -361, -361, 184, -361, -361, 52, -361, -68, 158, -361, -361, -361, -361, 517, -361, -361, -361, -361, -361, -361, 166, -361, -361, 1534, 1632, 150, 159, -361, -361, 120, 167, 61, -361, -62, -361, -361, -361, -5, -361, -361, 1632, 2371, -361, -361, 1632, 185, -361, -361, -361, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, -361, -361, 1994, -361, -361, -361, -361, -361, 181, -361, 1632, -361, -361, 67, 1632, 180, -361, -361, -361, 633, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, 1632, 1632, -361, -361, -361, 1632, 178, 186, -361, 1632, 182, 68, 1632, 120, -361, -71, -361, -361, 187, 188, -361, 192, -361, -361, -361, -361, -361, 96, 96, -97, -97, 128, 128, 128, 128, -54, -54, 111, 118, 102, 115, 154, 153, 113, -361, 242, 11, 865, 981, 4, -361, 18, -361, 1078, 633, -361, -361, 194, 1632, 189, -361, 1632, -361, 196, -361, 1632, -361, -361, 1632, 200, -361, -361, -361, -361, 1078, 181, -361, 188, 120, 2303, 201, 198, -361, -361, 1632, -361, -361, 202, -361, 1632, -361, 191, 203, 293, -361, 204, 205, 749, -361, -361, 197, 60, 1632, 749, 181, -361, 1632, -361, -361, -361, -361, 199, 188, -361, -361, -361, -361 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. Performed when YYTABLE does not specify something else to do. Zero means the default is an error. */ static const yytype_uint16 yydefact[] = { 0, 0, 148, 149, 150, 0, 130, 140, 164, 161, 162, 163, 168, 169, 170, 171, 172, 173, 165, 166, 167, 174, 175, 176, 177, 178, 179, 141, 142, 145, 131, 180, 181, 182, 183, 184, 185, 0, 128, 127, 0, 160, 186, 188, 201, 202, 189, 190, 191, 192, 193, 194, 195, 196, 197, 187, 198, 199, 200, 0, 204, 273, 274, 0, 97, 107, 0, 112, 118, 135, 0, 133, 125, 0, 136, 146, 157, 203, 0, 270, 272, 132, 124, 0, 138, 0, 143, 144, 2, 3, 207, 0, 0, 88, 0, 95, 107, 129, 108, 109, 110, 98, 0, 107, 0, 89, 2, 119, 134, 0, 94, 0, 126, 147, 137, 0, 1, 271, 139, 0, 0, 205, 154, 0, 152, 0, 275, 99, 104, 106, 111, 0, 113, 100, 0, 0, 87, 0, 0, 0, 0, 209, 4, 8, 6, 7, 9, 30, 0, 0, 0, 158, 37, 36, 38, 35, 5, 11, 31, 13, 18, 19, 0, 0, 24, 0, 39, 0, 43, 46, 49, 54, 57, 59, 61, 63, 65, 67, 69, 86, 0, 28, 90, 0, 0, 0, 151, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 229, 238, 242, 39, 71, 84, 0, 218, 0, 146, 221, 240, 220, 219, 0, 222, 223, 224, 225, 226, 227, 101, 103, 105, 0, 0, 0, 0, 217, 123, 0, 215, 0, 213, 0, 210, 32, 33, 0, 15, 16, 0, 0, 22, 21, 0, 160, 25, 27, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 159, 208, 0, 155, 156, 153, 266, 265, 236, 257, 0, 269, 267, 0, 0, 0, 250, 253, 228, 0, 74, 75, 77, 76, 79, 80, 81, 82, 83, 78, 73, 0, 0, 243, 239, 241, 0, 0, 0, 117, 0, 120, 0, 0, 0, 211, 0, 91, 10, 0, 17, 29, 14, 20, 26, 40, 41, 42, 45, 44, 47, 48, 52, 53, 50, 51, 55, 56, 58, 60, 62, 64, 66, 68, 0, 206, 0, 0, 0, 0, 0, 268, 0, 249, 0, 230, 72, 85, 0, 0, 114, 121, 0, 212, 0, 214, 0, 92, 12, 0, 0, 235, 237, 260, 259, 262, 236, 247, 251, 0, 0, 0, 0, 102, 115, 0, 122, 216, 0, 70, 0, 261, 0, 0, 246, 244, 0, 0, 0, 231, 116, 0, 0, 263, 0, 236, 248, 0, 233, 254, 232, 93, 0, 264, 258, 245, 252, 256 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { -361, -39, -361, -361, -361, -361, -361, -361, 73, -361, -361, -361, -361, -107, -361, -15, -20, -67, -19, 53, 54, 55, 51, 57, 58, -361, -110, -132, -361, -146, -125, -361, 6, 12, -361, -361, -361, 190, 228, 217, 195, -361, -361, -336, 25, -361, -104, 27, -57, 322, -361, -361, 141, 0, -361, -361, -361, -361, -109, -130, 100, 19, -185, -17, -193, -310, -65, -361, -361, -70, -360, -361, -361, -92, 46, -13, -361, -361, -361, -361, -361, -38, -361, -361, -361, -361, -361, -361, -361, -361, -361, 259, -361, -361 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { -1, 230, 156, 157, 158, 318, 159, 160, 161, 162, 163, 164, 165, 202, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 203, 204, 300, 205, 180, 111, 206, 207, 63, 64, 65, 128, 101, 102, 129, 66, 67, 68, 69, 103, 70, 71, 72, 73, 74, 123, 124, 181, 76, 77, 184, 120, 140, 141, 231, 232, 228, 209, 210, 211, 212, 288, 381, 408, 345, 346, 347, 409, 213, 214, 215, 394, 216, 395, 217, 380, 218, 353, 277, 348, 374, 391, 392, 219, 78, 79, 80, 94 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule whose number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int16 yytable[] = { 75, 91, 126, 227, 237, 179, 61, 138, 166, 226, 234, 183, 62, 112, 315, 393, 138, 378, 97, 252, 304, 253, 92, 267, 179, 7, 83, 166, 84, 107, 88, 89, 246, 256, 257, 365, 138, 371, 378, 308, 134, 235, 236, 366, 414, 130, 93, 135, 282, 98, 99, 100, 316, 234, 139, 186, 27, 28, 268, 29, 248, 187, 90, 139, 95, 132, 96, 37, 258, 259, 75, 284, 97, 113, 130, 271, 243, 121, 75, 138, 138, 229, 244, 139, 61, 119, 179, 407, 223, 166, 62, 220, 227, 407, 319, 224, 108, 115, 307, 122, 317, 114, 75, 98, 99, 100, 301, 238, 239, 375, 118, 75, 323, 179, -96, 301, 166, 133, 104, 125, 75, 105, 343, 376, 360, 208, 139, 139, 240, 301, 185, 75, 241, 349, 2, 3, 4, 351, 75, 136, 75, 234, 324, 325, 326, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 304, 83, 301, 84, 411, 302, 138, 355, 356, 182, 301, 313, 383, -29, 314, 385, 227, 301, 313, 357, 350, 362, 75, 75, 86, 87, 363, 7, 331, 332, 333, 334, 106, 89, 179, 88, 89, 166, 399, 260, 261, 179, 272, 273, 166, 242, 377, 98, 99, 100, 254, 255, 208, 139, 249, 250, 251, 247, 27, 28, 415, 29, 81, 301, 368, 227, 263, 377, 227, 37, 38, 39, 7, 329, 330, 388, 327, 328, 264, 387, 335, 336, 401, 262, 265, 266, 269, 275, 379, 276, 278, 227, 279, 370, 179, 412, 280, 166, 283, 285, 286, -28, 309, 27, 28, 310, 29, 81, 287, 379, 75, 305, 312, 227, 37, 38, 39, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 208, -234, -23, 358, 352, 359, 367, 361, -30, 299, 369, 301, 82, 382, 384, 386, 389, 402, 397, 398, 403, 400, 404, 410, 199, 416, 322, 337, 340, 338, 406, 339, 131, 221, 112, 341, 127, 342, 222, 85, 274, 311, 405, 372, 364, 413, 354, 373, 390, 117, 0, 396, 0, 0, 0, 0, 0, 0, 0, 208, 208, 0, 0, 0, 0, 208, 208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 208, 0, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 208, 0, 0, 0, 0, 0, 208, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 188, 189, 190, 0, 191, 192, 193, 194, 195, 196, 197, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 198, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 59, 142, 60, 143, 144, 145, 146, 147, 0, 0, 148, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 199, 200, 0, 0, 0, 0, 201, 152, 153, 154, 155, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 188, 189, 190, 0, 191, 192, 193, 194, 195, 196, 197, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 198, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 59, 142, 60, 143, 144, 145, 146, 147, 0, 0, 148, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 199, 303, 0, 0, 0, 0, 201, 152, 153, 154, 155, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 188, 189, 190, 0, 191, 192, 193, 194, 195, 196, 197, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 198, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 59, 142, 60, 143, 144, 145, 146, 147, 0, 0, 148, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 199, 0, 0, 0, 0, 0, 201, 152, 153, 154, 155, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 188, 189, 190, 0, 191, 192, 193, 194, 195, 196, 197, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 198, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 59, 142, 60, 143, 144, 145, 146, 147, 0, 0, 148, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 125, 0, 0, 0, 0, 0, 201, 152, 153, 154, 155, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 188, 189, 190, 0, 191, 192, 193, 194, 195, 196, 197, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 198, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 59, 142, 60, 143, 144, 145, 146, 147, 0, 0, 148, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 201, 152, 153, 154, 155, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 59, 142, 60, 143, 144, 145, 146, 147, 0, 0, 148, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 137, 2, 3, 4, 150, 6, 7, 8, 9, 10, 11, 0, 0, 0, 201, 152, 153, 154, 155, 0, 0, 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 59, 142, 60, 143, 144, 145, 146, 147, 0, 0, 148, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 0, 0, 150, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0, 152, 153, 154, 155, 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, 31, 32, 33, 34, 35, 36, 0, 0, 0, 40, 41, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 0, 109, 60, 0, 0, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 110, 31, 32, 33, 34, 35, 36, 0, 0, 0, 40, 41, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 0, 142, 60, 143, 144, 145, 146, 147, 0, 0, 148, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 151, 8, 9, 10, 11, 0, 0, 0, 152, 153, 154, 155, 0, 0, 0, 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, 31, 32, 33, 34, 35, 36, 0, 0, 0, 40, 41, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 0, 142, 60, 143, 144, 145, 146, 147, 0, 0, 148, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 225, 8, 9, 10, 11, 0, 0, 0, 152, 153, 154, 155, 0, 0, 0, 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, 31, 32, 33, 34, 35, 36, 0, 0, 0, 40, 41, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 0, 142, 60, 143, 144, 145, 146, 147, 0, 0, 148, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 8, 9, 10, 11, 0, 0, 0, 0, 0, 281, 152, 153, 154, 155, 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, 31, 32, 33, 34, 35, 36, 0, 0, 0, 40, 41, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 0, 142, 60, 143, 144, 145, 146, 147, 0, 0, 148, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 306, 8, 9, 10, 11, 0, 0, 0, 152, 153, 154, 155, 0, 0, 0, 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, 31, 32, 33, 34, 35, 36, 0, 0, 0, 40, 41, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 0, 142, 60, 143, 144, 145, 146, 147, 0, 0, 148, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0, 152, 153, 154, 155, 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, 31, 32, 33, 34, 35, 36, 0, 0, 0, 40, 245, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 0, 142, 60, 143, 144, 145, 146, 147, 0, 0, 148, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 137, 2, 3, 4, 150, 6, 7, 8, 9, 10, 11, 0, 0, 0, 0, 152, 153, 154, 155, 0, 0, 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 59, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 137, 2, 3, 4, 0, 6, 7, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 233, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 59, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 137, 2, 3, 4, 0, 6, 7, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 270, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 59, 0, 60, 0, 0, 0, 0, 0, 0, 0, 116, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 344, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 59, 0, 60, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 59, 0, 60, 137, 2, 3, 4, 0, 6, 7, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 59, 0, 60, 2, 3, 4, 0, 0, 0, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, 31, 32, 33, 34, 35, 36, 0, 0, 0, 40, 41, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 0, 0, 60, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, 31, 32, 33, 34, 35, 36, 0, 0, 0, 40, 41, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 0, 320, 60, 8, 9, 10, 11, 321, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, 31, 32, 33, 34, 35, 36, 0, 0, 0, 40, 41, 0, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 56, 57, 58, 0, 0, 60 }; static const yytype_int16 yycheck[] = { 0, 40, 94, 135, 150, 115, 0, 111, 115, 134, 140, 120, 0, 70, 76, 375, 120, 353, 9, 116, 213, 118, 104, 92, 134, 9, 1, 134, 1, 68, 76, 77, 164, 87, 88, 106, 140, 347, 374, 224, 106, 148, 149, 114, 404, 102, 114, 113, 194, 40, 41, 42, 114, 183, 111, 105, 40, 41, 127, 43, 167, 111, 108, 120, 105, 104, 111, 51, 122, 123, 70, 196, 9, 73, 131, 184, 105, 108, 78, 183, 184, 138, 111, 140, 78, 85, 196, 397, 106, 196, 78, 130, 224, 403, 240, 113, 69, 106, 223, 76, 105, 74, 102, 40, 41, 42, 111, 85, 86, 105, 83, 111, 244, 223, 105, 111, 223, 104, 111, 108, 120, 114, 268, 105, 309, 125, 183, 184, 106, 111, 113, 131, 110, 279, 4, 5, 6, 283, 138, 108, 140, 271, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 354, 137, 111, 137, 105, 114, 271, 300, 301, 114, 111, 111, 358, 104, 114, 361, 309, 111, 111, 305, 114, 114, 183, 184, 40, 41, 312, 9, 256, 257, 258, 259, 76, 77, 305, 76, 77, 305, 384, 89, 90, 312, 79, 80, 312, 105, 353, 40, 41, 42, 83, 84, 213, 271, 119, 120, 121, 104, 40, 41, 406, 43, 44, 111, 112, 358, 125, 374, 361, 51, 52, 53, 9, 254, 255, 368, 252, 253, 124, 365, 260, 261, 389, 126, 91, 93, 107, 114, 353, 114, 104, 384, 104, 346, 365, 402, 114, 365, 104, 112, 104, 104, 113, 40, 41, 107, 43, 44, 109, 374, 271, 106, 106, 406, 51, 52, 53, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 288, 108, 105, 113, 112, 107, 107, 113, 104, 113, 56, 111, 76, 107, 113, 107, 104, 114, 105, 109, 105, 107, 17, 114, 108, 114, 241, 262, 265, 263, 113, 264, 103, 131, 379, 266, 96, 267, 131, 5, 187, 229, 395, 348, 313, 403, 288, 348, 374, 78, -1, 378, -1, -1, -1, -1, -1, -1, -1, 347, 348, -1, -1, -1, -1, 353, 354, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 374, -1, -1, -1, -1, 379, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 397, -1, -1, -1, -1, -1, 403, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, -1, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, 85, 86, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, 108, 109, -1, -1, -1, -1, 114, 115, 116, 117, 118, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, -1, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, 85, 86, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, 108, 109, -1, -1, -1, -1, 114, 115, 116, 117, 118, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, -1, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, 85, 86, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, 108, -1, -1, -1, -1, -1, 114, 115, 116, 117, 118, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, -1, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, 85, 86, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, 108, -1, -1, -1, -1, -1, 114, 115, 116, 117, 118, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, -1, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, 85, 86, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, -1, -1, 114, 115, 116, 117, 118, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, -1, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, 85, 86, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, 5, 6, 104, 8, 9, 10, 11, 12, 13, -1, -1, -1, 114, 115, 116, 117, 118, -1, -1, -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, -1, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, 85, 86, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, 5, 6, -1, -1, 104, 10, 11, 12, 13, -1, -1, -1, -1, -1, -1, 115, 116, 117, 118, -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, -1, 45, 46, 47, 48, 49, 50, -1, -1, -1, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, -1, 76, 77, -1, -1, 10, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, 114, 45, 46, 47, 48, 49, 50, -1, -1, -1, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, -1, 76, 77, 78, 79, 80, 81, 82, -1, -1, 85, 86, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, 107, 10, 11, 12, 13, -1, -1, -1, 115, 116, 117, 118, -1, -1, -1, -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, -1, 45, 46, 47, 48, 49, 50, -1, -1, -1, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, -1, 76, 77, 78, 79, 80, 81, 82, -1, -1, 85, 86, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, 107, 10, 11, 12, 13, -1, -1, -1, 115, 116, 117, 118, -1, -1, -1, -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, -1, 45, 46, 47, 48, 49, 50, -1, -1, -1, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, -1, 76, 77, 78, 79, 80, 81, 82, -1, -1, 85, 86, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, 10, 11, 12, 13, -1, -1, -1, -1, -1, 114, 115, 116, 117, 118, -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, -1, 45, 46, 47, 48, 49, 50, -1, -1, -1, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, -1, 76, 77, 78, 79, 80, 81, 82, -1, -1, 85, 86, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, 107, 10, 11, 12, 13, -1, -1, -1, 115, 116, 117, 118, -1, -1, -1, -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, -1, 45, 46, 47, 48, 49, 50, -1, -1, -1, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, -1, 76, 77, 78, 79, 80, 81, 82, -1, -1, 85, 86, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, 10, 11, 12, 13, -1, -1, -1, -1, -1, -1, 115, 116, 117, 118, -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, -1, 45, 46, 47, 48, 49, 50, -1, -1, -1, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, -1, 76, 77, 78, 79, 80, 81, 82, -1, -1, 85, 86, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, 5, 6, 104, 8, 9, 10, 11, 12, 13, -1, -1, -1, -1, 115, 116, 117, 118, -1, -1, -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, -1, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, 75, -1, 77, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, 5, 6, -1, 8, 9, 10, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 109, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, -1, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, 75, -1, 77, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, 5, 6, -1, 8, 9, 10, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 109, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, -1, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, 75, -1, 77, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 109, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, -1, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, 75, -1, 77, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, -1, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, 75, -1, 77, 3, 4, 5, 6, -1, 8, 9, 10, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, -1, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, 75, -1, 77, 4, 5, 6, -1, -1, -1, 10, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, -1, 45, 46, 47, 48, 49, 50, -1, -1, -1, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, -1, -1, 77, 10, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, -1, 45, 46, 47, 48, 49, 50, -1, -1, -1, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, -1, 76, 77, 10, 11, 12, 13, 82, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, -1, 45, 46, 47, 48, 49, 50, -1, -1, -1, 54, 55, -1, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, 74, -1, -1, 77 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 72, 73, 74, 75, 77, 160, 161, 162, 163, 164, 169, 170, 171, 172, 174, 175, 176, 177, 178, 181, 182, 183, 218, 219, 220, 44, 76, 172, 175, 177, 40, 41, 76, 77, 108, 129, 104, 114, 221, 105, 111, 9, 40, 41, 42, 166, 167, 173, 111, 114, 76, 129, 175, 76, 114, 159, 176, 181, 175, 106, 0, 219, 175, 181, 185, 108, 76, 179, 180, 108, 201, 166, 165, 168, 176, 167, 129, 104, 106, 113, 108, 3, 174, 176, 186, 187, 76, 78, 79, 80, 81, 82, 85, 86, 104, 107, 115, 116, 117, 118, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 158, 181, 114, 186, 184, 113, 105, 111, 14, 15, 16, 18, 19, 20, 21, 22, 23, 24, 56, 108, 109, 114, 141, 154, 155, 157, 160, 161, 181, 191, 192, 193, 194, 202, 203, 204, 206, 208, 210, 217, 129, 165, 168, 106, 113, 107, 158, 155, 190, 176, 129, 188, 189, 109, 187, 141, 141, 157, 85, 86, 106, 110, 105, 105, 111, 55, 155, 104, 141, 119, 120, 121, 116, 118, 83, 84, 87, 88, 122, 123, 89, 90, 126, 125, 124, 91, 93, 92, 127, 107, 109, 186, 79, 80, 180, 114, 114, 212, 104, 104, 114, 114, 157, 104, 158, 112, 104, 109, 195, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 113, 156, 111, 114, 109, 192, 106, 107, 158, 190, 113, 107, 188, 106, 111, 114, 76, 114, 105, 133, 157, 76, 82, 136, 155, 141, 141, 141, 143, 143, 144, 144, 145, 145, 145, 145, 146, 146, 147, 148, 149, 150, 151, 152, 157, 109, 198, 199, 200, 213, 157, 114, 157, 112, 211, 202, 155, 155, 158, 113, 107, 190, 113, 114, 158, 189, 106, 114, 107, 112, 56, 201, 193, 191, 203, 214, 105, 105, 157, 171, 174, 209, 196, 107, 190, 113, 190, 107, 158, 155, 104, 209, 215, 216, 198, 205, 207, 129, 105, 109, 190, 107, 157, 114, 105, 17, 194, 113, 193, 197, 201, 114, 105, 157, 197, 198, 190, 114 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { 0, 128, 129, 129, 130, 131, 131, 131, 131, 131, 131, 132, 132, 132, 132, 132, 132, 133, 134, 135, 135, 136, 136, 137, 137, 138, 138, 139, 140, 140, 140, 141, 141, 141, 141, 142, 142, 142, 142, 143, 143, 143, 143, 144, 144, 144, 145, 145, 145, 146, 146, 146, 146, 146, 147, 147, 147, 148, 148, 149, 149, 150, 150, 151, 151, 152, 152, 153, 153, 154, 154, 155, 155, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 157, 157, 158, 159, 160, 160, 160, 160, 160, 160, 160, 161, 162, 162, 163, 163, 164, 165, 165, 166, 166, 166, 166, 167, 167, 167, 167, 168, 169, 169, 169, 169, 169, 169, 170, 170, 170, 170, 170, 170, 170, 171, 171, 172, 172, 173, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 175, 175, 175, 175, 175, 175, 176, 176, 177, 177, 177, 178, 179, 179, 180, 180, 180, 181, 181, 181, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 184, 183, 185, 183, 186, 186, 187, 187, 188, 188, 189, 189, 190, 191, 192, 192, 193, 193, 193, 193, 193, 193, 193, 194, 195, 196, 194, 197, 197, 199, 198, 200, 198, 201, 201, 202, 202, 203, 203, 204, 205, 205, 207, 206, 208, 208, 209, 209, 211, 210, 212, 210, 213, 210, 214, 214, 215, 215, 216, 216, 217, 217, 217, 217, 217, 218, 218, 219, 219, 221, 220 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 4, 1, 3, 2, 2, 1, 1, 1, 3, 2, 2, 2, 1, 2, 3, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 3, 3, 3, 1, 3, 3, 1, 3, 3, 1, 3, 3, 3, 3, 1, 3, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 5, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, 2, 2, 4, 5, 6, 9, 2, 2, 1, 1, 2, 3, 3, 2, 5, 3, 2, 3, 2, 0, 1, 1, 1, 1, 1, 3, 6, 7, 8, 5, 1, 2, 5, 6, 7, 4, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 3, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1, 1, 4, 1, 3, 1, 3, 3, 1, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 6, 0, 5, 1, 2, 3, 4, 1, 3, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 5, 1, 1, 0, 2, 0, 2, 2, 3, 1, 2, 1, 2, 5, 3, 1, 0, 6, 3, 2, 1, 4, 0, 6, 0, 8, 0, 7, 1, 1, 1, 0, 2, 3, 2, 2, 2, 3, 2, 1, 2, 1, 1, 0, 3 }; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY) \ { \ yychar = (Token); \ yylval = (Value); \ YYPOPSTACK (yylen); \ yystate = *yyssp; \ goto yybackup; \ } \ else \ { \ yyerror (&yylloc, context, scanner, YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (0) /* Error token number */ #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ if (N) \ { \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ } \ else \ { \ (Current).first_line = (Current).last_line = \ YYRHSLOC (Rhs, 0).last_line; \ (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ while (0) #endif #define YYRHSLOC(Rhs, K) ((Rhs)[K]) /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) /* YY_LOCATION_PRINT -- Print the location on the stream. This macro was not mandated originally: define only if we know we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL /* Print *YYLOCP on YYO. Private, do not rely on its existence. */ YY_ATTRIBUTE_UNUSED static unsigned yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp) { unsigned res = 0; int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0; if (0 <= yylocp->first_line) { res += YYFPRINTF (yyo, "%d", yylocp->first_line); if (0 <= yylocp->first_column) res += YYFPRINTF (yyo, ".%d", yylocp->first_column); } if (0 <= yylocp->last_line) { if (yylocp->first_line < yylocp->last_line) { res += YYFPRINTF (yyo, "-%d", yylocp->last_line); if (0 <= end_col) res += YYFPRINTF (yyo, ".%d", end_col); } else if (0 <= end_col && yylocp->first_column < end_col) res += YYFPRINTF (yyo, "-%d", end_col); } return res; } # define YY_LOCATION_PRINT(File, Loc) \ yy_location_print_ (File, &(Loc)) # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif #endif # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ Type, Value, Location, context, scanner); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) /*----------------------------------------. | Print this symbol's value on YYOUTPUT. | `----------------------------------------*/ static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, TParseContext* context, void *scanner) { FILE *yyo = yyoutput; YYUSE (yyo); YYUSE (yylocationp); YYUSE (context); YYUSE (scanner); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # endif YYUSE (yytype); } /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, TParseContext* context, void *scanner) { YYFPRINTF (yyoutput, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); YY_LOCATION_PRINT (yyoutput, *yylocationp); YYFPRINTF (yyoutput, ": "); yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, context, scanner); YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) { int yybot = *yybottom; YYFPRINTF (stderr, " %d", yybot); } YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ static void yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, TParseContext* context, void *scanner) { unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], &(yyvsp[(yyi + 1) - (yynrhs)]) , &(yylsp[(yyi + 1) - (yynrhs)]) , context, scanner); YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyssp, yyvsp, yylsp, Rule, context, scanner); \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ static YYSIZE_T yystrlen (const char *yystr) { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } # endif # endif # ifndef yystpcpy # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ static char * yystpcpy (char *yydest, const char *yysrc) { char *yyd = yydest; const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif # ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ static YYSIZE_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) switch (*++yyp) { case '\'': case ',': goto do_not_strip_quotes; case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; yyn++; break; case '"': if (yyres) yyres[yyn] = '\0'; return yyn; } do_not_strip_quotes: ; } if (! yyres) return yystrlen (yystr); return yystpcpy (yyres, yystr) - yyres; } # endif /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message about the unexpected token YYTOKEN for the state stack whose top is YYSSP. Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is not large enough to hold the message. In that case, also set *YYMSG_ALLOC to the required number of bytes. Return 2 if the required number of bytes is too large to store. */ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = YY_NULLPTR; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per "expected"). */ int yycount = 0; /* There are many possibilities here to consider: - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action is an error action. In that case, don't check for expected tokens because there are none. - The only way there can be no lookahead present (in yychar) is if this state is a consistent state with a default action. Thus, detecting the absence of a lookahead is sufficient to determine that there is no unexpected or expected token to report. In that case, just report a simple "syntax error". - Don't assume there isn't a lookahead just because this state is a consistent state with a default action. There might have been a previous inconsistent state, consistent state with a non-default action, or user semantic action that manipulated yychar. - Of course, the expected token list depends on states to have correct lookahead information, and it depends on the parser not to perform extra reductions after fetching a lookahead from the scanner and before detecting a syntax error. Thus, state merging (from LALR or IELR) and default reductions corrupt the expected token list. However, the list is correct for canonical LR with one exception: it will still contain any token that will not be accepted due to an error action in a later state. */ if (yytoken != YYEMPTY) { int yyn = yypact[*yyssp]; yyarg[yycount++] = yytname[yytoken]; if (!yypact_value_is_default (yyn)) { /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. In other words, skip the first -YYN actions for this state because they are default actions. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yyx; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR && !yytable_value_is_error (yytable[yyx + yyn])) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; break; } yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; } } } } switch (yycount) { # define YYCASE_(N, S) \ case N: \ yyformat = S; \ break YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); # undef YYCASE_ } { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; } if (*yymsg_alloc < yysize) { *yymsg_alloc = 2 * yysize; if (! (yysize <= *yymsg_alloc && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; return 1; } /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ { char *yyp = *yymsg; int yyi = 0; while ((*yyp = *yyformat) != '\0') if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyformat += 2; } else { yyp++; yyformat++; } } return 0; } #endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, TParseContext* context, void *scanner) { YYUSE (yyvaluep); YYUSE (yylocationp); YYUSE (context); YYUSE (scanner); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YYUSE (yytype); YY_IGNORE_MAYBE_UNINITIALIZED_END } /*----------. | yyparse. | `----------*/ int yyparse (TParseContext* context, void *scanner) { /* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ /* Default value used for initialization, for pacifying older GCCs or non-GCC compilers. */ YY_INITIAL_VALUE (static YYSTYPE yyval_default;) YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); /* Location data for the lookahead symbol. */ static YYLTYPE yyloc_default # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL = { 1, 1, 1, 1 } # endif ; YYLTYPE yylloc = yyloc_default; /* Number of syntax errors so far. */ int yynerrs; int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: 'yyss': related to states. 'yyvs': related to semantic values. 'yyls': related to locations. Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ yytype_int16 yyssa[YYINITDEPTH]; yytype_int16 *yyss; yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; /* The location stack. */ YYLTYPE yylsa[YYINITDEPTH]; YYLTYPE *yyls; YYLTYPE *yylsp; /* The locations where the error started and ended. */ YYLTYPE yyerror_range[3]; YYSIZE_T yystacksize; int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ int yytoken = 0; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; YYLTYPE yyloc; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; yyssp = yyss = yyssa; yyvsp = yyvs = yyvsa; yylsp = yyls = yylsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ yylsp[0] = yylloc; goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; YYLTYPE *yyls1 = yyls; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yyls1, yysize * sizeof (*yylsp), &yystacksize); yyls = yyls1; yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); YYSTACK_RELOCATE (yyls_alloc, yyls); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; yylsp = yyls + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = yylex (&yylval, &yylloc, scanner); } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yytable_value_is_error (yyn)) goto yyerrlab; yyn = -yyn; goto yyreduce; } /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token. */ yychar = YYEMPTY; yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END *++yylsp = yylloc; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: '$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; /* Default location. */ YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); YY_REDUCE_PRINT (yyn); switch (yyn) { case 4: { // The symbol table search was done in the lexical phase const TVariable *variable = context->getNamedVariable((yylsp[0]), (yyvsp[0].lex).string, (yyvsp[0].lex).symbol); if (variable->getType().getQualifier() == EvqConst) { TConstantUnion* constArray = variable->getConstPointer(); TType t(variable->getType()); (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(constArray, t, (yylsp[0])); } else { (yyval.interm.intermTypedNode) = context->intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), (yylsp[0])); } // don't delete $1.string, it's used by error recovery, and the pool // pop will reclaim the memory } break; case 5: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 6: { TConstantUnion *unionArray = new TConstantUnion[1]; unionArray->setIConst((yyvsp[0].lex).i); (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), (yylsp[0])); } break; case 7: { TConstantUnion *unionArray = new TConstantUnion[1]; unionArray->setUConst((yyvsp[0].lex).u); (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtUInt, EbpUndefined, EvqConst), (yylsp[0])); } break; case 8: { TConstantUnion *unionArray = new TConstantUnion[1]; unionArray->setFConst((yyvsp[0].lex).f); (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), (yylsp[0])); } break; case 9: { TConstantUnion *unionArray = new TConstantUnion[1]; unionArray->setBConst((yyvsp[0].lex).b); (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), (yylsp[0])); } break; case 10: { (yyval.interm.intermTypedNode) = (yyvsp[-1].interm.intermTypedNode); } break; case 11: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 12: { (yyval.interm.intermTypedNode) = context->addIndexExpression((yyvsp[-3].interm.intermTypedNode), (yylsp[-2]), (yyvsp[-1].interm.intermTypedNode)); } break; case 13: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 14: { (yyval.interm.intermTypedNode) = context->addFieldSelectionExpression((yyvsp[-2].interm.intermTypedNode), (yylsp[-1]), *(yyvsp[0].lex).string, (yylsp[0])); } break; case 15: { (yyval.interm.intermTypedNode) = context->addUnaryMathLValue(EOpPostIncrement, (yyvsp[-1].interm.intermTypedNode), (yylsp[0])); } break; case 16: { (yyval.interm.intermTypedNode) = context->addUnaryMathLValue(EOpPostDecrement, (yyvsp[-1].interm.intermTypedNode), (yylsp[0])); } break; case 17: { if (context->integerErrorCheck((yyvsp[0].interm.intermTypedNode), "[]")) context->recover(); (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 18: { bool fatalError = false; (yyval.interm.intermTypedNode) = context->addFunctionCallOrMethod((yyvsp[0].interm).function, (yyvsp[0].interm).nodePair.node1, (yyvsp[0].interm).nodePair.node2, (yylsp[0]), &fatalError); if (fatalError) { YYERROR; } } break; case 19: { (yyval.interm) = (yyvsp[0].interm); (yyval.interm).nodePair.node2 = nullptr; } break; case 20: { ES3_ONLY("", (yylsp[0]), "methods"); (yyval.interm) = (yyvsp[0].interm); (yyval.interm).nodePair.node2 = (yyvsp[-2].interm.intermTypedNode); } break; case 21: { (yyval.interm) = (yyvsp[-1].interm); } break; case 22: { (yyval.interm) = (yyvsp[-1].interm); } break; case 23: { (yyval.interm).function = (yyvsp[-1].interm.function); (yyval.interm).nodePair.node1 = nullptr; } break; case 24: { (yyval.interm).function = (yyvsp[0].interm.function); (yyval.interm).nodePair.node1 = nullptr; } break; case 25: { const TType *type = new TType((yyvsp[0].interm.intermTypedNode)->getType()); (yyvsp[-1].interm.function)->addParameter(TConstParameter(type)); (yyval.interm).function = (yyvsp[-1].interm.function); (yyval.interm).nodePair.node1 = (yyvsp[0].interm.intermTypedNode); } break; case 26: { const TType *type = new TType((yyvsp[0].interm.intermTypedNode)->getType()); (yyvsp[-2].interm).function->addParameter(TConstParameter(type)); (yyval.interm).function = (yyvsp[-2].interm).function; (yyval.interm).nodePair.node1 = context->intermediate.growAggregate((yyvsp[-2].interm).intermNode, (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 27: { (yyval.interm.function) = (yyvsp[-1].interm.function); } break; case 28: { if ((yyvsp[0].interm.type).array) { ES3_ONLY("[]", (yylsp[0]), "array constructor"); } (yyval.interm.function) = context->addConstructorFunc((yyvsp[0].interm.type)); } break; case 29: { if (context->reservedErrorCheck((yylsp[0]), *(yyvsp[0].lex).string)) context->recover(); const TType *type = TCache::getType(EbtVoid, EbpUndefined); TFunction *function = new TFunction((yyvsp[0].lex).string, type); (yyval.interm.function) = function; } break; case 30: { if (context->reservedErrorCheck((yylsp[0]), *(yyvsp[0].lex).string)) context->recover(); const TType *type = TCache::getType(EbtVoid, EbpUndefined); TFunction *function = new TFunction((yyvsp[0].lex).string, type); (yyval.interm.function) = function; } break; case 31: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 32: { (yyval.interm.intermTypedNode) = context->addUnaryMathLValue(EOpPreIncrement, (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 33: { (yyval.interm.intermTypedNode) = context->addUnaryMathLValue(EOpPreDecrement, (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 34: { if ((yyvsp[-1].interm).op != EOpNull) { (yyval.interm.intermTypedNode) = context->addUnaryMath((yyvsp[-1].interm).op, (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } else (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 35: { (yyval.interm).op = EOpPositive; } break; case 36: { (yyval.interm).op = EOpNegative; } break; case 37: { (yyval.interm).op = EOpLogicalNot; } break; case 38: { ES3_ONLY("~", (yyloc), "bit-wise operator"); (yyval.interm).op = EOpBitwiseNot; } break; case 39: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 40: { (yyval.interm.intermTypedNode) = context->addBinaryMath(EOpMul, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 41: { (yyval.interm.intermTypedNode) = context->addBinaryMath(EOpDiv, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 42: { ES3_ONLY("%", (yylsp[-1]), "integer modulus operator"); (yyval.interm.intermTypedNode) = context->addBinaryMath(EOpIMod, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 43: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 44: { (yyval.interm.intermTypedNode) = context->addBinaryMath(EOpAdd, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 45: { (yyval.interm.intermTypedNode) = context->addBinaryMath(EOpSub, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 46: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 47: { ES3_ONLY("<<", (yylsp[-1]), "bit-wise operator"); (yyval.interm.intermTypedNode) = context->addBinaryMath(EOpBitShiftLeft, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 48: { ES3_ONLY(">>", (yylsp[-1]), "bit-wise operator"); (yyval.interm.intermTypedNode) = context->addBinaryMath(EOpBitShiftRight, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 49: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 50: { (yyval.interm.intermTypedNode) = context->addBinaryMathBooleanResult(EOpLessThan, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 51: { (yyval.interm.intermTypedNode) = context->addBinaryMathBooleanResult(EOpGreaterThan, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 52: { (yyval.interm.intermTypedNode) = context->addBinaryMathBooleanResult(EOpLessThanEqual, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 53: { (yyval.interm.intermTypedNode) = context->addBinaryMathBooleanResult(EOpGreaterThanEqual, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 54: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 55: { (yyval.interm.intermTypedNode) = context->addBinaryMathBooleanResult(EOpEqual, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 56: { (yyval.interm.intermTypedNode) = context->addBinaryMathBooleanResult(EOpNotEqual, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 57: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 58: { ES3_ONLY("&", (yylsp[-1]), "bit-wise operator"); (yyval.interm.intermTypedNode) = context->addBinaryMath(EOpBitwiseAnd, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 59: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 60: { ES3_ONLY("^", (yylsp[-1]), "bit-wise operator"); (yyval.interm.intermTypedNode) = context->addBinaryMath(EOpBitwiseXor, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 61: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 62: { ES3_ONLY("|", (yylsp[-1]), "bit-wise operator"); (yyval.interm.intermTypedNode) = context->addBinaryMath(EOpBitwiseOr, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 63: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 64: { (yyval.interm.intermTypedNode) = context->addBinaryMathBooleanResult(EOpLogicalAnd, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 65: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 66: { (yyval.interm.intermTypedNode) = context->addBinaryMathBooleanResult(EOpLogicalXor, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 67: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 68: { (yyval.interm.intermTypedNode) = context->addBinaryMathBooleanResult(EOpLogicalOr, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 69: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 70: { (yyval.interm.intermTypedNode) = context->addTernarySelection((yyvsp[-4].interm.intermTypedNode), (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-3])); } break; case 71: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 72: { if (context->lValueErrorCheck((yylsp[-1]), "assign", (yyvsp[-2].interm.intermTypedNode))) context->recover(); (yyval.interm.intermTypedNode) = context->addAssign((yyvsp[-1].interm).op, (yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); } break; case 73: { (yyval.interm).op = EOpAssign; } break; case 74: { (yyval.interm).op = EOpMulAssign; } break; case 75: { (yyval.interm).op = EOpDivAssign; } break; case 76: { ES3_ONLY("%=", (yyloc), "integer modulus operator"); (yyval.interm).op = EOpIModAssign; } break; case 77: { (yyval.interm).op = EOpAddAssign; } break; case 78: { (yyval.interm).op = EOpSubAssign; } break; case 79: { ES3_ONLY("<<=", (yyloc), "bit-wise operator"); (yyval.interm).op = EOpBitShiftLeftAssign; } break; case 80: { ES3_ONLY(">>=", (yyloc), "bit-wise operator"); (yyval.interm).op = EOpBitShiftRightAssign; } break; case 81: { ES3_ONLY("&=", (yyloc), "bit-wise operator"); (yyval.interm).op = EOpBitwiseAndAssign; } break; case 82: { ES3_ONLY("^=", (yyloc), "bit-wise operator"); (yyval.interm).op = EOpBitwiseXorAssign; } break; case 83: { ES3_ONLY("|=", (yyloc), "bit-wise operator"); (yyval.interm).op = EOpBitwiseOrAssign; } break; case 84: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 85: { (yyval.interm.intermTypedNode) = context->intermediate.addComma((yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1])); if ((yyval.interm.intermTypedNode) == 0) { context->binaryOpError((yylsp[-1]), ",", (yyvsp[-2].interm.intermTypedNode)->getCompleteString(), (yyvsp[0].interm.intermTypedNode)->getCompleteString()); context->recover(); (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } } break; case 86: { if (context->constErrorCheck((yyvsp[0].interm.intermTypedNode))) context->recover(); (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 87: { if (context->enterStructDeclaration((yylsp[-1]), *(yyvsp[-1].lex).string)) context->recover(); (yyval.lex) = (yyvsp[-1].lex); } break; case 88: { TFunction &function = *((yyvsp[-1].interm).function); TIntermAggregate *prototype = new TIntermAggregate; prototype->setType(function.getReturnType()); prototype->setName(function.getMangledName()); prototype->setFunctionId(function.getUniqueId()); for (size_t i = 0; i < function.getParamCount(); i++) { const TConstParameter ¶m = function.getParam(i); if (param.name != 0) { TVariable variable(param.name, *param.type); prototype = context->intermediate.growAggregate(prototype, context->intermediate.addSymbol(variable.getUniqueId(), variable.getName(), variable.getType(), (yylsp[-1])), (yylsp[-1])); } else { prototype = context->intermediate.growAggregate(prototype, context->intermediate.addSymbol(0, "", *param.type, (yylsp[-1])), (yylsp[-1])); } } prototype->setOp(EOpPrototype); (yyval.interm.intermNode) = prototype; context->symbolTable.pop(); } break; case 89: { TIntermAggregate *aggNode = (yyvsp[-1].interm).intermAggregate; if (aggNode && aggNode->getOp() == EOpNull) aggNode->setOp(EOpDeclaration); (yyval.interm.intermNode) = aggNode; } break; case 90: { if (((yyvsp[-2].interm.precision) == EbpHigh) && (context->getShaderType() == GL_FRAGMENT_SHADER) && !context->getFragmentPrecisionHigh()) { context->error((yylsp[-3]), "precision is not supported in fragment shader", "highp"); context->recover(); } if (!context->symbolTable.setDefaultPrecision( (yyvsp[-1].interm.type), (yyvsp[-2].interm.precision) )) { context->error((yylsp[-3]), "illegal type argument for default precision qualifier", getBasicString((yyvsp[-1].interm.type).type)); context->recover(); } (yyval.interm.intermNode) = 0; } break; case 91: { ES3_ONLY(getQualifierString((yyvsp[-4].interm.type).qualifier), (yylsp[-4]), "interface blocks"); (yyval.interm.intermNode) = context->addInterfaceBlock((yyvsp[-4].interm.type), (yylsp[-3]), *(yyvsp[-3].lex).string, (yyvsp[-2].interm.fieldList), NULL, (yyloc), NULL, (yyloc)); } break; case 92: { ES3_ONLY(getQualifierString((yyvsp[-5].interm.type).qualifier), (yylsp[-5]), "interface blocks"); (yyval.interm.intermNode) = context->addInterfaceBlock((yyvsp[-5].interm.type), (yylsp[-4]), *(yyvsp[-4].lex).string, (yyvsp[-3].interm.fieldList), (yyvsp[-1].lex).string, (yylsp[-1]), NULL, (yyloc)); } break; case 93: { ES3_ONLY(getQualifierString((yyvsp[-8].interm.type).qualifier), (yylsp[-8]), "interface blocks"); (yyval.interm.intermNode) = context->addInterfaceBlock((yyvsp[-8].interm.type), (yylsp[-7]), *(yyvsp[-7].lex).string, (yyvsp[-6].interm.fieldList), (yyvsp[-4].lex).string, (yylsp[-4]), (yyvsp[-2].interm.intermTypedNode), (yylsp[-3])); } break; case 94: { context->parseGlobalLayoutQualifier((yyvsp[-1].interm.type)); (yyval.interm.intermNode) = 0; } break; case 95: { (yyval.interm).function = context->parseFunctionDeclarator((yylsp[0]), (yyvsp[-1].interm.function)); } break; case 96: { (yyval.interm.function) = (yyvsp[0].interm.function); } break; case 97: { (yyval.interm.function) = (yyvsp[0].interm.function); } break; case 98: { // Add the parameter (yyval.interm.function) = (yyvsp[-1].interm.function); if ((yyvsp[0].interm).param.type->getBasicType() != EbtVoid) (yyvsp[-1].interm.function)->addParameter((yyvsp[0].interm).param.turnToConst()); else delete (yyvsp[0].interm).param.type; } break; case 99: { // // Only first parameter of one-parameter functions can be void // The check for named parameters not being void is done in parameter_declarator // if ((yyvsp[0].interm).param.type->getBasicType() == EbtVoid) { // // This parameter > first is void // context->error((yylsp[-1]), "cannot be an argument type except for '(void)'", "void"); context->recover(); delete (yyvsp[0].interm).param.type; } else { // Add the parameter (yyval.interm.function) = (yyvsp[-2].interm.function); (yyvsp[-2].interm.function)->addParameter((yyvsp[0].interm).param.turnToConst()); } } break; case 100: { if ((yyvsp[-2].interm.type).qualifier != EvqGlobal && (yyvsp[-2].interm.type).qualifier != EvqTemporary) { context->error((yylsp[-1]), "no qualifiers allowed for function return", getQualifierString((yyvsp[-2].interm.type).qualifier)); context->recover(); } if (!(yyvsp[-2].interm.type).layoutQualifier.isEmpty()) { context->error((yylsp[-1]), "no qualifiers allowed for function return", "layout"); context->recover(); } // make sure a sampler is not involved as well... if (context->samplerErrorCheck((yylsp[-1]), (yyvsp[-2].interm.type), "samplers can't be function return values")) context->recover(); // Add the function as a prototype after parsing it (we do not support recursion) TFunction *function; const TType *type = new TType((yyvsp[-2].interm.type)); function = new TFunction((yyvsp[-1].lex).string, type); (yyval.interm.function) = function; context->symbolTable.push(); } break; case 101: { if ((yyvsp[-1].interm.type).type == EbtVoid) { context->error((yylsp[0]), "illegal use of type 'void'", (yyvsp[0].lex).string->c_str()); context->recover(); } if (context->reservedErrorCheck((yylsp[0]), *(yyvsp[0].lex).string)) context->recover(); TParameter param = {(yyvsp[0].lex).string, new TType((yyvsp[-1].interm.type))}; (yyval.interm).param = param; } break; case 102: { // Check that we can make an array out of this type if (context->arrayTypeErrorCheck((yylsp[-2]), (yyvsp[-4].interm.type))) context->recover(); if (context->reservedErrorCheck((yylsp[-3]), *(yyvsp[-3].lex).string)) context->recover(); int size; if (context->arraySizeErrorCheck((yylsp[-2]), (yyvsp[-1].interm.intermTypedNode), size)) context->recover(); (yyvsp[-4].interm.type).setArraySize(size); TType* type = new TType((yyvsp[-4].interm.type)); TParameter param = { (yyvsp[-3].lex).string, type }; (yyval.interm).param = param; } break; case 103: { (yyval.interm) = (yyvsp[0].interm); if (context->paramErrorCheck((yylsp[0]), (yyvsp[-2].interm.qualifier), (yyvsp[-1].interm.qualifier), (yyval.interm).param.type)) context->recover(); } break; case 104: { (yyval.interm) = (yyvsp[0].interm); if (context->parameterSamplerErrorCheck((yylsp[0]), (yyvsp[-1].interm.qualifier), *(yyvsp[0].interm).param.type)) context->recover(); if (context->paramErrorCheck((yylsp[0]), EvqTemporary, (yyvsp[-1].interm.qualifier), (yyval.interm).param.type)) context->recover(); } break; case 105: { (yyval.interm) = (yyvsp[0].interm); if (context->paramErrorCheck((yylsp[0]), (yyvsp[-2].interm.qualifier), (yyvsp[-1].interm.qualifier), (yyval.interm).param.type)) context->recover(); } break; case 106: { (yyval.interm) = (yyvsp[0].interm); if (context->parameterSamplerErrorCheck((yylsp[0]), (yyvsp[-1].interm.qualifier), *(yyvsp[0].interm).param.type)) context->recover(); if (context->paramErrorCheck((yylsp[0]), EvqTemporary, (yyvsp[-1].interm.qualifier), (yyval.interm).param.type)) context->recover(); } break; case 107: { (yyval.interm.qualifier) = EvqIn; } break; case 108: { (yyval.interm.qualifier) = EvqIn; } break; case 109: { (yyval.interm.qualifier) = EvqOut; } break; case 110: { (yyval.interm.qualifier) = EvqInOut; } break; case 111: { TParameter param = { 0, new TType((yyvsp[0].interm.type)) }; (yyval.interm).param = param; } break; case 112: { (yyval.interm) = (yyvsp[0].interm); } break; case 113: { (yyval.interm) = (yyvsp[-2].interm); (yyval.interm).intermAggregate = context->parseDeclarator((yyval.interm).type, (yyvsp[-2].interm).intermAggregate, (yylsp[0]), *(yyvsp[0].lex).string); } break; case 114: { (yyval.interm) = (yyvsp[-5].interm); (yyval.interm).intermAggregate = context->parseArrayDeclarator((yyval.interm).type, (yyvsp[-5].interm).intermAggregate, (yylsp[-3]), *(yyvsp[-3].lex).string, (yylsp[-2]), (yyvsp[-1].interm.intermTypedNode)); } break; case 115: { ES3_ONLY("[]", (yylsp[-4]), "implicitly sized array"); (yyval.interm) = (yyvsp[-6].interm); (yyval.interm).intermAggregate = context->parseArrayInitDeclarator((yyval.interm).type, (yyvsp[-6].interm).intermAggregate, (yylsp[-4]), *(yyvsp[-4].lex).string, (yylsp[-3]), nullptr, (yylsp[-1]), (yyvsp[0].interm.intermTypedNode)); } break; case 116: { ES3_ONLY("=", (yylsp[-1]), "first-class arrays (array initializer)"); (yyval.interm) = (yyvsp[-7].interm); (yyval.interm).intermAggregate = context->parseArrayInitDeclarator((yyval.interm).type, (yyvsp[-7].interm).intermAggregate, (yylsp[-5]), *(yyvsp[-5].lex).string, (yylsp[-4]), (yyvsp[-3].interm.intermTypedNode), (yylsp[-1]), (yyvsp[0].interm.intermTypedNode)); } break; case 117: { (yyval.interm) = (yyvsp[-4].interm); (yyval.interm).intermAggregate = context->parseInitDeclarator((yyval.interm).type, (yyvsp[-4].interm).intermAggregate, (yylsp[-2]), *(yyvsp[-2].lex).string, (yylsp[-1]), (yyvsp[0].interm.intermTypedNode)); } break; case 118: { (yyval.interm).type = (yyvsp[0].interm.type); (yyval.interm).intermAggregate = context->parseSingleDeclaration((yyval.interm).type, (yylsp[0]), ""); } break; case 119: { (yyval.interm).type = (yyvsp[-1].interm.type); (yyval.interm).intermAggregate = context->parseSingleDeclaration((yyval.interm).type, (yylsp[0]), *(yyvsp[0].lex).string); } break; case 120: { (yyval.interm).type = (yyvsp[-4].interm.type); (yyval.interm).intermAggregate = context->parseSingleArrayDeclaration((yyval.interm).type, (yylsp[-3]), *(yyvsp[-3].lex).string, (yylsp[-2]), (yyvsp[-1].interm.intermTypedNode)); } break; case 121: { ES3_ONLY("[]", (yylsp[-3]), "implicitly sized array"); (yyval.interm).type = (yyvsp[-5].interm.type); (yyval.interm).intermAggregate = context->parseSingleArrayInitDeclaration((yyval.interm).type, (yylsp[-4]), *(yyvsp[-4].lex).string, (yylsp[-3]), nullptr, (yylsp[-1]), (yyvsp[0].interm.intermTypedNode)); } break; case 122: { ES3_ONLY("=", (yylsp[-1]), "first-class arrays (array initializer)"); (yyval.interm).type = (yyvsp[-6].interm.type); (yyval.interm).intermAggregate = context->parseSingleArrayInitDeclaration((yyval.interm).type, (yylsp[-5]), *(yyvsp[-5].lex).string, (yylsp[-4]), (yyvsp[-3].interm.intermTypedNode), (yylsp[-1]), (yyvsp[0].interm.intermTypedNode)); } break; case 123: { (yyval.interm).type = (yyvsp[-3].interm.type); (yyval.interm).intermAggregate = context->parseSingleInitDeclaration((yyval.interm).type, (yylsp[-2]), *(yyvsp[-2].lex).string, (yylsp[-1]), (yyvsp[0].interm.intermTypedNode)); } break; case 124: { // $$.type is not used in invariant declarations. (yyval.interm).intermAggregate = context->parseInvariantDeclaration((yylsp[-1]), (yylsp[0]), (yyvsp[0].lex).string, (yyvsp[0].lex).symbol); } break; case 125: { (yyval.interm.type) = (yyvsp[0].interm.type); if ((yyvsp[0].interm.type).array) { ES3_ONLY("[]", (yylsp[0]), "first-class-array"); if (context->getShaderVersion() != 300) { (yyvsp[0].interm.type).clearArrayness(); } } } break; case 126: { (yyval.interm.type) = context->addFullySpecifiedType((yyvsp[-1].interm.type).qualifier, (yyvsp[-1].interm.type).invariant, (yyvsp[-1].interm.type).layoutQualifier, (yyvsp[0].interm.type)); } break; case 127: { (yyval.interm.type).qualifier = EvqSmooth; } break; case 128: { (yyval.interm.type).qualifier = EvqFlat; } break; case 129: { (yyval.interm.qualifier) = EvqConst; } break; case 130: { VERTEX_ONLY("attribute", (yylsp[0])); ES2_ONLY("attribute", (yylsp[0])); if (context->globalErrorCheck((yylsp[0]), context->symbolTable.atGlobalLevel(), "attribute")) context->recover(); (yyval.interm.type).setBasic(EbtVoid, EvqAttribute, (yylsp[0])); } break; case 131: { ES2_ONLY("varying", (yylsp[0])); if (context->globalErrorCheck((yylsp[0]), context->symbolTable.atGlobalLevel(), "varying")) context->recover(); if (context->getShaderType() == GL_VERTEX_SHADER) (yyval.interm.type).setBasic(EbtVoid, EvqVaryingOut, (yylsp[0])); else (yyval.interm.type).setBasic(EbtVoid, EvqVaryingIn, (yylsp[0])); } break; case 132: { ES2_ONLY("varying", (yylsp[-1])); if (context->globalErrorCheck((yylsp[-1]), context->symbolTable.atGlobalLevel(), "invariant varying")) context->recover(); if (context->getShaderType() == GL_VERTEX_SHADER) (yyval.interm.type).setBasic(EbtVoid, EvqVaryingOut, (yylsp[-1])); else (yyval.interm.type).setBasic(EbtVoid, EvqVaryingIn, (yylsp[-1])); (yyval.interm.type).invariant = true; } break; case 133: { if ((yyvsp[0].interm.type).qualifier != EvqConst && !context->symbolTable.atGlobalLevel()) { context->error((yylsp[0]), "Local variables can only use the const storage qualifier.", getQualifierString((yyvsp[0].interm.type).qualifier)); context->recover(); } else { (yyval.interm.type).setBasic(EbtVoid, (yyvsp[0].interm.type).qualifier, (yylsp[0])); } } break; case 134: { (yyval.interm.type) = context->joinInterpolationQualifiers((yylsp[-1]), (yyvsp[-1].interm.type).qualifier, (yylsp[0]), (yyvsp[0].interm.type).qualifier); } break; case 135: { context->error((yylsp[0]), "interpolation qualifier requires a fragment 'in' or vertex 'out' storage qualifier", getInterpolationString((yyvsp[0].interm.type).qualifier)); context->recover(); TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtVoid, qual, (yylsp[0])); } break; case 136: { (yyval.interm.type).qualifier = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).layoutQualifier = (yyvsp[0].interm.layoutQualifier); } break; case 137: { (yyval.interm.type).setBasic(EbtVoid, (yyvsp[0].interm.type).qualifier, (yylsp[0])); (yyval.interm.type).layoutQualifier = (yyvsp[-1].interm.layoutQualifier); } break; case 138: { context->es3InvariantErrorCheck((yyvsp[0].interm.type).qualifier, (yylsp[-1])); (yyval.interm.type).setBasic(EbtVoid, (yyvsp[0].interm.type).qualifier, (yylsp[0])); (yyval.interm.type).invariant = true; } break; case 139: { context->es3InvariantErrorCheck((yyvsp[0].interm.type).qualifier, (yylsp[-2])); (yyval.interm.type) = context->joinInterpolationQualifiers((yylsp[-1]), (yyvsp[-1].interm.type).qualifier, (yylsp[0]), (yyvsp[0].interm.type).qualifier); (yyval.interm.type).invariant = true; } break; case 140: { (yyval.interm.type).qualifier = EvqConst; } break; case 141: { ES3_ONLY("in", (yylsp[0]), "storage qualifier"); (yyval.interm.type).qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentIn : EvqVertexIn; } break; case 142: { ES3_ONLY("out", (yylsp[0]), "storage qualifier"); (yyval.interm.type).qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqVertexOut; } break; case 143: { ES3_ONLY("centroid in", (yylsp[-1]), "storage qualifier"); if (context->getShaderType() == GL_VERTEX_SHADER) { context->error((yylsp[-1]), "invalid storage qualifier", "it is an error to use 'centroid in' in the vertex shader"); context->recover(); } (yyval.interm.type).qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqCentroidIn : EvqVertexIn; } break; case 144: { ES3_ONLY("centroid out", (yylsp[-1]), "storage qualifier"); if (context->getShaderType() == GL_FRAGMENT_SHADER) { context->error((yylsp[-1]), "invalid storage qualifier", "it is an error to use 'centroid out' in the fragment shader"); context->recover(); } (yyval.interm.type).qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqCentroidOut; } break; case 145: { if (context->globalErrorCheck((yylsp[0]), context->symbolTable.atGlobalLevel(), "uniform")) context->recover(); (yyval.interm.type).qualifier = EvqUniform; } break; case 146: { (yyval.interm.type) = (yyvsp[0].interm.type); if ((yyval.interm.type).precision == EbpUndefined) { (yyval.interm.type).precision = context->symbolTable.getDefaultPrecision((yyvsp[0].interm.type).type); if (context->precisionErrorCheck((yylsp[0]), (yyval.interm.type).precision, (yyvsp[0].interm.type).type)) { context->recover(); } } } break; case 147: { (yyval.interm.type) = (yyvsp[0].interm.type); (yyval.interm.type).precision = (yyvsp[-1].interm.precision); if (!SupportsPrecision((yyvsp[0].interm.type).type)) { context->error((yylsp[-1]), "illegal type for precision qualifier", getBasicString((yyvsp[0].interm.type).type)); context->recover(); } } break; case 148: { (yyval.interm.precision) = EbpHigh; } break; case 149: { (yyval.interm.precision) = EbpMedium; } break; case 150: { (yyval.interm.precision) = EbpLow; } break; case 151: { ES3_ONLY("layout", (yylsp[-3]), "qualifier"); (yyval.interm.layoutQualifier) = (yyvsp[-1].interm.layoutQualifier); } break; case 152: { (yyval.interm.layoutQualifier) = (yyvsp[0].interm.layoutQualifier); } break; case 153: { (yyval.interm.layoutQualifier) = context->joinLayoutQualifiers((yyvsp[-2].interm.layoutQualifier), (yyvsp[0].interm.layoutQualifier)); } break; case 154: { (yyval.interm.layoutQualifier) = context->parseLayoutQualifier(*(yyvsp[0].lex).string, (yylsp[0])); } break; case 155: { (yyval.interm.layoutQualifier) = context->parseLayoutQualifier(*(yyvsp[-2].lex).string, (yylsp[-2]), *(yyvsp[0].lex).string, (yyvsp[0].lex).i, (yylsp[0])); } break; case 156: { (yyval.interm.layoutQualifier) = context->parseLayoutQualifier(*(yyvsp[-2].lex).string, (yylsp[-2]), *(yyvsp[0].lex).string, (yyvsp[0].lex).i, (yylsp[0])); } break; case 157: { (yyval.interm.type) = (yyvsp[0].interm.type); } break; case 158: { ES3_ONLY("[]", (yylsp[-1]), "implicitly sized array"); (yyval.interm.type) = (yyvsp[-2].interm.type); (yyval.interm.type).setArraySize(0); } break; case 159: { (yyval.interm.type) = (yyvsp[-3].interm.type); if (context->arrayTypeErrorCheck((yylsp[-2]), (yyvsp[-3].interm.type))) context->recover(); else { int size; if (context->arraySizeErrorCheck((yylsp[-2]), (yyvsp[-1].interm.intermTypedNode), size)) context->recover(); (yyval.interm.type).setArraySize(size); } } break; case 160: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtVoid, qual, (yylsp[0])); } break; case 161: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[0])); } break; case 162: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtInt, qual, (yylsp[0])); } break; case 163: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtUInt, qual, (yylsp[0])); } break; case 164: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtBool, qual, (yylsp[0])); } break; case 165: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[0])); (yyval.interm.type).setAggregate(2); } break; case 166: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[0])); (yyval.interm.type).setAggregate(3); } break; case 167: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[0])); (yyval.interm.type).setAggregate(4); } break; case 168: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtBool, qual, (yylsp[0])); (yyval.interm.type).setAggregate(2); } break; case 169: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtBool, qual, (yylsp[0])); (yyval.interm.type).setAggregate(3); } break; case 170: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtBool, qual, (yylsp[0])); (yyval.interm.type).setAggregate(4); } break; case 171: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtInt, qual, (yylsp[0])); (yyval.interm.type).setAggregate(2); } break; case 172: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtInt, qual, (yylsp[0])); (yyval.interm.type).setAggregate(3); } break; case 173: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtInt, qual, (yylsp[0])); (yyval.interm.type).setAggregate(4); } break; case 174: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtUInt, qual, (yylsp[0])); (yyval.interm.type).setAggregate(2); } break; case 175: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtUInt, qual, (yylsp[0])); (yyval.interm.type).setAggregate(3); } break; case 176: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtUInt, qual, (yylsp[0])); (yyval.interm.type).setAggregate(4); } break; case 177: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[0])); (yyval.interm.type).setMatrix(2, 2); } break; case 178: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[0])); (yyval.interm.type).setMatrix(3, 3); } break; case 179: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[0])); (yyval.interm.type).setMatrix(4, 4); } break; case 180: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[0])); (yyval.interm.type).setMatrix(2, 3); } break; case 181: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[0])); (yyval.interm.type).setMatrix(3, 2); } break; case 182: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[0])); (yyval.interm.type).setMatrix(2, 4); } break; case 183: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[0])); (yyval.interm.type).setMatrix(4, 2); } break; case 184: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[0])); (yyval.interm.type).setMatrix(3, 4); } break; case 185: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[0])); (yyval.interm.type).setMatrix(4, 3); } break; case 186: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtSampler2D, qual, (yylsp[0])); } break; case 187: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtSampler3D, qual, (yylsp[0])); } break; case 188: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtSamplerCube, qual, (yylsp[0])); } break; case 189: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtSampler2DArray, qual, (yylsp[0])); } break; case 190: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtISampler2D, qual, (yylsp[0])); } break; case 191: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtISampler3D, qual, (yylsp[0])); } break; case 192: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtISamplerCube, qual, (yylsp[0])); } break; case 193: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtISampler2DArray, qual, (yylsp[0])); } break; case 194: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtUSampler2D, qual, (yylsp[0])); } break; case 195: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtUSampler3D, qual, (yylsp[0])); } break; case 196: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtUSamplerCube, qual, (yylsp[0])); } break; case 197: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtUSampler2DArray, qual, (yylsp[0])); } break; case 198: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtSampler2DShadow, qual, (yylsp[0])); } break; case 199: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtSamplerCubeShadow, qual, (yylsp[0])); } break; case 200: { TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtSampler2DArrayShadow, qual, (yylsp[0])); } break; case 201: { if (!context->supportsExtension("GL_OES_EGL_image_external")) { context->error((yylsp[0]), "unsupported type", "samplerExternalOES"); context->recover(); } TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtSamplerExternalOES, qual, (yylsp[0])); } break; case 202: { if (!context->supportsExtension("GL_ARB_texture_rectangle")) { context->error((yylsp[0]), "unsupported type", "sampler2DRect"); context->recover(); } TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtSampler2DRect, qual, (yylsp[0])); } break; case 203: { (yyval.interm.type) = (yyvsp[0].interm.type); (yyval.interm.type).qualifier = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; } break; case 204: { // // This is for user defined type names. The lexical phase looked up the // type. // TType& structure = static_cast((yyvsp[0].lex).symbol)->getType(); TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; (yyval.interm.type).setBasic(EbtStruct, qual, (yylsp[0])); (yyval.interm.type).userDef = &structure; } break; case 205: { if (context->enterStructDeclaration((yylsp[-1]), *(yyvsp[-1].lex).string)) context->recover(); } break; case 206: { (yyval.interm.type) = context->addStructure((yylsp[-5]), (yylsp[-4]), (yyvsp[-4].lex).string, (yyvsp[-1].interm.fieldList)); } break; case 207: { if (context->enterStructDeclaration((yylsp[0]), *(yyvsp[0].lex).string)) context->recover(); } break; case 208: { (yyval.interm.type) = context->addStructure((yylsp[-4]), (yyloc), NewPoolTString(""), (yyvsp[-1].interm.fieldList)); } break; case 209: { (yyval.interm.fieldList) = (yyvsp[0].interm.fieldList); } break; case 210: { (yyval.interm.fieldList) = (yyvsp[-1].interm.fieldList); for (size_t i = 0; i < (yyvsp[0].interm.fieldList)->size(); ++i) { TField* field = (*(yyvsp[0].interm.fieldList))[i]; for (size_t j = 0; j < (yyval.interm.fieldList)->size(); ++j) { if ((*(yyval.interm.fieldList))[j]->name() == field->name()) { context->error((yylsp[0]), "duplicate field name in structure:", "struct", field->name().c_str()); context->recover(); } } (yyval.interm.fieldList)->push_back(field); } } break; case 211: { (yyval.interm.fieldList) = context->addStructDeclaratorList((yyvsp[-2].interm.type), (yyvsp[-1].interm.fieldList)); } break; case 212: { // ES3 Only, but errors should be handled elsewhere (yyvsp[-2].interm.type).qualifier = (yyvsp[-3].interm.type).qualifier; (yyvsp[-2].interm.type).layoutQualifier = (yyvsp[-3].interm.type).layoutQualifier; (yyval.interm.fieldList) = context->addStructDeclaratorList((yyvsp[-2].interm.type), (yyvsp[-1].interm.fieldList)); } break; case 213: { (yyval.interm.fieldList) = NewPoolTFieldList(); (yyval.interm.fieldList)->push_back((yyvsp[0].interm.field)); } break; case 214: { (yyval.interm.fieldList)->push_back((yyvsp[0].interm.field)); } break; case 215: { if (context->reservedErrorCheck((yylsp[0]), *(yyvsp[0].lex).string)) context->recover(); TType* type = new TType(EbtVoid, EbpUndefined); (yyval.interm.field) = new TField(type, (yyvsp[0].lex).string, (yylsp[0])); } break; case 216: { if (context->reservedErrorCheck((yylsp[-3]), *(yyvsp[-3].lex).string)) context->recover(); TType* type = new TType(EbtVoid, EbpUndefined); int size; if (context->arraySizeErrorCheck((yylsp[-1]), (yyvsp[-1].interm.intermTypedNode), size)) context->recover(); type->setArraySize(size); (yyval.interm.field) = new TField(type, (yyvsp[-3].lex).string, (yylsp[-3])); } break; case 217: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 218: { (yyval.interm.intermNode) = (yyvsp[0].interm.intermNode); } break; case 219: { (yyval.interm.intermNode) = (yyvsp[0].interm.intermAggregate); } break; case 220: { (yyval.interm.intermNode) = (yyvsp[0].interm.intermNode); } break; case 221: { (yyval.interm.intermNode) = (yyvsp[0].interm.intermNode); } break; case 222: { (yyval.interm.intermNode) = (yyvsp[0].interm.intermNode); } break; case 223: { (yyval.interm.intermNode) = (yyvsp[0].interm.intermNode); } break; case 224: { (yyval.interm.intermNode) = (yyvsp[0].interm.intermSwitch); } break; case 225: { (yyval.interm.intermNode) = (yyvsp[0].interm.intermCase); } break; case 226: { (yyval.interm.intermNode) = (yyvsp[0].interm.intermNode); } break; case 227: { (yyval.interm.intermNode) = (yyvsp[0].interm.intermNode); } break; case 228: { (yyval.interm.intermAggregate) = 0; } break; case 229: { context->symbolTable.push(); } break; case 230: { context->symbolTable.pop(); } break; case 231: { if ((yyvsp[-2].interm.intermAggregate) != 0) { (yyvsp[-2].interm.intermAggregate)->setOp(EOpSequence); (yyvsp[-2].interm.intermAggregate)->setLine((yyloc)); } (yyval.interm.intermAggregate) = (yyvsp[-2].interm.intermAggregate); } break; case 232: { (yyval.interm.intermNode) = (yyvsp[0].interm.intermNode); } break; case 233: { (yyval.interm.intermNode) = (yyvsp[0].interm.intermNode); } break; case 234: { context->symbolTable.push(); } break; case 235: { context->symbolTable.pop(); (yyval.interm.intermNode) = (yyvsp[0].interm.intermNode); } break; case 236: { context->symbolTable.push(); } break; case 237: { context->symbolTable.pop(); (yyval.interm.intermNode) = (yyvsp[0].interm.intermNode); } break; case 238: { (yyval.interm.intermNode) = 0; } break; case 239: { if ((yyvsp[-1].interm.intermAggregate)) { (yyvsp[-1].interm.intermAggregate)->setOp(EOpSequence); (yyvsp[-1].interm.intermAggregate)->setLine((yyloc)); } (yyval.interm.intermNode) = (yyvsp[-1].interm.intermAggregate); } break; case 240: { (yyval.interm.intermAggregate) = context->intermediate.makeAggregate((yyvsp[0].interm.intermNode), (yyloc)); } break; case 241: { (yyval.interm.intermAggregate) = context->intermediate.growAggregate((yyvsp[-1].interm.intermAggregate), (yyvsp[0].interm.intermNode), (yyloc)); } break; case 242: { (yyval.interm.intermNode) = 0; } break; case 243: { (yyval.interm.intermNode) = static_cast((yyvsp[-1].interm.intermTypedNode)); } break; case 244: { if (context->boolErrorCheck((yylsp[-4]), (yyvsp[-2].interm.intermTypedNode))) context->recover(); (yyval.interm.intermNode) = context->intermediate.addSelection((yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.nodePair), (yylsp[-4])); } break; case 245: { (yyval.interm.nodePair).node1 = (yyvsp[-2].interm.intermNode); (yyval.interm.nodePair).node2 = (yyvsp[0].interm.intermNode); } break; case 246: { (yyval.interm.nodePair).node1 = (yyvsp[0].interm.intermNode); (yyval.interm.nodePair).node2 = 0; } break; case 247: { context->incrSwitchNestingLevel(); } break; case 248: { (yyval.interm.intermSwitch) = context->addSwitch((yyvsp[-3].interm.intermTypedNode), (yyvsp[0].interm.intermAggregate), (yylsp[-5])); context->decrSwitchNestingLevel(); } break; case 249: { (yyval.interm.intermCase) = context->addCase((yyvsp[-1].interm.intermTypedNode), (yylsp[-2])); } break; case 250: { (yyval.interm.intermCase) = context->addDefault((yylsp[-1])); } break; case 251: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); if (context->boolErrorCheck((yyvsp[0].interm.intermTypedNode)->getLine(), (yyvsp[0].interm.intermTypedNode))) context->recover(); } break; case 252: { TIntermNode *intermNode; if (context->boolErrorCheck((yylsp[-2]), (yyvsp[-3].interm.type))) context->recover(); if (!context->executeInitializer((yylsp[-2]), *(yyvsp[-2].lex).string, (yyvsp[-3].interm.type), (yyvsp[0].interm.intermTypedNode), &intermNode)) (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); else { context->recover(); (yyval.interm.intermTypedNode) = 0; } } break; case 253: { context->symbolTable.push(); context->incrLoopNestingLevel(); } break; case 254: { context->symbolTable.pop(); (yyval.interm.intermNode) = context->intermediate.addLoop(ELoopWhile, 0, (yyvsp[-2].interm.intermTypedNode), 0, (yyvsp[0].interm.intermNode), (yylsp[-5])); context->decrLoopNestingLevel(); } break; case 255: { context->incrLoopNestingLevel(); } break; case 256: { if (context->boolErrorCheck((yylsp[0]), (yyvsp[-2].interm.intermTypedNode))) context->recover(); (yyval.interm.intermNode) = context->intermediate.addLoop(ELoopDoWhile, 0, (yyvsp[-2].interm.intermTypedNode), 0, (yyvsp[-5].interm.intermNode), (yylsp[-4])); context->decrLoopNestingLevel(); } break; case 257: { context->symbolTable.push(); context->incrLoopNestingLevel(); } break; case 258: { context->symbolTable.pop(); (yyval.interm.intermNode) = context->intermediate.addLoop(ELoopFor, (yyvsp[-3].interm.intermNode), reinterpret_cast((yyvsp[-2].interm.nodePair).node1), reinterpret_cast((yyvsp[-2].interm.nodePair).node2), (yyvsp[0].interm.intermNode), (yylsp[-6])); context->decrLoopNestingLevel(); } break; case 259: { (yyval.interm.intermNode) = (yyvsp[0].interm.intermNode); } break; case 260: { (yyval.interm.intermNode) = (yyvsp[0].interm.intermNode); } break; case 261: { (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode); } break; case 262: { (yyval.interm.intermTypedNode) = 0; } break; case 263: { (yyval.interm.nodePair).node1 = (yyvsp[-1].interm.intermTypedNode); (yyval.interm.nodePair).node2 = 0; } break; case 264: { (yyval.interm.nodePair).node1 = (yyvsp[-2].interm.intermTypedNode); (yyval.interm.nodePair).node2 = (yyvsp[0].interm.intermTypedNode); } break; case 265: { (yyval.interm.intermNode) = context->addBranch(EOpContinue, (yylsp[-1])); } break; case 266: { (yyval.interm.intermNode) = context->addBranch(EOpBreak, (yylsp[-1])); } break; case 267: { (yyval.interm.intermNode) = context->addBranch(EOpReturn, (yylsp[-1])); } break; case 268: { (yyval.interm.intermNode) = context->addBranch(EOpReturn, (yyvsp[-1].interm.intermTypedNode), (yylsp[-2])); } break; case 269: { FRAG_ONLY("discard", (yylsp[-1])); (yyval.interm.intermNode) = context->addBranch(EOpKill, (yylsp[-1])); } break; case 270: { (yyval.interm.intermNode) = (yyvsp[0].interm.intermNode); context->setTreeRoot((yyval.interm.intermNode)); } break; case 271: { (yyval.interm.intermNode) = context->intermediate.growAggregate((yyvsp[-1].interm.intermNode), (yyvsp[0].interm.intermNode), (yyloc)); context->setTreeRoot((yyval.interm.intermNode)); } break; case 272: { (yyval.interm.intermNode) = (yyvsp[0].interm.intermNode); } break; case 273: { (yyval.interm.intermNode) = (yyvsp[0].interm.intermNode); } break; case 274: { context->parseFunctionPrototype((yylsp[0]), (yyvsp[0].interm).function, &(yyvsp[0].interm).intermAggregate); } break; case 275: { //?? Check that all paths return a value if return type != void ? // May be best done as post process phase on intermediate code if (context->getCurrentFunctionType()->getBasicType() != EbtVoid && !context->getFunctionReturnsValue()) { context->error((yylsp[-2]), "function does not return a value:", "", (yyvsp[-2].interm).function->getName().c_str()); context->recover(); } (yyval.interm.intermNode) = context->intermediate.growAggregate((yyvsp[-2].interm).intermAggregate, (yyvsp[0].interm.intermNode), (yyloc)); context->intermediate.setAggregateOperator((yyval.interm.intermNode), EOpFunction, (yylsp[-2])); (yyval.interm.intermNode)->getAsAggregate()->setName((yyvsp[-2].interm).function->getMangledName().c_str()); (yyval.interm.intermNode)->getAsAggregate()->setType((yyvsp[-2].interm).function->getReturnType()); (yyval.interm.intermNode)->getAsAggregate()->setFunctionId((yyvsp[-2].interm).function->getUniqueId()); // store the pragma information for debug and optimize and other vendor specific // information. This information can be queried from the parse tree (yyval.interm.intermNode)->getAsAggregate()->setOptimize(context->pragma().optimize); (yyval.interm.intermNode)->getAsAggregate()->setDebug(context->pragma().debug); context->symbolTable.pop(); } break; default: break; } /* User semantic actions sometimes alter yychar, and that requires that yytoken be updated with the new translation. We take the approach of translating immediately before every use of yytoken. One alternative is translating here after every semantic action, but that translation would be missed if the semantic action invokes YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an incorrect destructor might then be invoked immediately. In the case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; *++yylsp = yyloc; /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*--------------------------------------. | yyerrlab -- here on detecting error. | `--------------------------------------*/ yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (&yylloc, context, scanner, YY_("syntax error")); #else # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ yyssp, yytoken) { char const *yymsgp = YY_("syntax error"); int yysyntax_error_status; yysyntax_error_status = YYSYNTAX_ERROR; if (yysyntax_error_status == 0) yymsgp = yymsg; else if (yysyntax_error_status == 1) { if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); if (!yymsg) { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; yysyntax_error_status = 2; } else { yysyntax_error_status = YYSYNTAX_ERROR; yymsgp = yymsg; } } yyerror (&yylloc, context, scanner, yymsgp); if (yysyntax_error_status == 2) goto yyexhaustedlab; } # undef YYSYNTAX_ERROR #endif } yyerror_range[1] = yylloc; if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval, &yylloc, context, scanner); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) goto yyerrorlab; yyerror_range[1] = yylsp[1-yylen]; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yyerror_range[1] = *yylsp; yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp, context, scanner); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END yyerror_range[2] = yylloc; /* Using YYLLOC is tempting, but would change the location of the lookahead. YYLOC is available though. */ YYLLOC_DEFAULT (yyloc, yyerror_range, 2); *++yylsp = yyloc; /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (&yylloc, context, scanner, YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEMPTY) { /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = YYTRANSLATE (yychar); yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc, context, scanner); } /* Do not reclaim the symbols of the rule whose action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp, yylsp, context, scanner); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif return yyresult; } int glslang_parse(TParseContext* context) { return yyparse(context, context->getScanner()); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/glslang_tab.h000066400000000000000000000132611321746453100273550ustar00rootroot00000000000000/* A Bison parser, made by GNU Bison 3.0.4. */ /* Bison interface for Yacc-like parsers in C Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. 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 . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ #ifndef YY_YY_GLSLANG_TAB_H_INCLUDED # define YY_YY_GLSLANG_TAB_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif #if YYDEBUG extern int yydebug; #endif /* "%code requires" blocks. */ #define YYLTYPE TSourceLoc #define YYLTYPE_IS_DECLARED 1 /* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { INVARIANT = 258, HIGH_PRECISION = 259, MEDIUM_PRECISION = 260, LOW_PRECISION = 261, PRECISION = 262, ATTRIBUTE = 263, CONST_QUAL = 264, BOOL_TYPE = 265, FLOAT_TYPE = 266, INT_TYPE = 267, UINT_TYPE = 268, BREAK = 269, CONTINUE = 270, DO = 271, ELSE = 272, FOR = 273, IF = 274, DISCARD = 275, RETURN = 276, SWITCH = 277, CASE = 278, DEFAULT = 279, BVEC2 = 280, BVEC3 = 281, BVEC4 = 282, IVEC2 = 283, IVEC3 = 284, IVEC4 = 285, VEC2 = 286, VEC3 = 287, VEC4 = 288, UVEC2 = 289, UVEC3 = 290, UVEC4 = 291, MATRIX2 = 292, MATRIX3 = 293, MATRIX4 = 294, IN_QUAL = 295, OUT_QUAL = 296, INOUT_QUAL = 297, UNIFORM = 298, VARYING = 299, MATRIX2x3 = 300, MATRIX3x2 = 301, MATRIX2x4 = 302, MATRIX4x2 = 303, MATRIX3x4 = 304, MATRIX4x3 = 305, CENTROID = 306, FLAT = 307, SMOOTH = 308, STRUCT = 309, VOID_TYPE = 310, WHILE = 311, SAMPLER2D = 312, SAMPLERCUBE = 313, SAMPLER_EXTERNAL_OES = 314, SAMPLER2DRECT = 315, SAMPLER2DARRAY = 316, ISAMPLER2D = 317, ISAMPLER3D = 318, ISAMPLERCUBE = 319, ISAMPLER2DARRAY = 320, USAMPLER2D = 321, USAMPLER3D = 322, USAMPLERCUBE = 323, USAMPLER2DARRAY = 324, SAMPLER3D = 325, SAMPLER3DRECT = 326, SAMPLER2DSHADOW = 327, SAMPLERCUBESHADOW = 328, SAMPLER2DARRAYSHADOW = 329, LAYOUT = 330, IDENTIFIER = 331, TYPE_NAME = 332, FLOATCONSTANT = 333, INTCONSTANT = 334, UINTCONSTANT = 335, BOOLCONSTANT = 336, FIELD_SELECTION = 337, LEFT_OP = 338, RIGHT_OP = 339, INC_OP = 340, DEC_OP = 341, LE_OP = 342, GE_OP = 343, EQ_OP = 344, NE_OP = 345, AND_OP = 346, OR_OP = 347, XOR_OP = 348, MUL_ASSIGN = 349, DIV_ASSIGN = 350, ADD_ASSIGN = 351, MOD_ASSIGN = 352, LEFT_ASSIGN = 353, RIGHT_ASSIGN = 354, AND_ASSIGN = 355, XOR_ASSIGN = 356, OR_ASSIGN = 357, SUB_ASSIGN = 358, LEFT_PAREN = 359, RIGHT_PAREN = 360, LEFT_BRACKET = 361, RIGHT_BRACKET = 362, LEFT_BRACE = 363, RIGHT_BRACE = 364, DOT = 365, COMMA = 366, COLON = 367, EQUAL = 368, SEMICOLON = 369, BANG = 370, DASH = 371, TILDE = 372, PLUS = 373, STAR = 374, SLASH = 375, PERCENT = 376, LEFT_ANGLE = 377, RIGHT_ANGLE = 378, VERTICAL_BAR = 379, CARET = 380, AMPERSAND = 381, QUESTION = 382 }; #endif /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { struct { union { TString *string; float f; int i; unsigned int u; bool b; }; TSymbol* symbol; } lex; struct { TOperator op; union { TIntermNode* intermNode; TIntermNodePair nodePair; TIntermTyped* intermTypedNode; TIntermAggregate* intermAggregate; TIntermSwitch* intermSwitch; TIntermCase* intermCase; }; union { TPublicType type; TPrecision precision; TLayoutQualifier layoutQualifier; TQualifier qualifier; TFunction* function; TParameter param; TField* field; TFieldList* fieldList; }; } interm; }; typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 #endif /* Location type. */ #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED typedef struct YYLTYPE YYLTYPE; struct YYLTYPE { int first_line; int first_column; int last_line; int last_column; }; # define YYLTYPE_IS_DECLARED 1 # define YYLTYPE_IS_TRIVIAL 1 #endif int yyparse (TParseContext* context, void *scanner); #endif /* !YY_YY_GLSLANG_TAB_H_INCLUDED */ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/intermOut.cpp000066400000000000000000000015771321746453100274300ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/Intermediate.h" #include "compiler/translator/SymbolTable.h" TString TType::getCompleteString() const { TStringStream stream; if (invariant) stream << "invariant "; if (qualifier != EvqTemporary && qualifier != EvqGlobal) stream << getQualifierString() << " "; if (precision != EbpUndefined) stream << getPrecisionString() << " "; if (array) stream << "array[" << getArraySize() << "] of "; if (isMatrix()) stream << getCols() << "X" << getRows() << " matrix of "; else if (isVector()) stream << getNominalSize() << "-component vector of "; stream << getBasicString(); return stream.str(); } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/length_limits.h000066400000000000000000000010621321746453100277360ustar00rootroot00000000000000// // Copyright (c) 2011-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // // length_limits.h // #ifndef COMPILER_TRANSLATOR_LENGTHLIMITS_H_ #define COMPILER_TRANSLATOR_LENGTHLIMITS_H_ #include "GLSLANG/ShaderLang.h" // These constants are factored out from the rest of the headers to // make it easier to reference them from the compiler sources. size_t GetGlobalMaxTokenSize(ShShaderSpec spec); #endif // COMPILER_TRANSLATOR_LENGTHLIMITS_H_ freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/parseConst.cpp000066400000000000000000000173701321746453100275610ustar00rootroot00000000000000// // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/ParseContext.h" // // Use this class to carry along data from node to node in // the traversal // class TConstTraverser : public TIntermTraverser { public: TConstTraverser(TConstantUnion *cUnion, bool singleConstParam, TOperator constructType, TInfoSink &sink, TType &t) : TIntermTraverser(true, false, false), error(false), mIndex(0), mUnionArray(cUnion), mType(t), mConstructorType(constructType), mSingleConstantParam(singleConstParam), mInfoSink(sink), mSize(0), mIsDiagonalMatrixInit(false), mMatrixCols(0), mMatrixRows(0) { } bool error; protected: void visitSymbol(TIntermSymbol *); void visitConstantUnion(TIntermConstantUnion *); bool visitBinary(Visit visit, TIntermBinary *); bool visitUnary(Visit visit, TIntermUnary *); bool visitSelection(Visit visit, TIntermSelection *); bool visitAggregate(Visit visit, TIntermAggregate *); bool visitLoop(Visit visit, TIntermLoop *); bool visitBranch(Visit visit, TIntermBranch *); size_t mIndex; TConstantUnion *mUnionArray; TType mType; TOperator mConstructorType; bool mSingleConstantParam; TInfoSink &mInfoSink; size_t mSize; // size of the constructor ( 4 for vec4) bool mIsDiagonalMatrixInit; int mMatrixCols; // columns of the matrix int mMatrixRows; // rows of the matrix }; // // The rest of the file are the traversal functions. The last one // is the one that starts the traversal. // // Return true from interior nodes to have the external traversal // continue on to children. If you process children yourself, // return false. // void TConstTraverser::visitSymbol(TIntermSymbol *node) { mInfoSink.info.message(EPrefixInternalError, node->getLine(), "Symbol Node found in constant constructor"); return; } bool TConstTraverser::visitBinary(Visit visit, TIntermBinary *node) { TQualifier qualifier = node->getType().getQualifier(); if (qualifier != EvqConst) { TString buf; buf.append("'constructor' : assigning non-constant to "); buf.append(mType.getCompleteString()); mInfoSink.info.message(EPrefixError, node->getLine(), buf.c_str()); error = true; return false; } mInfoSink.info.message(EPrefixInternalError, node->getLine(), "Binary Node found in constant constructor"); return false; } bool TConstTraverser::visitUnary(Visit visit, TIntermUnary *node) { TString buf; buf.append("'constructor' : assigning non-constant to "); buf.append(mType.getCompleteString()); mInfoSink.info.message(EPrefixError, node->getLine(), buf.c_str()); error = true; return false; } bool TConstTraverser::visitAggregate(Visit visit, TIntermAggregate *node) { if (!node->isConstructor() && node->getOp() != EOpComma) { TString buf; buf.append("'constructor' : assigning non-constant to "); buf.append(mType.getCompleteString()); mInfoSink.info.message(EPrefixError, node->getLine(), buf.c_str()); error = true; return false; } if (node->getSequence()->size() == 0) { error = true; return false; } bool flag = node->getSequence()->size() == 1 && (*node->getSequence())[0]->getAsTyped()->getAsConstantUnion(); if (flag) { mSingleConstantParam = true; mConstructorType = node->getOp(); mSize = node->getType().getObjectSize(); if (node->getType().isMatrix()) { mIsDiagonalMatrixInit = true; mMatrixCols = node->getType().getCols(); mMatrixRows = node->getType().getRows(); } } for (TIntermSequence::iterator p = node->getSequence()->begin(); p != node->getSequence()->end(); p++) { if (node->getOp() == EOpComma) mIndex = 0; (*p)->traverse(this); } if (flag) { mSingleConstantParam = false; mConstructorType = EOpNull; mSize = 0; mIsDiagonalMatrixInit = false; mMatrixCols = 0; mMatrixRows = 0; } return false; } bool TConstTraverser::visitSelection(Visit visit, TIntermSelection *node) { mInfoSink.info.message(EPrefixInternalError, node->getLine(), "Selection Node found in constant constructor"); error = true; return false; } void TConstTraverser::visitConstantUnion(TIntermConstantUnion *node) { if (!node->getUnionArrayPointer()) { // The constant was not initialized, this should already have been logged ASSERT(mInfoSink.info.size() != 0); return; } TConstantUnion *leftUnionArray = mUnionArray; size_t instanceSize = mType.getObjectSize(); TBasicType basicType = mType.getBasicType(); if (mIndex >= instanceSize) return; if (!mSingleConstantParam) { size_t objectSize = node->getType().getObjectSize(); const TConstantUnion *rightUnionArray = node->getUnionArrayPointer(); for (size_t i=0; i < objectSize; i++) { if (mIndex >= instanceSize) return; leftUnionArray[mIndex].cast(basicType, rightUnionArray[i]); mIndex++; } } else { size_t totalSize = mIndex + mSize; const TConstantUnion *rightUnionArray = node->getUnionArrayPointer(); if (!mIsDiagonalMatrixInit) { int count = 0; for (size_t i = mIndex; i < totalSize; i++) { if (i >= instanceSize) return; leftUnionArray[i].cast(basicType, rightUnionArray[count]); mIndex++; if (node->getType().getObjectSize() > 1) count++; } } else { // for matrix diagonal constructors from a single scalar for (int i = 0, col = 0; col < mMatrixCols; col++) { for (int row = 0; row < mMatrixRows; row++, i++) { if (col == row) { leftUnionArray[i].cast(basicType, rightUnionArray[0]); } else { leftUnionArray[i].setFConst(0.0f); } mIndex++; } } } } } bool TConstTraverser::visitLoop(Visit visit, TIntermLoop *node) { mInfoSink.info.message(EPrefixInternalError, node->getLine(), "Loop Node found in constant constructor"); error = true; return false; } bool TConstTraverser::visitBranch(Visit visit, TIntermBranch *node) { mInfoSink.info.message(EPrefixInternalError, node->getLine(), "Branch Node found in constant constructor"); error = true; return false; } // // This function is the one to call externally to start the traversal. // Individual functions can be initialized to 0 to skip processing of that // type of node. It's children will still be processed. // bool TIntermediate::parseConstTree( const TSourceLoc &line, TIntermNode *root, TConstantUnion *unionArray, TOperator constructorType, TType t, bool singleConstantParam) { if (root == 0) return false; TConstTraverser it(unionArray, singleConstantParam, constructorType, mInfoSink, t); root->traverse(&it); if (it.error) return true; else return false; } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/util.cpp000066400000000000000000000151041321746453100264060ustar00rootroot00000000000000// // Copyright (c) 2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/translator/util.h" #include #include "compiler/preprocessor/numeric_lex.h" #include "compiler/translator/SymbolTable.h" #include "common/utilities.h" bool strtof_clamp(const std::string &str, float *value) { bool success = pp::numeric_lex_float(str, value); if (!success) *value = std::numeric_limits::max(); return success; } bool atoi_clamp(const char *str, int *value) { bool success = pp::numeric_lex_int(str, value); if (!success) *value = std::numeric_limits::max(); return success; } namespace sh { GLenum GLVariableType(const TType &type) { if (type.getBasicType() == EbtFloat) { if (type.isScalar()) { return GL_FLOAT; } else if (type.isVector()) { switch (type.getNominalSize()) { case 2: return GL_FLOAT_VEC2; case 3: return GL_FLOAT_VEC3; case 4: return GL_FLOAT_VEC4; default: UNREACHABLE(); } } else if (type.isMatrix()) { switch (type.getCols()) { case 2: switch (type.getRows()) { case 2: return GL_FLOAT_MAT2; case 3: return GL_FLOAT_MAT2x3; case 4: return GL_FLOAT_MAT2x4; default: UNREACHABLE(); } case 3: switch (type.getRows()) { case 2: return GL_FLOAT_MAT3x2; case 3: return GL_FLOAT_MAT3; case 4: return GL_FLOAT_MAT3x4; default: UNREACHABLE(); } case 4: switch (type.getRows()) { case 2: return GL_FLOAT_MAT4x2; case 3: return GL_FLOAT_MAT4x3; case 4: return GL_FLOAT_MAT4; default: UNREACHABLE(); } default: UNREACHABLE(); } } else UNREACHABLE(); } else if (type.getBasicType() == EbtInt) { if (type.isScalar()) { return GL_INT; } else if (type.isVector()) { switch (type.getNominalSize()) { case 2: return GL_INT_VEC2; case 3: return GL_INT_VEC3; case 4: return GL_INT_VEC4; default: UNREACHABLE(); } } else UNREACHABLE(); } else if (type.getBasicType() == EbtUInt) { if (type.isScalar()) { return GL_UNSIGNED_INT; } else if (type.isVector()) { switch (type.getNominalSize()) { case 2: return GL_UNSIGNED_INT_VEC2; case 3: return GL_UNSIGNED_INT_VEC3; case 4: return GL_UNSIGNED_INT_VEC4; default: UNREACHABLE(); } } else UNREACHABLE(); } else if (type.getBasicType() == EbtBool) { if (type.isScalar()) { return GL_BOOL; } else if (type.isVector()) { switch (type.getNominalSize()) { case 2: return GL_BOOL_VEC2; case 3: return GL_BOOL_VEC3; case 4: return GL_BOOL_VEC4; default: UNREACHABLE(); } } else UNREACHABLE(); } switch (type.getBasicType()) { case EbtSampler2D: return GL_SAMPLER_2D; case EbtSampler3D: return GL_SAMPLER_3D; case EbtSamplerCube: return GL_SAMPLER_CUBE; case EbtSamplerExternalOES: return GL_SAMPLER_EXTERNAL_OES; case EbtSampler2DRect: return GL_SAMPLER_2D_RECT_ARB; case EbtSampler2DArray: return GL_SAMPLER_2D_ARRAY; case EbtISampler2D: return GL_INT_SAMPLER_2D; case EbtISampler3D: return GL_INT_SAMPLER_3D; case EbtISamplerCube: return GL_INT_SAMPLER_CUBE; case EbtISampler2DArray: return GL_INT_SAMPLER_2D_ARRAY; case EbtUSampler2D: return GL_UNSIGNED_INT_SAMPLER_2D; case EbtUSampler3D: return GL_UNSIGNED_INT_SAMPLER_3D; case EbtUSamplerCube: return GL_UNSIGNED_INT_SAMPLER_CUBE; case EbtUSampler2DArray: return GL_UNSIGNED_INT_SAMPLER_2D_ARRAY; case EbtSampler2DShadow: return GL_SAMPLER_2D_SHADOW; case EbtSamplerCubeShadow: return GL_SAMPLER_CUBE_SHADOW; case EbtSampler2DArrayShadow: return GL_SAMPLER_2D_ARRAY_SHADOW; default: UNREACHABLE(); } return GL_NONE; } GLenum GLVariablePrecision(const TType &type) { if (type.getBasicType() == EbtFloat) { switch (type.getPrecision()) { case EbpHigh: return GL_HIGH_FLOAT; case EbpMedium: return GL_MEDIUM_FLOAT; case EbpLow: return GL_LOW_FLOAT; case EbpUndefined: // Should be defined as the default precision by the parser default: UNREACHABLE(); } } else if (type.getBasicType() == EbtInt || type.getBasicType() == EbtUInt) { switch (type.getPrecision()) { case EbpHigh: return GL_HIGH_INT; case EbpMedium: return GL_MEDIUM_INT; case EbpLow: return GL_LOW_INT; case EbpUndefined: // Should be defined as the default precision by the parser default: UNREACHABLE(); } } // Other types (boolean, sampler) don't have a precision return GL_NONE; } TString ArrayString(const TType &type) { if (!type.isArray()) { return ""; } return "[" + str(type.getArraySize()) + "]"; } bool IsVaryingOut(TQualifier qualifier) { switch (qualifier) { case EvqVaryingOut: case EvqSmoothOut: case EvqFlatOut: case EvqCentroidOut: case EvqVertexOut: return true; default: break; } return false; } bool IsVaryingIn(TQualifier qualifier) { switch (qualifier) { case EvqVaryingIn: case EvqSmoothIn: case EvqFlatIn: case EvqCentroidIn: case EvqFragmentIn: return true; default: break; } return false; } bool IsVarying(TQualifier qualifier) { return IsVaryingIn(qualifier) || IsVaryingOut(qualifier); } } freshplayerplugin-0.3.9/3rdparty/angle/src/compiler/translator/util.h000066400000000000000000000021271321746453100260540ustar00rootroot00000000000000// // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef COMPILER_TRANSLATOR_UTIL_H_ #define COMPILER_TRANSLATOR_UTIL_H_ #include #include "angle_gl.h" #include #include "compiler/translator/Types.h" // strtof_clamp is like strtof but // 1. it forces C locale, i.e. forcing '.' as decimal point. // 2. it clamps the value to -FLT_MAX or FLT_MAX if overflow happens. // Return false if overflow happens. bool strtof_clamp(const std::string &str, float *value); // If overflow happens, clamp the value to INT_MIN or INT_MAX. // Return false if overflow happens. bool atoi_clamp(const char *str, int *value); class TSymbolTable; namespace sh { GLenum GLVariableType(const TType &type); GLenum GLVariablePrecision(const TType &type); bool IsVaryingIn(TQualifier qualifier); bool IsVaryingOut(TQualifier qualifier); bool IsVarying(TQualifier qualifier); TString ArrayString(const TType &type); } #endif // COMPILER_TRANSLATOR_UTIL_H_ freshplayerplugin-0.3.9/3rdparty/angle/version-tag000066400000000000000000000000651321746453100223140ustar00rootroot00000000000000from chromium-browser-46.0.2490.71/third_party/angle freshplayerplugin-0.3.9/3rdparty/npapi/000077500000000000000000000000001321746453100201535ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/npapi/npapi.h000066400000000000000000000636771321746453100214560ustar00rootroot00000000000000/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef npapi_h_ #define npapi_h_ #include "nptypes.h" #if defined(_WIN32) && !defined(__SYMBIAN32__) #include #ifndef XP_WIN #define XP_WIN 1 #endif #endif #if defined(__SYMBIAN32__) #ifndef XP_SYMBIAN #define XP_SYMBIAN 1 #undef XP_WIN #endif #endif #if defined(__APPLE_CC__) && !defined(XP_UNIX) #ifndef XP_MACOSX #define XP_MACOSX 1 #endif #endif #if defined(XP_MACOSX) && defined(__LP64__) #define NP_NO_QUICKDRAW #define NP_NO_CARBON #endif #if defined(XP_MACOSX) #include #include #ifndef NP_NO_CARBON #include #endif #endif #if defined(XP_UNIX) #include #if defined(MOZ_X11) #include #include #endif #endif #if defined(XP_SYMBIAN) #include #include #endif /*----------------------------------------------------------------------*/ /* Plugin Version Constants */ /*----------------------------------------------------------------------*/ #define NP_VERSION_MAJOR 0 #define NP_VERSION_MINOR 28 /* The OS/2 version of Netscape uses RC_DATA to define the mime types, file extensions, etc that are required. Use a vertical bar to separate types, end types with \0. FileVersion and ProductVersion are 32bit ints, all other entries are strings that MUST be terminated with a \0. AN EXAMPLE: RCDATA NP_INFO_ProductVersion { 1,0,0,1,} RCDATA NP_INFO_MIMEType { "video/x-video|", "video/x-flick\0" } RCDATA NP_INFO_FileExtents { "avi|", "flc\0" } RCDATA NP_INFO_FileOpenName{ "MMOS2 video player(*.avi)|", "MMOS2 Flc/Fli player(*.flc)\0" } RCDATA NP_INFO_FileVersion { 1,0,0,1 } RCDATA NP_INFO_CompanyName { "Netscape Communications\0" } RCDATA NP_INFO_FileDescription { "NPAVI32 Extension DLL\0" RCDATA NP_INFO_InternalName { "NPAVI32\0" ) RCDATA NP_INFO_LegalCopyright { "Copyright Netscape Communications \251 1996\0" RCDATA NP_INFO_OriginalFilename { "NVAPI32.DLL" } RCDATA NP_INFO_ProductName { "NPAVI32 Dynamic Link Library\0" } */ /* RC_DATA types for version info - required */ #define NP_INFO_ProductVersion 1 #define NP_INFO_MIMEType 2 #define NP_INFO_FileOpenName 3 #define NP_INFO_FileExtents 4 /* RC_DATA types for version info - used if found */ #define NP_INFO_FileDescription 5 #define NP_INFO_ProductName 6 /* RC_DATA types for version info - optional */ #define NP_INFO_CompanyName 7 #define NP_INFO_FileVersion 8 #define NP_INFO_InternalName 9 #define NP_INFO_LegalCopyright 10 #define NP_INFO_OriginalFilename 11 #ifndef RC_INVOKED /*----------------------------------------------------------------------*/ /* Definition of Basic Types */ /*----------------------------------------------------------------------*/ typedef unsigned char NPBool; typedef int16_t NPError; typedef int16_t NPReason; typedef char* NPMIMEType; /*----------------------------------------------------------------------*/ /* Structures and definitions */ /*----------------------------------------------------------------------*/ #if !defined(__LP64__) #if defined(XP_MACOSX) #pragma options align=mac68k #endif #endif /* __LP64__ */ /* * NPP is a plug-in's opaque instance handle */ typedef struct _NPP { void* pdata; /* plug-in private data */ void* ndata; /* netscape private data */ } NPP_t; typedef NPP_t* NPP; typedef struct _NPStream { void* pdata; /* plug-in private data */ void* ndata; /* netscape private data */ const char* url; uint32_t end; uint32_t lastmodified; void* notifyData; const char* headers; /* Response headers from host. * Exists only for >= NPVERS_HAS_RESPONSE_HEADERS. * Used for HTTP only; nullptr for non-HTTP. * Available from NPP_NewStream onwards. * Plugin should copy this data before storing it. * Includes HTTP status line and all headers, * preferably verbatim as received from server, * headers formatted as in HTTP ("Header: Value"), * and newlines (\n, NOT \r\n) separating lines. * Terminated by \n\0 (NOT \n\n\0). */ } NPStream; typedef struct _NPByteRange { int32_t offset; /* negative offset means from the end */ uint32_t length; struct _NPByteRange* next; } NPByteRange; typedef struct _NPSavedData { int32_t len; void* buf; } NPSavedData; typedef struct _NPRect { uint16_t top; uint16_t left; uint16_t bottom; uint16_t right; } NPRect; typedef struct _NPSize { int32_t width; int32_t height; } NPSize; typedef enum { NPFocusNext = 0, NPFocusPrevious = 1 } NPFocusDirection; /* Return values for NPP_HandleEvent */ #define kNPEventNotHandled 0 #define kNPEventHandled 1 /* Exact meaning must be spec'd in event model. */ #define kNPEventStartIME 2 #if defined(XP_UNIX) /* * Unix specific structures and definitions */ /* * Callback Structures. * * These are used to pass additional platform specific information. */ enum { NP_SETWINDOW = 1, NP_PRINT }; typedef struct { int32_t type; } NPAnyCallbackStruct; typedef struct { int32_t type; #if defined(MOZ_X11) Display* display; Visual* visual; Colormap colormap; unsigned int depth; #endif } NPSetWindowCallbackStruct; typedef struct { int32_t type; FILE* fp; } NPPrintCallbackStruct; #endif /* XP_UNIX */ typedef enum { NPDrawingModelDUMMY #if defined(XP_MACOSX) #ifndef NP_NO_QUICKDRAW , NPDrawingModelQuickDraw = 0 #endif , NPDrawingModelCoreGraphics = 1 , NPDrawingModelOpenGL = 2 , NPDrawingModelCoreAnimation = 3 , NPDrawingModelInvalidatingCoreAnimation = 4 #endif #if defined(XP_WIN) , NPDrawingModelSyncWin = 5 #endif #if defined(MOZ_X11) , NPDrawingModelSyncX = 6 #endif #if 0 /* OBSOLETE */ , NPDrawingModelAsyncBitmapSurfaceOBSOLETE = 7 #if defined(XP_WIN) , NPDrawingModelAsyncWindowsDXGISurfaceOBSOLETE = 8 #endif #endif } NPDrawingModel; #ifdef XP_MACOSX typedef enum { #ifndef NP_NO_CARBON NPEventModelCarbon = 0, #endif NPEventModelCocoa = 1 } NPEventModel; #endif /* * The following masks are applied on certain platforms to NPNV and * NPPV selectors that pass around pointers to COM interfaces. Newer * compilers on some platforms may generate vtables that are not * compatible with older compilers. To prevent older plugins from * not understanding a new browser's ABI, these masks change the * values of those selectors on those platforms. To remain backwards * compatible with different versions of the browser, plugins can * use these masks to dynamically determine and use the correct C++ * ABI that the browser is expecting. This does not apply to Windows * as Microsoft's COM ABI will likely not change. */ #define NP_ABI_GCC3_MASK 0x10000000 /* * gcc 3.x generated vtables on UNIX and OSX are incompatible with * previous compilers. */ #if (defined(XP_UNIX) && defined(__GNUC__) && (__GNUC__ >= 3)) #define _NP_ABI_MIXIN_FOR_GCC3 NP_ABI_GCC3_MASK #else #define _NP_ABI_MIXIN_FOR_GCC3 0 #endif #if defined(XP_MACOSX) #define NP_ABI_MACHO_MASK 0x01000000 #define _NP_ABI_MIXIN_FOR_MACHO NP_ABI_MACHO_MASK #else #define _NP_ABI_MIXIN_FOR_MACHO 0 #endif #define NP_ABI_MASK (_NP_ABI_MIXIN_FOR_GCC3 | _NP_ABI_MIXIN_FOR_MACHO) /* * List of variable names for which NPP_GetValue shall be implemented */ typedef enum { NPPVpluginNameString = 1, NPPVpluginDescriptionString, NPPVpluginWindowBool, NPPVpluginTransparentBool, NPPVjavaClass, NPPVpluginWindowSize, NPPVpluginTimerInterval, NPPVpluginScriptableInstance = (10 | NP_ABI_MASK), NPPVpluginScriptableIID = 11, NPPVjavascriptPushCallerBool = 12, NPPVpluginKeepLibraryInMemory = 13, NPPVpluginNeedsXEmbed = 14, /* Get the NPObject for scripting the plugin. Introduced in NPAPI minor version 14. */ NPPVpluginScriptableNPObject = 15, /* Get the plugin value (as \0-terminated UTF-8 string data) for * form submission if the plugin is part of a form. Use * NPN_MemAlloc() to allocate memory for the string data. Introduced * in NPAPI minor version 15. */ NPPVformValue = 16, NPPVpluginUrlRequestsDisplayedBool = 17, /* Checks if the plugin is interested in receiving the http body of * all http requests (including failed ones, http status != 200). */ NPPVpluginWantsAllNetworkStreams = 18, /* Browsers can retrieve a native ATK accessibility plug ID via this variable. */ NPPVpluginNativeAccessibleAtkPlugId = 19, /* Checks to see if the plug-in would like the browser to load the "src" attribute. */ NPPVpluginCancelSrcStream = 20, NPPVsupportsAdvancedKeyHandling = 21, NPPVpluginUsesDOMForCursorBool = 22, /* Used for negotiating drawing models */ NPPVpluginDrawingModel = 1000 #if defined(XP_MACOSX) /* Used for negotiating event models */ , NPPVpluginEventModel = 1001 /* In the NPDrawingModelCoreAnimation drawing model, the browser asks the plug-in for a Core Animation layer. */ , NPPVpluginCoreAnimationLayer = 1003 #endif /* Notification that the plugin just started or stopped playing audio */ , NPPVpluginIsPlayingAudio = 4000 } NPPVariable; /* * List of variable names for which NPN_GetValue should be implemented. */ typedef enum { NPNVxDisplay = 1, NPNVxtAppContext, NPNVnetscapeWindow, NPNVjavascriptEnabledBool, NPNVasdEnabledBool, NPNVisOfflineBool, NPNVserviceManager = (10 | NP_ABI_MASK), NPNVDOMElement = (11 | NP_ABI_MASK), NPNVDOMWindow = (12 | NP_ABI_MASK), NPNVToolkit = (13 | NP_ABI_MASK), NPNVSupportsXEmbedBool = 14, /* Get the NPObject wrapper for the browser window. */ NPNVWindowNPObject = 15, /* Get the NPObject wrapper for the plugins DOM element. */ NPNVPluginElementNPObject = 16, NPNVSupportsWindowless = 17, NPNVprivateModeBool = 18, NPNVsupportsAdvancedKeyHandling = 21, NPNVdocumentOrigin = 22, NPNVpluginDrawingModel = 1000 /* Get the current drawing model (NPDrawingModel) */ #if defined(XP_MACOSX) , NPNVcontentsScaleFactor = 1001 #ifndef NP_NO_QUICKDRAW , NPNVsupportsQuickDrawBool = 2000 #endif , NPNVsupportsCoreGraphicsBool = 2001 , NPNVsupportsOpenGLBool = 2002 , NPNVsupportsCoreAnimationBool = 2003 , NPNVsupportsInvalidatingCoreAnimationBool = 2004 #endif #if 0 /* OBSOLETE */ , NPNVsupportsAsyncBitmapSurfaceBoolOBSOLETE = 2007 #if defined(XP_WIN) , NPNVsupportsAsyncWindowsDXGISurfaceBoolOBSOLETE = 2008 #endif #endif #if defined(XP_MACOSX) #ifndef NP_NO_CARBON , NPNVsupportsCarbonBool = 3000 /* TRUE if the browser supports the Carbon event model */ #endif , NPNVsupportsCocoaBool = 3001 /* TRUE if the browser supports the Cocoa event model */ , NPNVsupportsUpdatedCocoaTextInputBool = 3002 /* TRUE if the browser supports the updated Cocoa text input specification. */ #endif , NPNVmuteAudioBool = 4000 /* Request that the browser wants to mute or unmute the plugin */ #if defined(XP_MACOSX) , NPNVsupportsCompositingCoreAnimationPluginsBool = 74656 /* TRUE if the browser supports CA model compositing */ #endif } NPNVariable; typedef enum { NPNURLVCookie = 501, NPNURLVProxy } NPNURLVariable; /* * The type of Toolkit the widgets use */ typedef enum { NPNVGtk12 = 1, NPNVGtk2 } NPNToolkitType; /* * The type of a NPWindow - it specifies the type of the data structure * returned in the window field. */ typedef enum { NPWindowTypeWindow = 1, NPWindowTypeDrawable } NPWindowType; typedef struct _NPWindow { void* window; /* Platform specific window handle */ /* OS/2: x - Position of bottom left corner */ /* OS/2: y - relative to visible netscape window */ int32_t x; /* Position of top left corner relative */ int32_t y; /* to a netscape page. */ uint32_t width; /* Maximum window size */ uint32_t height; NPRect clipRect; /* Clipping rectangle in port coordinates */ #if (defined(XP_UNIX) || defined(XP_SYMBIAN)) && !defined(XP_MACOSX) void * ws_info; /* Platform-dependent additional data */ #endif /* XP_UNIX */ NPWindowType type; /* Is this a window or a drawable? */ } NPWindow; typedef struct _NPImageExpose { char* data; /* image pointer */ int32_t stride; /* Stride of data image pointer */ int32_t depth; /* Depth of image pointer */ int32_t x; /* Expose x */ int32_t y; /* Expose y */ uint32_t width; /* Expose width */ uint32_t height; /* Expose height */ NPSize dataSize; /* Data buffer size */ float translateX; /* translate X matrix value */ float translateY; /* translate Y matrix value */ float scaleX; /* scale X matrix value */ float scaleY; /* scale Y matrix value */ } NPImageExpose; typedef struct _NPFullPrint { NPBool pluginPrinted;/* Set TRUE if plugin handled fullscreen printing */ NPBool printOne; /* TRUE if plugin should print one copy to default printer */ void* platformPrint; /* Platform-specific printing info */ } NPFullPrint; typedef struct _NPEmbedPrint { NPWindow window; void* platformPrint; /* Platform-specific printing info */ } NPEmbedPrint; typedef struct _NPPrint { uint16_t mode; /* NP_FULL or NP_EMBED */ union { NPFullPrint fullPrint; /* if mode is NP_FULL */ NPEmbedPrint embedPrint; /* if mode is NP_EMBED */ } print; } NPPrint; #if defined(XP_MACOSX) #ifndef NP_NO_CARBON typedef EventRecord NPEvent; #endif #elif defined(XP_SYMBIAN) typedef QEvent NPEvent; #elif defined(XP_WIN) typedef struct _NPEvent { uint16_t event; uintptr_t wParam; uintptr_t lParam; } NPEvent; #elif defined(XP_UNIX) && defined(MOZ_X11) typedef XEvent NPEvent; #else typedef void* NPEvent; #endif #if defined(XP_MACOSX) typedef void* NPRegion; #ifndef NP_NO_QUICKDRAW typedef RgnHandle NPQDRegion; #endif typedef CGPathRef NPCGRegion; #elif defined(XP_WIN) typedef HRGN NPRegion; #elif defined(XP_UNIX) && defined(MOZ_X11) typedef Region NPRegion; #elif defined(XP_SYMBIAN) typedef QRegion* NPRegion; #else typedef void *NPRegion; #endif typedef struct _NPNSString NPNSString; typedef struct _NPNSWindow NPNSWindow; typedef struct _NPNSMenu NPNSMenu; #if defined(XP_MACOSX) typedef NPNSMenu NPMenu; #else typedef void *NPMenu; #endif typedef enum { NPCoordinateSpacePlugin = 1, NPCoordinateSpaceWindow, NPCoordinateSpaceFlippedWindow, NPCoordinateSpaceScreen, NPCoordinateSpaceFlippedScreen } NPCoordinateSpace; #if defined(XP_MACOSX) #ifndef NP_NO_QUICKDRAW typedef struct NP_Port { CGrafPtr port; int32_t portx; /* position inside the topmost window */ int32_t porty; } NP_Port; #endif /* NP_NO_QUICKDRAW */ /* * NP_CGContext is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelCoreGraphics * as its drawing model. */ typedef struct NP_CGContext { CGContextRef context; void *window; /* A WindowRef under the Carbon event model. */ } NP_CGContext; /* * NP_GLContext is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelOpenGL as its * drawing model. */ typedef struct NP_GLContext { CGLContextObj context; #ifdef NP_NO_CARBON NPNSWindow *window; #else void *window; /* Can be either an NSWindow or a WindowRef depending on the event model */ #endif } NP_GLContext; typedef enum { NPCocoaEventDrawRect = 1, NPCocoaEventMouseDown, NPCocoaEventMouseUp, NPCocoaEventMouseMoved, NPCocoaEventMouseEntered, NPCocoaEventMouseExited, NPCocoaEventMouseDragged, NPCocoaEventKeyDown, NPCocoaEventKeyUp, NPCocoaEventFlagsChanged, NPCocoaEventFocusChanged, NPCocoaEventWindowFocusChanged, NPCocoaEventScrollWheel, NPCocoaEventTextInput } NPCocoaEventType; typedef struct _NPCocoaEvent { NPCocoaEventType type; uint32_t version; union { struct { uint32_t modifierFlags; double pluginX; double pluginY; int32_t buttonNumber; int32_t clickCount; double deltaX; double deltaY; double deltaZ; } mouse; struct { uint32_t modifierFlags; NPNSString *characters; NPNSString *charactersIgnoringModifiers; NPBool isARepeat; uint16_t keyCode; } key; struct { CGContextRef context; double x; double y; double width; double height; } draw; struct { NPBool hasFocus; } focus; struct { NPNSString *text; } text; } data; } NPCocoaEvent; #ifndef NP_NO_CARBON /* Non-standard event types that can be passed to HandleEvent */ enum NPEventType { NPEventType_GetFocusEvent = (osEvt + 16), NPEventType_LoseFocusEvent, NPEventType_AdjustCursorEvent, NPEventType_MenuCommandEvent, NPEventType_ClippingChangedEvent, NPEventType_ScrollingBeginsEvent = 1000, NPEventType_ScrollingEndsEvent }; #endif /* NP_NO_CARBON */ #endif /* XP_MACOSX */ /* * Values for mode passed to NPP_New: */ #define NP_EMBED 1 #define NP_FULL 2 /* * Values for stream type passed to NPP_NewStream: */ #define NP_NORMAL 1 #define NP_SEEK 2 #define NP_ASFILE 3 #define NP_ASFILEONLY 4 #define NP_MAXREADY (((unsigned)(~0)<<1)>>1) /* * Flags for NPP_ClearSiteData. */ #define NP_CLEAR_ALL 0 #define NP_CLEAR_CACHE (1 << 0) #if !defined(__LP64__) #if defined(XP_MACOSX) #pragma options align=reset #endif #endif /* __LP64__ */ /*----------------------------------------------------------------------*/ /* Error and Reason Code definitions */ /*----------------------------------------------------------------------*/ /* * Values of type NPError: */ #define NPERR_BASE 0 #define NPERR_NO_ERROR (NPERR_BASE + 0) #define NPERR_GENERIC_ERROR (NPERR_BASE + 1) #define NPERR_INVALID_INSTANCE_ERROR (NPERR_BASE + 2) #define NPERR_INVALID_FUNCTABLE_ERROR (NPERR_BASE + 3) #define NPERR_MODULE_LOAD_FAILED_ERROR (NPERR_BASE + 4) #define NPERR_OUT_OF_MEMORY_ERROR (NPERR_BASE + 5) #define NPERR_INVALID_PLUGIN_ERROR (NPERR_BASE + 6) #define NPERR_INVALID_PLUGIN_DIR_ERROR (NPERR_BASE + 7) #define NPERR_INCOMPATIBLE_VERSION_ERROR (NPERR_BASE + 8) #define NPERR_INVALID_PARAM (NPERR_BASE + 9) #define NPERR_INVALID_URL (NPERR_BASE + 10) #define NPERR_FILE_NOT_FOUND (NPERR_BASE + 11) #define NPERR_NO_DATA (NPERR_BASE + 12) #define NPERR_STREAM_NOT_SEEKABLE (NPERR_BASE + 13) #define NPERR_TIME_RANGE_NOT_SUPPORTED (NPERR_BASE + 14) #define NPERR_MALFORMED_SITE (NPERR_BASE + 15) /* * Values of type NPReason: */ #define NPRES_BASE 0 #define NPRES_DONE (NPRES_BASE + 0) #define NPRES_NETWORK_ERR (NPRES_BASE + 1) #define NPRES_USER_BREAK (NPRES_BASE + 2) /* * Don't use these obsolete error codes any more. */ #define NP_NOERR NP_NOERR_is_obsolete_use_NPERR_NO_ERROR #define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR #define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK /* * Version feature information */ #define NPVERS_HAS_STREAMOUTPUT 8 #define NPVERS_HAS_NOTIFICATION 9 #define NPVERS_HAS_LIVECONNECT 9 #define NPVERS_68K_HAS_LIVECONNECT 11 #define NPVERS_HAS_WINDOWLESS 11 #define NPVERS_HAS_XPCONNECT_SCRIPTING 13 #define NPVERS_HAS_NPRUNTIME_SCRIPTING 14 #define NPVERS_HAS_FORM_VALUES 15 #define NPVERS_HAS_POPUPS_ENABLED_STATE 16 #define NPVERS_HAS_RESPONSE_HEADERS 17 #define NPVERS_HAS_NPOBJECT_ENUM 18 #define NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL 19 #define NPVERS_HAS_ALL_NETWORK_STREAMS 20 #define NPVERS_HAS_URL_AND_AUTH_INFO 21 #define NPVERS_HAS_PRIVATE_MODE 22 #define NPVERS_MACOSX_HAS_COCOA_EVENTS 23 #define NPVERS_HAS_ADVANCED_KEY_HANDLING 25 #define NPVERS_HAS_URL_REDIRECT_HANDLING 26 #define NPVERS_HAS_CLEAR_SITE_DATA 27 /*----------------------------------------------------------------------*/ /* Function Prototypes */ /*----------------------------------------------------------------------*/ #ifdef __cplusplus extern "C" { #endif /* NPP_* functions are provided by the plugin and called by the navigator. */ #if defined(XP_UNIX) const char* NPP_GetMIMEDescription(void); #endif NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved); NPError NPP_Destroy(NPP instance, NPSavedData** save); NPError NPP_SetWindow(NPP instance, NPWindow* window); NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype); NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason); int32_t NPP_WriteReady(NPP instance, NPStream* stream); int32_t NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer); void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname); void NPP_Print(NPP instance, NPPrint* platformPrint); int16_t NPP_HandleEvent(NPP instance, void* event); void NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData); NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value); NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value); NPBool NPP_GotFocus(NPP instance, NPFocusDirection direction); void NPP_LostFocus(NPP instance); void NPP_URLRedirectNotify(NPP instance, const char* url, int32_t status, void* notifyData); NPError NPP_ClearSiteData(const char* site, uint64_t flags, uint64_t maxAge); char** NPP_GetSitesWithData(void); void NPP_DidComposite(NPP instance); /* NPN_* functions are provided by the navigator and called by the plugin. */ void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor); NPError NPN_GetURLNotify(NPP instance, const char* url, const char* target, void* notifyData); NPError NPN_GetURL(NPP instance, const char* url, const char* target); NPError NPN_PostURLNotify(NPP instance, const char* url, const char* target, uint32_t len, const char* buf, NPBool file, void* notifyData); NPError NPN_PostURL(NPP instance, const char* url, const char* target, uint32_t len, const char* buf, NPBool file); NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList); NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream); int32_t NPN_Write(NPP instance, NPStream* stream, int32_t len, void* buffer); NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPReason reason); void NPN_Status(NPP instance, const char* message); const char* NPN_UserAgent(NPP instance); void* NPN_MemAlloc(uint32_t size); void NPN_MemFree(void* ptr); uint32_t NPN_MemFlush(uint32_t size); void NPN_ReloadPlugins(NPBool reloadPages); NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value); NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value); void NPN_InvalidateRect(NPP instance, NPRect *invalidRect); void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion); void NPN_ForceRedraw(NPP instance); void NPN_PushPopupsEnabledState(NPP instance, NPBool enabled); void NPN_PopPopupsEnabledState(NPP instance); void NPN_PluginThreadAsyncCall(NPP instance, void (*func) (void *), void *userData); NPError NPN_GetValueForURL(NPP instance, NPNURLVariable variable, const char *url, char **value, uint32_t *len); NPError NPN_SetValueForURL(NPP instance, NPNURLVariable variable, const char *url, const char *value, uint32_t len); NPError NPN_GetAuthenticationInfo(NPP instance, const char *protocol, const char *host, int32_t port, const char *scheme, const char *realm, char **username, uint32_t *ulen, char **password, uint32_t *plen); uint32_t NPN_ScheduleTimer(NPP instance, uint32_t interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32_t timerID)); void NPN_UnscheduleTimer(NPP instance, uint32_t timerID); NPError NPN_PopUpContextMenu(NPP instance, NPMenu* menu); NPBool NPN_ConvertPoint(NPP instance, double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace); NPBool NPN_HandleEvent(NPP instance, void *event, NPBool handled); NPBool NPN_UnfocusInstance(NPP instance, NPFocusDirection direction); void NPN_URLRedirectResponse(NPP instance, void* notifyData, NPBool allow); #ifdef __cplusplus } /* end extern "C" */ #endif #endif /* RC_INVOKED */ #endif /* npapi_h_ */ freshplayerplugin-0.3.9/3rdparty/npapi/npfunctions.h000066400000000000000000000341721321746453100227010ustar00rootroot00000000000000/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef npfunctions_h_ #define npfunctions_h_ #include "npapi.h" #include "npruntime.h" #ifdef MOZ_WIDGET_ANDROID #include #endif typedef NPError (* NPP_NewProcPtr)(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved); typedef NPError (* NPP_DestroyProcPtr)(NPP instance, NPSavedData** save); typedef NPError (* NPP_SetWindowProcPtr)(NPP instance, NPWindow* window); typedef NPError (* NPP_NewStreamProcPtr)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype); typedef NPError (* NPP_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason); typedef int32_t (* NPP_WriteReadyProcPtr)(NPP instance, NPStream* stream); typedef int32_t (* NPP_WriteProcPtr)(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer); typedef void (* NPP_StreamAsFileProcPtr)(NPP instance, NPStream* stream, const char* fname); typedef void (* NPP_PrintProcPtr)(NPP instance, NPPrint* platformPrint); typedef int16_t (* NPP_HandleEventProcPtr)(NPP instance, void* event); typedef void (* NPP_URLNotifyProcPtr)(NPP instance, const char* url, NPReason reason, void* notifyData); /* Any NPObjects returned to the browser via NPP_GetValue should be retained by the plugin on the way out. The browser is responsible for releasing. */ typedef NPError (* NPP_GetValueProcPtr)(NPP instance, NPPVariable variable, void *ret_value); typedef NPError (* NPP_SetValueProcPtr)(NPP instance, NPNVariable variable, void *value); typedef NPBool (* NPP_GotFocusPtr)(NPP instance, NPFocusDirection direction); typedef void (* NPP_LostFocusPtr)(NPP instance); typedef void (* NPP_URLRedirectNotifyPtr)(NPP instance, const char* url, int32_t status, void* notifyData); typedef NPError (* NPP_ClearSiteDataPtr)(const char* site, uint64_t flags, uint64_t maxAge); typedef char** (* NPP_GetSitesWithDataPtr)(void); typedef void (* NPP_DidCompositePtr)(NPP instance); typedef NPError (*NPN_GetValueProcPtr)(NPP instance, NPNVariable variable, void *ret_value); typedef NPError (*NPN_SetValueProcPtr)(NPP instance, NPPVariable variable, void *value); typedef NPError (*NPN_GetURLNotifyProcPtr)(NPP instance, const char* url, const char* window, void* notifyData); typedef NPError (*NPN_PostURLNotifyProcPtr)(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file, void* notifyData); typedef NPError (*NPN_GetURLProcPtr)(NPP instance, const char* url, const char* window); typedef NPError (*NPN_PostURLProcPtr)(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file); typedef NPError (*NPN_RequestReadProcPtr)(NPStream* stream, NPByteRange* rangeList); typedef NPError (*NPN_NewStreamProcPtr)(NPP instance, NPMIMEType type, const char* window, NPStream** stream); typedef int32_t (*NPN_WriteProcPtr)(NPP instance, NPStream* stream, int32_t len, void* buffer); typedef NPError (*NPN_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason); typedef void (*NPN_StatusProcPtr)(NPP instance, const char* message); /* Browser manages the lifetime of the buffer returned by NPN_UserAgent, don't depend on it sticking around and don't free it. */ typedef const char* (*NPN_UserAgentProcPtr)(NPP instance); typedef void* (*NPN_MemAllocProcPtr)(uint32_t size); typedef void (*NPN_MemFreeProcPtr)(void* ptr); typedef uint32_t (*NPN_MemFlushProcPtr)(uint32_t size); typedef void (*NPN_ReloadPluginsProcPtr)(NPBool reloadPages); typedef void* (*NPN_GetJavaEnvProcPtr)(void); typedef void* (*NPN_GetJavaPeerProcPtr)(NPP instance); typedef void (*NPN_InvalidateRectProcPtr)(NPP instance, NPRect *rect); typedef void (*NPN_InvalidateRegionProcPtr)(NPP instance, NPRegion region); typedef void (*NPN_ForceRedrawProcPtr)(NPP instance); typedef NPIdentifier (*NPN_GetStringIdentifierProcPtr)(const NPUTF8* name); typedef void (*NPN_GetStringIdentifiersProcPtr)(const NPUTF8** names, int32_t nameCount, NPIdentifier* identifiers); typedef NPIdentifier (*NPN_GetIntIdentifierProcPtr)(int32_t intid); typedef bool (*NPN_IdentifierIsStringProcPtr)(NPIdentifier identifier); typedef NPUTF8* (*NPN_UTF8FromIdentifierProcPtr)(NPIdentifier identifier); typedef int32_t (*NPN_IntFromIdentifierProcPtr)(NPIdentifier identifier); typedef NPObject* (*NPN_CreateObjectProcPtr)(NPP npp, NPClass *aClass); typedef NPObject* (*NPN_RetainObjectProcPtr)(NPObject *obj); typedef void (*NPN_ReleaseObjectProcPtr)(NPObject *obj); typedef bool (*NPN_InvokeProcPtr)(NPP npp, NPObject* obj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result); typedef bool (*NPN_InvokeDefaultProcPtr)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result); typedef bool (*NPN_EvaluateProcPtr)(NPP npp, NPObject *obj, NPString *script, NPVariant *result); typedef bool (*NPN_GetPropertyProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName, NPVariant *result); typedef bool (*NPN_SetPropertyProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName, const NPVariant *value); typedef bool (*NPN_RemovePropertyProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName); typedef bool (*NPN_HasPropertyProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName); typedef bool (*NPN_HasMethodProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName); typedef void (*NPN_ReleaseVariantValueProcPtr)(NPVariant *variant); typedef void (*NPN_SetExceptionProcPtr)(NPObject *obj, const NPUTF8 *message); typedef void (*NPN_PushPopupsEnabledStateProcPtr)(NPP npp, NPBool enabled); typedef void (*NPN_PopPopupsEnabledStateProcPtr)(NPP npp); typedef bool (*NPN_EnumerateProcPtr)(NPP npp, NPObject *obj, NPIdentifier **identifier, uint32_t *count); typedef void (*NPN_PluginThreadAsyncCallProcPtr)(NPP instance, void (*func)(void *), void *userData); typedef bool (*NPN_ConstructProcPtr)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result); typedef NPError (*NPN_GetValueForURLPtr)(NPP npp, NPNURLVariable variable, const char *url, char **value, uint32_t *len); typedef NPError (*NPN_SetValueForURLPtr)(NPP npp, NPNURLVariable variable, const char *url, const char *value, uint32_t len); typedef NPError (*NPN_GetAuthenticationInfoPtr)(NPP npp, const char *protocol, const char *host, int32_t port, const char *scheme, const char *realm, char **username, uint32_t *ulen, char **password, uint32_t *plen); typedef uint32_t (*NPN_ScheduleTimerPtr)(NPP instance, uint32_t interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32_t timerID)); typedef void (*NPN_UnscheduleTimerPtr)(NPP instance, uint32_t timerID); typedef NPError (*NPN_PopUpContextMenuPtr)(NPP instance, NPMenu* menu); typedef NPBool (*NPN_ConvertPointPtr)(NPP instance, double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace); typedef NPBool (*NPN_HandleEventPtr)(NPP instance, void *event, NPBool handled); typedef NPBool (*NPN_UnfocusInstancePtr)(NPP instance, NPFocusDirection direction); typedef void (*NPN_URLRedirectResponsePtr)(NPP instance, void* notifyData, NPBool allow); typedef void (*NPN_DummyPtr)(void); typedef struct _NPPluginFuncs { uint16_t size; uint16_t version; NPP_NewProcPtr newp; NPP_DestroyProcPtr destroy; NPP_SetWindowProcPtr setwindow; NPP_NewStreamProcPtr newstream; NPP_DestroyStreamProcPtr destroystream; NPP_StreamAsFileProcPtr asfile; NPP_WriteReadyProcPtr writeready; NPP_WriteProcPtr write; NPP_PrintProcPtr print; NPP_HandleEventProcPtr event; NPP_URLNotifyProcPtr urlnotify; void* javaClass; NPP_GetValueProcPtr getvalue; NPP_SetValueProcPtr setvalue; NPP_GotFocusPtr gotfocus; NPP_LostFocusPtr lostfocus; NPP_URLRedirectNotifyPtr urlredirectnotify; NPP_ClearSiteDataPtr clearsitedata; NPP_GetSitesWithDataPtr getsiteswithdata; NPP_DidCompositePtr didComposite; } NPPluginFuncs; typedef struct _NPNetscapeFuncs { uint16_t size; uint16_t version; NPN_GetURLProcPtr geturl; NPN_PostURLProcPtr posturl; NPN_RequestReadProcPtr requestread; NPN_NewStreamProcPtr newstream; NPN_WriteProcPtr write; NPN_DestroyStreamProcPtr destroystream; NPN_StatusProcPtr status; NPN_UserAgentProcPtr uagent; NPN_MemAllocProcPtr memalloc; NPN_MemFreeProcPtr memfree; NPN_MemFlushProcPtr memflush; NPN_ReloadPluginsProcPtr reloadplugins; NPN_GetJavaEnvProcPtr getJavaEnv; NPN_GetJavaPeerProcPtr getJavaPeer; NPN_GetURLNotifyProcPtr geturlnotify; NPN_PostURLNotifyProcPtr posturlnotify; NPN_GetValueProcPtr getvalue; NPN_SetValueProcPtr setvalue; NPN_InvalidateRectProcPtr invalidaterect; NPN_InvalidateRegionProcPtr invalidateregion; NPN_ForceRedrawProcPtr forceredraw; NPN_GetStringIdentifierProcPtr getstringidentifier; NPN_GetStringIdentifiersProcPtr getstringidentifiers; NPN_GetIntIdentifierProcPtr getintidentifier; NPN_IdentifierIsStringProcPtr identifierisstring; NPN_UTF8FromIdentifierProcPtr utf8fromidentifier; NPN_IntFromIdentifierProcPtr intfromidentifier; NPN_CreateObjectProcPtr createobject; NPN_RetainObjectProcPtr retainobject; NPN_ReleaseObjectProcPtr releaseobject; NPN_InvokeProcPtr invoke; NPN_InvokeDefaultProcPtr invokeDefault; NPN_EvaluateProcPtr evaluate; NPN_GetPropertyProcPtr getproperty; NPN_SetPropertyProcPtr setproperty; NPN_RemovePropertyProcPtr removeproperty; NPN_HasPropertyProcPtr hasproperty; NPN_HasMethodProcPtr hasmethod; NPN_ReleaseVariantValueProcPtr releasevariantvalue; NPN_SetExceptionProcPtr setexception; NPN_PushPopupsEnabledStateProcPtr pushpopupsenabledstate; NPN_PopPopupsEnabledStateProcPtr poppopupsenabledstate; NPN_EnumerateProcPtr enumerate; NPN_PluginThreadAsyncCallProcPtr pluginthreadasynccall; NPN_ConstructProcPtr construct; NPN_GetValueForURLPtr getvalueforurl; NPN_SetValueForURLPtr setvalueforurl; NPN_GetAuthenticationInfoPtr getauthenticationinfo; NPN_ScheduleTimerPtr scheduletimer; NPN_UnscheduleTimerPtr unscheduletimer; NPN_PopUpContextMenuPtr popupcontextmenu; NPN_ConvertPointPtr convertpoint; NPN_HandleEventPtr handleevent; NPN_UnfocusInstancePtr unfocusinstance; NPN_URLRedirectResponsePtr urlredirectresponse; NPN_DummyPtr initasyncsurfaceOBSOLETE; NPN_DummyPtr finalizeasyncsurfaceOBSOLETE; NPN_DummyPtr setcurrentasyncsurfaceOBSOLETE; } NPNetscapeFuncs; #ifdef XP_MACOSX /* * Mac OS X version(s) of NP_GetMIMEDescription(const char *) * These can be called to retrieve MIME information from the plugin dynamically * * Note: For compatibility with Quicktime, BPSupportedMIMEtypes is another way * to get mime info from the plugin only on OSX and may not be supported * in furture version -- use NP_GetMIMEDescription instead */ enum { kBPSupportedMIMETypesStructVers_1 = 1 }; typedef struct _BPSupportedMIMETypes { SInt32 structVersion; /* struct version */ Handle typeStrings; /* STR# formatted handle, allocated by plug-in */ Handle infoStrings; /* STR# formatted handle, allocated by plug-in */ } BPSupportedMIMETypes; OSErr BP_GetSupportedMIMETypes(BPSupportedMIMETypes *mimeInfo, UInt32 flags); #define NP_GETMIMEDESCRIPTION_NAME "NP_GetMIMEDescription" typedef const char* (*NP_GetMIMEDescriptionProcPtr)(void); typedef OSErr (*BP_GetSupportedMIMETypesProcPtr)(BPSupportedMIMETypes*, UInt32); #endif #if defined(_WIN32) #define OSCALL WINAPI #else #define OSCALL #endif #if defined(XP_UNIX) /* GCC 3.3 and later support the visibility attribute. */ #if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) #define NP_VISIBILITY_DEFAULT __attribute__((visibility("default"))) #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) #define NP_VISIBILITY_DEFAULT __global #else #define NP_VISIBILITY_DEFAULT #endif #define NP_EXPORT(__type) NP_VISIBILITY_DEFAULT __type #endif #if defined(_WIN32) #ifdef __cplusplus extern "C" { #endif /* plugin meta member functions */ typedef NPError (OSCALL *NP_GetEntryPointsFunc)(NPPluginFuncs*); NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs); typedef NPError (OSCALL *NP_InitializeFunc)(NPNetscapeFuncs*); NPError OSCALL NP_Initialize(NPNetscapeFuncs* bFuncs); typedef NPError (OSCALL *NP_ShutdownFunc)(void); NPError OSCALL NP_Shutdown(void); typedef const char* (*NP_GetMIMEDescriptionFunc)(void); const char* NP_GetMIMEDescription(void); #ifdef __cplusplus } #endif #endif #ifdef XP_UNIX #ifdef __cplusplus extern "C" { #endif typedef char* (*NP_GetPluginVersionFunc)(void); NP_EXPORT(char*) NP_GetPluginVersion(void); typedef const char* (*NP_GetMIMEDescriptionFunc)(void); NP_EXPORT(const char*) NP_GetMIMEDescription(void); #ifdef XP_MACOSX typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*); NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs); typedef NPError (*NP_GetEntryPointsFunc)(NPPluginFuncs*); NP_EXPORT(NPError) NP_GetEntryPoints(NPPluginFuncs* pFuncs); #else #ifdef MOZ_WIDGET_ANDROID typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*, NPPluginFuncs*, JNIEnv* pEnv); NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, JNIEnv* pEnv); #else typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*, NPPluginFuncs*); NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs); #endif #endif typedef NPError (*NP_ShutdownFunc)(void); NP_EXPORT(NPError) NP_Shutdown(void); typedef NPError (*NP_GetValueFunc)(void *, NPPVariable, void *); NP_EXPORT(NPError) NP_GetValue(void *future, NPPVariable aVariable, void *aValue); #ifdef __cplusplus } #endif #endif #endif /* npfunctions_h_ */ freshplayerplugin-0.3.9/3rdparty/npapi/npruntime.h000066400000000000000000000377761321746453100223710ustar00rootroot00000000000000/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (c) 2004, Apple Computer, Inc. and The Mozilla Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the names of Apple Computer, Inc. ("Apple") or The Mozilla * Foundation ("Mozilla") nor the names of their contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY APPLE, MOZILLA AND THEIR CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE, MOZILLA OR * THEIR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifndef _NP_RUNTIME_H_ #define _NP_RUNTIME_H_ #ifdef __cplusplus extern "C" { #endif #include "nptypes.h" /* This API is used to facilitate binding code written in C to script objects. The API in this header does not assume the presence of a user agent. That is, it can be used to bind C code to scripting environments outside of the context of a user agent. However, the normal use of the this API is in the context of a scripting environment running in a browser or other user agent. In particular it is used to support the extended Netscape script-ability API for plugins (NP-SAP). NP-SAP is an extension of the Netscape plugin API. As such we have adopted the use of the "NP" prefix for this API. The following NP{N|P}Variables were added to the Netscape plugin API (in npapi.h): NPNVWindowNPObject NPNVPluginElementNPObject NPPVpluginScriptableNPObject These variables are exposed through NPN_GetValue() and NPP_GetValue() (respectively) and are used to establish the initial binding between the user agent and native code. The DOM objects in the user agent can be examined and manipulated using the NPN_ functions that operate on NPObjects described in this header. To the extent possible the assumptions about the scripting language used by the scripting environment have been minimized. */ #define NP_BEGIN_MACRO do { #define NP_END_MACRO } while (0) /* Objects (non-primitive data) passed between 'C' and script is always wrapped in an NPObject. The 'interface' of an NPObject is described by an NPClass. */ typedef struct NPObject NPObject; typedef struct NPClass NPClass; typedef char NPUTF8; typedef struct _NPString { const NPUTF8 *UTF8Characters; uint32_t UTF8Length; } NPString; typedef enum { NPVariantType_Void, NPVariantType_Null, NPVariantType_Bool, NPVariantType_Int32, NPVariantType_Double, NPVariantType_String, NPVariantType_Object } NPVariantType; typedef struct _NPVariant { NPVariantType type; union { bool boolValue; int32_t intValue; double doubleValue; NPString stringValue; NPObject *objectValue; } value; } NPVariant; /* NPN_ReleaseVariantValue is called on all 'out' parameters references. Specifically it is to be called on variants that own their value, as is the case with all non-const NPVariant* arguments after a successful call to any methods (except this one) in this API. After calling NPN_ReleaseVariantValue, the type of the variant will be NPVariantType_Void. */ void NPN_ReleaseVariantValue(NPVariant *variant); #define NPVARIANT_IS_VOID(_v) ((_v).type == NPVariantType_Void) #define NPVARIANT_IS_NULL(_v) ((_v).type == NPVariantType_Null) #define NPVARIANT_IS_BOOLEAN(_v) ((_v).type == NPVariantType_Bool) #define NPVARIANT_IS_INT32(_v) ((_v).type == NPVariantType_Int32) #define NPVARIANT_IS_DOUBLE(_v) ((_v).type == NPVariantType_Double) #define NPVARIANT_IS_STRING(_v) ((_v).type == NPVariantType_String) #define NPVARIANT_IS_OBJECT(_v) ((_v).type == NPVariantType_Object) #define NPVARIANT_TO_BOOLEAN(_v) ((_v).value.boolValue) #define NPVARIANT_TO_INT32(_v) ((_v).value.intValue) #define NPVARIANT_TO_DOUBLE(_v) ((_v).value.doubleValue) #define NPVARIANT_TO_STRING(_v) ((_v).value.stringValue) #define NPVARIANT_TO_OBJECT(_v) ((_v).value.objectValue) #define VOID_TO_NPVARIANT(_v) \ NP_BEGIN_MACRO \ (_v).type = NPVariantType_Void; \ (_v).value.objectValue = NULL; \ NP_END_MACRO #define NULL_TO_NPVARIANT(_v) \ NP_BEGIN_MACRO \ (_v).type = NPVariantType_Null; \ (_v).value.objectValue = NULL; \ NP_END_MACRO #define BOOLEAN_TO_NPVARIANT(_val, _v) \ NP_BEGIN_MACRO \ (_v).type = NPVariantType_Bool; \ (_v).value.boolValue = !!(_val); \ NP_END_MACRO #define INT32_TO_NPVARIANT(_val, _v) \ NP_BEGIN_MACRO \ (_v).type = NPVariantType_Int32; \ (_v).value.intValue = _val; \ NP_END_MACRO #define DOUBLE_TO_NPVARIANT(_val, _v) \ NP_BEGIN_MACRO \ (_v).type = NPVariantType_Double; \ (_v).value.doubleValue = _val; \ NP_END_MACRO #define STRINGZ_TO_NPVARIANT(_val, _v) \ NP_BEGIN_MACRO \ (_v).type = NPVariantType_String; \ NPString str = { _val, (uint32_t)(strlen(_val)) }; \ (_v).value.stringValue = str; \ NP_END_MACRO #define STRINGN_TO_NPVARIANT(_val, _len, _v) \ NP_BEGIN_MACRO \ (_v).type = NPVariantType_String; \ NPString str = { _val, (uint32_t)(_len) }; \ (_v).value.stringValue = str; \ NP_END_MACRO #define OBJECT_TO_NPVARIANT(_val, _v) \ NP_BEGIN_MACRO \ (_v).type = NPVariantType_Object; \ (_v).value.objectValue = _val; \ NP_END_MACRO /* Type mappings (JavaScript types have been used for illustration purposes): JavaScript to C (NPVariant with type:) undefined NPVariantType_Void null NPVariantType_Null Boolean NPVariantType_Bool Number NPVariantType_Double or NPVariantType_Int32 String NPVariantType_String Object NPVariantType_Object C (NPVariant with type:) to JavaScript NPVariantType_Void undefined NPVariantType_Null null NPVariantType_Bool Boolean NPVariantType_Int32 Number NPVariantType_Double Number NPVariantType_String String NPVariantType_Object Object */ typedef void *NPIdentifier; /* NPObjects have methods and properties. Methods and properties are identified with NPIdentifiers. These identifiers may be reflected in script. NPIdentifiers can be either strings or integers, IOW, methods and properties can be identified by either strings or integers (i.e. foo["bar"] vs foo[1]). NPIdentifiers can be compared using ==. In case of any errors, the requested NPIdentifier(s) will be NULL. NPIdentifier lifetime is controlled by the browser. Plugins do not need to worry about memory management with regards to NPIdentifiers. */ NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name); void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount, NPIdentifier *identifiers); NPIdentifier NPN_GetIntIdentifier(int32_t intid); bool NPN_IdentifierIsString(NPIdentifier identifier); /* The NPUTF8 returned from NPN_UTF8FromIdentifier SHOULD be freed. */ NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier); /* Get the integer represented by identifier. If identifier is not an integer identifier, the behaviour is undefined. */ int32_t NPN_IntFromIdentifier(NPIdentifier identifier); /* NPObject behavior is implemented using the following set of callback functions. The NPVariant *result argument of these functions (where applicable) should be released using NPN_ReleaseVariantValue(). */ typedef NPObject *(*NPAllocateFunctionPtr)(NPP npp, NPClass *aClass); typedef void (*NPDeallocateFunctionPtr)(NPObject *npobj); typedef void (*NPInvalidateFunctionPtr)(NPObject *npobj); typedef bool (*NPHasMethodFunctionPtr)(NPObject *npobj, NPIdentifier name); typedef bool (*NPInvokeFunctionPtr)(NPObject *npobj, NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result); typedef bool (*NPInvokeDefaultFunctionPtr)(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result); typedef bool (*NPHasPropertyFunctionPtr)(NPObject *npobj, NPIdentifier name); typedef bool (*NPGetPropertyFunctionPtr)(NPObject *npobj, NPIdentifier name, NPVariant *result); typedef bool (*NPSetPropertyFunctionPtr)(NPObject *npobj, NPIdentifier name, const NPVariant *value); typedef bool (*NPRemovePropertyFunctionPtr)(NPObject *npobj, NPIdentifier name); typedef bool (*NPEnumerationFunctionPtr)(NPObject *npobj, NPIdentifier **value, uint32_t *count); typedef bool (*NPConstructFunctionPtr)(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result); /* NPObjects returned by create, retain, invoke, and getProperty pass a reference count to the caller. That is, the callee adds a reference count which passes to the caller. It is the caller's responsibility to release the returned object. NPInvokeFunctionPtr function may return 0 to indicate a void result. NPInvalidateFunctionPtr is called by the scripting environment when the native code is shutdown. Any attempt to message a NPObject instance after the invalidate callback has been called will result in undefined behavior, even if the native code is still retaining those NPObject instances. (The runtime will typically return immediately, with 0 or NULL, from an attempt to dispatch to a NPObject, but this behavior should not be depended upon.) The NPEnumerationFunctionPtr function may pass an array of NPIdentifiers back to the caller. The callee allocs the memory of the array using NPN_MemAlloc(), and it's the caller's responsibility to release it using NPN_MemFree(). */ struct NPClass { uint32_t structVersion; NPAllocateFunctionPtr allocate; NPDeallocateFunctionPtr deallocate; NPInvalidateFunctionPtr invalidate; NPHasMethodFunctionPtr hasMethod; NPInvokeFunctionPtr invoke; NPInvokeDefaultFunctionPtr invokeDefault; NPHasPropertyFunctionPtr hasProperty; NPGetPropertyFunctionPtr getProperty; NPSetPropertyFunctionPtr setProperty; NPRemovePropertyFunctionPtr removeProperty; NPEnumerationFunctionPtr enumerate; NPConstructFunctionPtr construct; }; #define NP_CLASS_STRUCT_VERSION 3 #define NP_CLASS_STRUCT_VERSION_ENUM 2 #define NP_CLASS_STRUCT_VERSION_CTOR 3 #define NP_CLASS_STRUCT_VERSION_HAS_ENUM(npclass) \ ((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_ENUM) #define NP_CLASS_STRUCT_VERSION_HAS_CTOR(npclass) \ ((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_CTOR) struct NPObject { NPClass *_class; uint32_t referenceCount; /* * Additional space may be allocated here by types of NPObjects */ }; /* If the class has an allocate function, NPN_CreateObject invokes that function, otherwise a NPObject is allocated and returned. This method will initialize the referenceCount member of the NPObject to 1. */ NPObject *NPN_CreateObject(NPP npp, NPClass *aClass); /* Increment the NPObject's reference count. */ NPObject *NPN_RetainObject(NPObject *npobj); /* Decremented the NPObject's reference count. If the reference count goes to zero, the class's destroy function is invoke if specified, otherwise the object is freed directly. */ void NPN_ReleaseObject(NPObject *npobj); /* Functions to access script objects represented by NPObject. Calls to script objects are synchronous. If a function returns a value, it will be supplied via the result NPVariant argument. Successful calls will return true, false will be returned in case of an error. Calls made from plugin code to script must be made from the thread on which the plugin was initialized. */ bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result); bool NPN_InvokeDefault(NPP npp, NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result); bool NPN_Evaluate(NPP npp, NPObject *npobj, NPString *script, NPVariant *result); bool NPN_GetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, NPVariant *result); bool NPN_SetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, const NPVariant *value); bool NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName); bool NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName); bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName); bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t *count); bool NPN_Construct(NPP npp, NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result); /* NPN_SetException may be called to trigger a script exception upon return from entry points into NPObjects. Typical usage: NPN_SetException (npobj, message); */ void NPN_SetException(NPObject *npobj, const NPUTF8 *message); #ifdef __cplusplus } #endif #endif freshplayerplugin-0.3.9/3rdparty/npapi/nptypes.h000066400000000000000000000043761321746453100220400ustar00rootroot00000000000000/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef nptypes_h_ #define nptypes_h_ /* * Header file for ensuring that C99 types ([u]int32_t, [u]int64_t and bool) and * true/false macros are available. */ #if defined(WIN32) /* * Win32 and OS/2 don't know C99, so define [u]int_16/32/64 here. The bool * is predefined tho, both in C and C++. */ typedef short int16_t; typedef unsigned short uint16_t; typedef int int32_t; typedef unsigned int uint32_t; typedef long long int64_t; typedef unsigned long long uint64_t; #elif defined(_AIX) || defined(__sun) || defined(__osf__) || defined(IRIX) || defined(HPUX) /* * AIX and SunOS ship a inttypes.h header that defines [u]int32_t, * but not bool for C. */ #include #ifndef __cplusplus typedef int bool; #define true 1 #define false 0 #endif #elif defined(bsdi) || defined(FREEBSD) || defined(OPENBSD) /* * BSD/OS, FreeBSD, and OpenBSD ship sys/types.h that define int32_t and * u_int32_t. */ #include /* * BSD/OS ships no header that defines uint32_t, nor bool (for C) */ #if defined(bsdi) typedef u_int32_t uint32_t; typedef u_int64_t uint64_t; #if !defined(__cplusplus) typedef int bool; #define true 1 #define false 0 #endif #else /* * FreeBSD and OpenBSD define uint32_t and bool. */ #include #include #endif #elif defined(BEOS) #include #else /* * For those that ship a standard C99 stdint.h header file, include * it. Can't do the same for stdbool.h tho, since some systems ship * with a stdbool.h file that doesn't compile! */ #include #ifndef __cplusplus #if !defined(__GNUC__) || (__GNUC__ > 2 || __GNUC_MINOR__ > 95) #include #else /* * GCC 2.91 can't deal with a typedef for bool, but a #define * works. */ #define bool int #define true 1 #define false 0 #endif #endif #endif #endif /* nptypes_h_ */ freshplayerplugin-0.3.9/3rdparty/parson/000077500000000000000000000000001321746453100203465ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/parson/.gitignore000066400000000000000000000000231321746453100223310ustar00rootroot00000000000000.DS_Store test *.o freshplayerplugin-0.3.9/3rdparty/parson/CMakeLists.txt000066400000000000000000000000501321746453100231010ustar00rootroot00000000000000add_library(parson-obj OBJECT parson.c) freshplayerplugin-0.3.9/3rdparty/parson/Makefile000066400000000000000000000002661321746453100220120ustar00rootroot00000000000000CC = gcc CFLAGS = -O0 -g -Wall -Wextra -std=c89 -pedantic-errors all: test .PHONY: test test: tests.c parson.c $(CC) $(CFLAGS) -o $@ tests.c parson.c ./$@ clean: rm -f test *.ofreshplayerplugin-0.3.9/3rdparty/parson/README.md000066400000000000000000000111231321746453100216230ustar00rootroot00000000000000##About Parson is a lighweight [json](http://json.org) library written in C. ##Features * Full JSON support * Lightweight (only 2 files) * Simple API * Addressing json values with dot notation (similar to C structs or objects in most OO languages, e.g. "objectA.objectB.value") * C89 compatible * Test suites ##Installation Run: ``` git clone https://github.com/kgabis/parson.git ``` and copy parson.h and parson.c to you source code tree. Run ```make test``` to compile and run tests. ##Examples ###Parsing JSON Here is a function, which prints basic commit info (date, sha and author) from a github repository. ```c void print_commits_info(const char *username, const char *repo) { JSON_Value *root_value; JSON_Array *commits; JSON_Object *commit; size_t i; char curl_command[512]; char cleanup_command[256]; char output_filename[] = "commits.json"; /* it ain't pretty, but it's not a libcurl tutorial */ sprintf(curl_command, "curl -s \"https://api.github.com/repos/%s/%s/commits\" > %s", username, repo, output_filename); sprintf(cleanup_command, "rm -f %s", output_filename); system(curl_command); /* parsing json and validating output */ root_value = json_parse_file(output_filename); if (json_value_get_type(root_value) != JSONArray) { system(cleanup_command); return; } /* getting array from root value and printing commit info */ commits = json_value_get_array(root_value); printf("%-10.10s %-10.10s %s\n", "Date", "SHA", "Author"); for (i = 0; i < json_array_get_count(commits); i++) { commit = json_array_get_object(commits, i); printf("%.10s %.10s %s\n", json_object_dotget_string(commit, "commit.author.date"), json_object_get_string(commit, "sha"), json_object_dotget_string(commit, "commit.author.name")); } /* cleanup code */ json_value_free(root_value); system(cleanup_command); } ``` Calling ```print_commits_info("torvalds", "linux");``` prints: ``` Date SHA Author 2012-10-15 dd8e8c4a2c David Rientjes 2012-10-15 3ce9e53e78 Michal Marek 2012-10-14 29bb4cc5e0 Randy Dunlap 2012-10-15 325adeb55e Ralf Baechle 2012-10-14 68687c842c Russell King 2012-10-14 ddffeb8c4d Linus Torvalds ... ``` ###Persistence In this example I'm using parson to save user information to a file and then load it and validate later. ```c void persistence_example(void) { JSON_Value *schema = json_parse_string("{\"name\":\"\"}"); JSON_Value *user_data = json_parse_file("user_data.json"); char buf[256]; const char *name = NULL; if (user_data == NULL || json_validate(schema, user_data) != JSONSuccess) { puts("Enter your name:"); scanf("%s", buf); user_data = json_value_init_object(); json_object_set_string(json_object(user_data), "name", buf); json_serialize_to_file(user_data, "user_data.json"); } name = json_object_get_string(json_object(user_data), "name"); printf("Hello, %s.", name); json_value_free(schema); json_value_free(user_data); return; } ``` ###Serialization Creating JSON values is very simple thanks to the dot notation. Object hierarchy is automatically created when addressing specific fields. In the following example I create a simple JSON value containing basic information about a person. ```c void serialization_example(void) { JSON_Value *root_value = json_value_init_object(); JSON_Object *root_object = json_value_get_object(root_value); char *serialized_string = NULL; json_object_set_string(root_object, "name", "John Smith"); json_object_set_number(root_object, "age", 25); json_object_dotset_string(root_object, "address.city", "Cupertino"); json_object_dotset_value(root_object, "contact.emails", json_parse_string("[\"email@example.com\",\"email2@example.com\"]")); serialized_string = json_serialize_to_string(root_value); puts(serialized_string); json_free_serialized_string(serialized_string); json_value_free(root_value); } ``` Created value (after formatting outside parson): ``` { "name":"John Smith", "age":25, "address":{ "city":"Cupertino" }, "contact":{ "emails":[ "email@example.com", "email2@example.com" ] } } ``` ##Contributing I will always merge *working* bug fixes. However, if you want to add something to the API, I *won't* merge it without prior discussion. Remember to follow parson's code style and write appropriate tests. ##License [The MIT License (MIT)](http://opensource.org/licenses/mit-license.php)freshplayerplugin-0.3.9/3rdparty/parson/package.json000066400000000000000000000003401321746453100226310ustar00rootroot00000000000000{ "name": "parson", "version": "0.0.0", "repo": "kgabis/parson", "description": "Small json parser and reader", "keywords": [ "json", "parser" ], "license": "MIT", "src": [ "parson.c", "parson.h" ] } freshplayerplugin-0.3.9/3rdparty/parson/parson.c000066400000000000000000001541201321746453100220170ustar00rootroot00000000000000/* Parson ( http://kgabis.github.com/parson/ ) Copyright (c) 2012 - 2014 Krzysztof Gabis 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. */ #ifdef _MSC_VER #define _CRT_SECURE_NO_WARNINGS #endif #include "parson.h" #include #include #include #include #include #define STARTING_CAPACITY 15 #define ARRAY_MAX_CAPACITY 122880 /* 15*(2^13) */ #define OBJECT_MAX_CAPACITY 960 /* 15*(2^6) */ #define MAX_NESTING 19 #define DOUBLE_SERIALIZATION_FORMAT "%f" #define SIZEOF_TOKEN(a) (sizeof(a) - 1) #define SKIP_CHAR(str) ((*str)++) #define SKIP_WHITESPACES(str) while (isspace(**str)) { SKIP_CHAR(str); } #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define PARSON_MALLOC(a) malloc(a) #define PARSON_FREE(a) free((void*)(a)) #define PARSON_REALLOC(a, b) realloc((a), (b)) #define PRINT_AND_SKIP(str, to_append) str += sprintf(str, to_append); #define PRINTF_AND_SKIP(str, format, to_append) str += sprintf(str, format, to_append); /* Type definitions */ typedef union json_value_value { const char *string; double number; JSON_Object *object; JSON_Array *array; int boolean; int null; } JSON_Value_Value; struct json_value_t { JSON_Value_Type type; JSON_Value_Value value; }; struct json_object_t { const char **names; JSON_Value **values; size_t count; size_t capacity; }; struct json_array_t { JSON_Value **items; size_t count; size_t capacity; }; /* Various */ static char * read_file(const char *filename); static void remove_comments(char *string, const char *start_token, const char *end_token); static int try_realloc(void **ptr, size_t new_size); static char * parson_strndup(const char *string, size_t n); static char * parson_strdup(const char *string); static int is_utf(const unsigned char *string); static int is_decimal(const char *string, size_t length); static size_t parson_strlen(const char *string); /* JSON Object */ static JSON_Object * json_object_init(void); static JSON_Status json_object_add(JSON_Object *object, const char *name, JSON_Value *value); static JSON_Status json_object_resize(JSON_Object *object, size_t capacity); static JSON_Value * json_object_nget_value(const JSON_Object *object, const char *name, size_t n); static void json_object_free(JSON_Object *object); /* JSON Array */ static JSON_Array * json_array_init(void); static JSON_Status json_array_add(JSON_Array *array, JSON_Value *value); static JSON_Status json_array_resize(JSON_Array *array, size_t capacity); static void json_array_free(JSON_Array *array); /* JSON Value */ static JSON_Value * json_value_init_string_no_copy(const char *string); /* Parser */ static void skip_quotes(const char **string); static int parse_utf_16(const char **unprocessed, char **processed); static char* process_string(const char *input, size_t len); static const char * get_quoted_string(const char **string); static JSON_Value * parse_object_value(const char **string, size_t nesting); static JSON_Value * parse_array_value(const char **string, size_t nesting); static JSON_Value * parse_string_value(const char **string); static JSON_Value * parse_boolean_value(const char **string); static JSON_Value * parse_number_value(const char **string); static JSON_Value * parse_null_value(const char **string); static JSON_Value * parse_value(const char **string, size_t nesting); /* Serialization */ static size_t json_serialization_size_r(const JSON_Value *value, char *buf); static char * json_serialize_to_buffer_r(const JSON_Value *value, char *buf); static char * json_serialize_string(const char *string, char *buf); /* Various */ static int try_realloc(void **ptr, size_t new_size) { void *reallocated_ptr = NULL; if (new_size == 0) { return JSONFailure; } reallocated_ptr = PARSON_REALLOC(*ptr, new_size); if (reallocated_ptr == NULL) { return JSONFailure; } *ptr = reallocated_ptr; return JSONSuccess; } static char * parson_strndup(const char *string, size_t n) { char *output_string = (char*)PARSON_MALLOC(n + 1); if (!output_string) return NULL; output_string[n] = '\0'; strncpy(output_string, string, n); return output_string; } static char * parson_strdup(const char *string) { return parson_strndup(string, strlen(string)); } static int is_utf(const unsigned char *s) { return isxdigit(s[0]) && isxdigit(s[1]) && isxdigit(s[2]) && isxdigit(s[3]); } static int is_decimal(const char *string, size_t length) { if (length > 1 && string[0] == '0' && string[1] != '.') return 0; if (length > 2 && !strncmp(string, "-0", 2) && string[2] != '.') return 0; while (length--) if (strchr("xX", string[length])) return 0; return 1; } static size_t parson_strlen(const char *string) { size_t result = 0; size_t i = 0, len = strlen(string); for (i = 0; i < len; i++) { if (strchr("\"\\\b\f\n\r\t", string[i])) /* must be escaped */ result += 2; else result += 1; } return result; } static char * read_file(const char * filename) { FILE *fp = fopen(filename, "r"); size_t file_size; long pos; char *file_contents; if (!fp) return NULL; fseek(fp, 0L, SEEK_END); pos = ftell(fp); if (pos < 0) { fclose(fp); return NULL; } file_size = pos; rewind(fp); file_contents = (char*)PARSON_MALLOC(sizeof(char) * (file_size + 1)); if (!file_contents) { fclose(fp); return NULL; } if (fread(file_contents, file_size, 1, fp) < 1) { if (ferror(fp)) { fclose(fp); PARSON_FREE(file_contents); return NULL; } } fclose(fp); file_contents[file_size] = '\0'; return file_contents; } static void remove_comments(char *string, const char *start_token, const char *end_token) { int in_string = 0, escaped = 0; size_t i; char *ptr = NULL, current_char; size_t start_token_len = strlen(start_token); size_t end_token_len = strlen(end_token); if (start_token_len == 0 || end_token_len == 0) return; while ((current_char = *string) != '\0') { if (current_char == '\\' && !escaped) { escaped = 1; string++; continue; } else if (current_char == '\"' && !escaped) { in_string = !in_string; } else if (!in_string && strncmp(string, start_token, start_token_len) == 0) { for(i = 0; i < start_token_len; i++) string[i] = ' '; string = string + start_token_len; ptr = strstr(string, end_token); if (!ptr) return; for (i = 0; i < (ptr - string) + end_token_len; i++) string[i] = ' '; string = ptr + end_token_len - 1; } escaped = 0; string++; } } /* JSON Object */ static JSON_Object * json_object_init(void) { JSON_Object *new_obj = (JSON_Object*)PARSON_MALLOC(sizeof(JSON_Object)); if (!new_obj) return NULL; new_obj->names = (const char**)NULL; new_obj->values = (JSON_Value**)NULL; new_obj->capacity = 0; new_obj->count = 0; return new_obj; } static JSON_Status json_object_add(JSON_Object *object, const char *name, JSON_Value *value) { size_t index = 0; if (object == NULL || name == NULL || value == NULL) { return JSONFailure; } if (object->count >= object->capacity) { size_t new_capacity = MAX(object->capacity * 2, STARTING_CAPACITY); if (new_capacity > OBJECT_MAX_CAPACITY) return JSONFailure; if (json_object_resize(object, new_capacity) == JSONFailure) return JSONFailure; } if (json_object_get_value(object, name) != NULL) return JSONFailure; index = object->count; object->names[index] = parson_strdup(name); if (object->names[index] == NULL) return JSONFailure; object->values[index] = value; object->count++; return JSONSuccess; } static JSON_Status json_object_resize(JSON_Object *object, size_t capacity) { if (try_realloc((void**)&object->names, capacity * sizeof(char*)) == JSONFailure) return JSONFailure; if (try_realloc((void**)&object->values, capacity * sizeof(JSON_Value*)) == JSONFailure) return JSONFailure; object->capacity = capacity; return JSONSuccess; } static JSON_Value * json_object_nget_value(const JSON_Object *object, const char *name, size_t n) { size_t i, name_length; for (i = 0; i < json_object_get_count(object); i++) { name_length = strlen(object->names[i]); if (name_length != n) continue; if (strncmp(object->names[i], name, n) == 0) return object->values[i]; } return NULL; } static void json_object_free(JSON_Object *object) { while(object->count--) { PARSON_FREE(object->names[object->count]); json_value_free(object->values[object->count]); } PARSON_FREE(object->names); PARSON_FREE(object->values); PARSON_FREE(object); } /* JSON Array */ static JSON_Array * json_array_init(void) { JSON_Array *new_array = (JSON_Array*)PARSON_MALLOC(sizeof(JSON_Array)); if (!new_array) return NULL; new_array->items = (JSON_Value**)NULL; new_array->capacity = 0; new_array->count = 0; return new_array; } static JSON_Status json_array_add(JSON_Array *array, JSON_Value *value) { if (array->count >= array->capacity) { size_t new_capacity = MAX(array->capacity * 2, STARTING_CAPACITY); if (new_capacity > ARRAY_MAX_CAPACITY) return JSONFailure; if (json_array_resize(array, new_capacity) == JSONFailure) return JSONFailure; } array->items[array->count] = value; array->count++; return JSONSuccess; } static JSON_Status json_array_resize(JSON_Array *array, size_t capacity) { if (try_realloc((void**)&array->items, capacity * sizeof(JSON_Value*)) == JSONFailure) return JSONFailure; array->capacity = capacity; return JSONSuccess; } static void json_array_free(JSON_Array *array) { while (array->count--) json_value_free(array->items[array->count]); PARSON_FREE(array->items); PARSON_FREE(array); } /* JSON Value */ static JSON_Value * json_value_init_string_no_copy(const char *string) { JSON_Value *new_value = (JSON_Value*)PARSON_MALLOC(sizeof(JSON_Value)); if (!new_value) return NULL; new_value->type = JSONString; new_value->value.string = string; return new_value; } /* Parser */ static void skip_quotes(const char **string) { SKIP_CHAR(string); while (**string != '\"') { if (**string == '\0') return; if (**string == '\\') { SKIP_CHAR(string); if (**string == '\0') return; } SKIP_CHAR(string); } SKIP_CHAR(string); } static int parse_utf_16(const char **unprocessed, char **processed) { unsigned int cp, lead, trail; char *processed_ptr = *processed; const char *unprocessed_ptr = *unprocessed; unprocessed_ptr++; /* skips u */ if (!is_utf((const unsigned char*)unprocessed_ptr) || sscanf(unprocessed_ptr, "%4x", &cp) == EOF) return JSONFailure; if (cp < 0x80) { *processed_ptr = cp; /* 0xxxxxxx */ } else if (cp < 0x800) { *processed_ptr++ = ((cp >> 6) & 0x1F) | 0xC0; /* 110xxxxx */ *processed_ptr = ((cp ) & 0x3F) | 0x80; /* 10xxxxxx */ } else if (cp < 0xD800 || cp > 0xDFFF) { *processed_ptr++ = ((cp >> 12) & 0x0F) | 0xE0; /* 1110xxxx */ *processed_ptr++ = ((cp >> 6) & 0x3F) | 0x80; /* 10xxxxxx */ *processed_ptr = ((cp ) & 0x3F) | 0x80; /* 10xxxxxx */ } else if (cp >= 0xD800 && cp <= 0xDBFF) { /* lead surrogate (0xD800..0xDBFF) */ lead = cp; unprocessed_ptr += 4; /* should always be within the buffer, otherwise previous sscanf would fail */ if (*unprocessed_ptr++ != '\\' || *unprocessed_ptr++ != 'u' || /* starts with \u? */ !is_utf((const unsigned char*)unprocessed_ptr) || sscanf(unprocessed_ptr, "%4x", &trail) == EOF || trail < 0xDC00 || trail > 0xDFFF) { /* valid trail surrogate? (0xDC00..0xDFFF) */ return JSONFailure; } cp = ((((lead-0xD800)&0x3FF)<<10)|((trail-0xDC00)&0x3FF))+0x010000; *processed_ptr++ = (((cp >> 18) & 0x07) | 0xF0); /* 11110xxx */ *processed_ptr++ = (((cp >> 12) & 0x3F) | 0x80); /* 10xxxxxx */ *processed_ptr++ = (((cp >> 6) & 0x3F) | 0x80); /* 10xxxxxx */ *processed_ptr = (((cp ) & 0x3F) | 0x80); /* 10xxxxxx */ } else { /* trail surrogate before lead surrogate */ return JSONFailure; } unprocessed_ptr += 3; *processed = processed_ptr; *unprocessed = unprocessed_ptr; return JSONSuccess; } /* Copies and processes passed string up to supplied length. Example: "\u006Corem ipsum" -> lorem ipsum */ static char* process_string(const char *input, size_t len) { const char *input_ptr = input; char *output = (char*)PARSON_MALLOC((len + 1) * sizeof(char)); char *output_ptr = output; while ((*input_ptr != '\0') && (size_t)(input_ptr - input) < len) { if (*input_ptr == '\\') { input_ptr++; switch (*input_ptr) { case '\"': *output_ptr = '\"'; break; case '\\': *output_ptr = '\\'; break; case '/': *output_ptr = '/'; break; case 'b': *output_ptr = '\b'; break; case 'f': *output_ptr = '\f'; break; case 'n': *output_ptr = '\n'; break; case 'r': *output_ptr = '\r'; break; case 't': *output_ptr = '\t'; break; case 'u': if (parse_utf_16(&input_ptr, &output_ptr) == JSONFailure) goto error; break; default: goto error; } } else if ((unsigned char)*input_ptr < 0x20) { goto error; /* 0x00-0x19 are invalid characters for json string (http://www.ietf.org/rfc/rfc4627.txt) */ } else { *output_ptr = *input_ptr; } output_ptr++; input_ptr++; } *output_ptr = '\0'; if (try_realloc((void**)&output, (size_t)(output_ptr-output) + 1) == JSONFailure) /* resize to new length */ goto error; return output; error: free(output); return NULL; } /* Return processed contents of a string between quotes and skips passed argument to a matching quote. */ static const char * get_quoted_string(const char **string) { const char *string_start = *string; size_t string_len = 0; skip_quotes(string); if (**string == '\0') return NULL; string_len = *string - string_start - 2; /* length without quotes */ return process_string(string_start + 1, string_len); } static JSON_Value * parse_value(const char **string, size_t nesting) { if (nesting > MAX_NESTING) return NULL; SKIP_WHITESPACES(string); switch (**string) { case '{': return parse_object_value(string, nesting + 1); case '[': return parse_array_value(string, nesting + 1); case '\"': return parse_string_value(string); case 'f': case 't': return parse_boolean_value(string); case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return parse_number_value(string); case 'n': return parse_null_value(string); default: return NULL; } } static JSON_Value * parse_object_value(const char **string, size_t nesting) { JSON_Value *output_value = json_value_init_object(), *new_value = NULL; JSON_Object *output_object = json_value_get_object(output_value); const char *new_key = NULL; if (output_value == NULL) return NULL; SKIP_CHAR(string); SKIP_WHITESPACES(string); if (**string == '}') { /* empty object */ SKIP_CHAR(string); return output_value; } while (**string != '\0') { new_key = get_quoted_string(string); SKIP_WHITESPACES(string); if (new_key == NULL || **string != ':') { json_value_free(output_value); return NULL; } SKIP_CHAR(string); new_value = parse_value(string, nesting); if (new_value == NULL) { PARSON_FREE(new_key); json_value_free(output_value); return NULL; } if(json_object_add(output_object, new_key, new_value) == JSONFailure) { PARSON_FREE(new_key); PARSON_FREE(new_value); json_value_free(output_value); return NULL; } PARSON_FREE(new_key); SKIP_WHITESPACES(string); if (**string != ',') break; SKIP_CHAR(string); SKIP_WHITESPACES(string); } SKIP_WHITESPACES(string); if (**string != '}' || /* Trim object after parsing is over */ json_object_resize(output_object, json_object_get_count(output_object)) == JSONFailure) { json_value_free(output_value); return NULL; } SKIP_CHAR(string); return output_value; } static JSON_Value * parse_array_value(const char **string, size_t nesting) { JSON_Value *output_value = json_value_init_array(), *new_array_value = NULL; JSON_Array *output_array = json_value_get_array(output_value); if (!output_value) return NULL; SKIP_CHAR(string); SKIP_WHITESPACES(string); if (**string == ']') { /* empty array */ SKIP_CHAR(string); return output_value; } while (**string != '\0') { new_array_value = parse_value(string, nesting); if (!new_array_value) { json_value_free(output_value); return NULL; } if(json_array_add(output_array, new_array_value) == JSONFailure) { PARSON_FREE(new_array_value); json_value_free(output_value); return NULL; } SKIP_WHITESPACES(string); if (**string != ',') break; SKIP_CHAR(string); SKIP_WHITESPACES(string); } SKIP_WHITESPACES(string); if (**string != ']' || /* Trim array after parsing is over */ json_array_resize(output_array, json_array_get_count(output_array)) == JSONFailure) { json_value_free(output_value); return NULL; } SKIP_CHAR(string); return output_value; } static JSON_Value * parse_string_value(const char **string) { const char *new_string = get_quoted_string(string); if (!new_string) return NULL; return json_value_init_string_no_copy(new_string); } static JSON_Value * parse_boolean_value(const char **string) { size_t true_token_size = SIZEOF_TOKEN("true"); size_t false_token_size = SIZEOF_TOKEN("false"); if (strncmp("true", *string, true_token_size) == 0) { *string += true_token_size; return json_value_init_boolean(1); } else if (strncmp("false", *string, false_token_size) == 0) { *string += false_token_size; return json_value_init_boolean(0); } return NULL; } static JSON_Value * parse_number_value(const char **string) { char *end; double number = strtod(*string, &end); JSON_Value *output_value; if (is_decimal(*string, end - *string)) { *string = end; output_value = json_value_init_number(number); } else { output_value = NULL; } return output_value; } static JSON_Value * parse_null_value(const char **string) { size_t token_size = SIZEOF_TOKEN("null"); if (strncmp("null", *string, token_size) == 0) { *string += token_size; return json_value_init_null(); } return NULL; } /* Serialization */ static size_t json_serialization_size_r(const JSON_Value *value, char *buf) { size_t result_size = 0; const char *key = NULL; JSON_Value *temp_value = NULL; JSON_Array *array = NULL; JSON_Object *object = NULL; size_t i = 0, count = 0; double num = 0.0; switch (json_value_get_type(value)) { case JSONArray: array = json_value_get_array(value); count = json_array_get_count(array); result_size += 2; /* [ and ] brackets */ if (count > 0) result_size += count - 1; /* , between items */ for (i = 0; i < count; i++) { temp_value = json_array_get_value(array, i); result_size += json_serialization_size_r(temp_value, buf); } return result_size; case JSONObject: object = json_value_get_object(value); count = json_object_get_count(object); result_size += 2; /* { and } brackets */ if (count > 0) result_size += (count * 2) - 1; /* : between keys and values and , between items */ for (i = 0; i < count; i++) { key = json_object_get_name(object, i); result_size += parson_strlen(key) + 2; /* string and quotes */ result_size += json_serialization_size_r(json_object_get_value(object, key), buf); } return result_size; case JSONString: return parson_strlen(json_value_get_string(value)) + 2; /* string and quotes */ case JSONBoolean: if (json_value_get_boolean(value)) return 4; /* strlen("true"); */ else return 5; /* strlen("false"); */ case JSONNumber: num = json_value_get_number(value); if (num == ((double)(int)num) ) /* check if num is integer */ return (size_t)sprintf(buf, "%d", (int)num); return (size_t)sprintf(buf, DOUBLE_SERIALIZATION_FORMAT, num); case JSONNull: return 4; /* strlen("null"); */ case JSONError: return 0; default: return 0; } } char* json_serialize_to_buffer_r(const JSON_Value *value, char *buf) { const char *key = NULL, *string = NULL; JSON_Value *temp_value = NULL; JSON_Array *array = NULL; JSON_Object *object = NULL; size_t i = 0, count = 0; double num = 0.0; switch (json_value_get_type(value)) { case JSONArray: array = json_value_get_array(value); count = json_array_get_count(array); PRINT_AND_SKIP(buf, "["); for (i = 0; i < count; i++) { temp_value = json_array_get_value(array, i); buf = json_serialize_to_buffer_r(temp_value, buf); if (buf == NULL) return NULL; if (i < (count - 1)) PRINT_AND_SKIP(buf, ","); } PRINT_AND_SKIP(buf, "]"); return buf; case JSONObject: object = json_value_get_object(value); count = json_object_get_count(object); PRINT_AND_SKIP(buf, "{"); for (i = 0; i < count; i++) { key = json_object_get_name(object, i); buf = json_serialize_string(key, buf); if (buf == NULL) return NULL; PRINT_AND_SKIP(buf, ":"); temp_value = json_object_get_value(object, key); buf = json_serialize_to_buffer_r(temp_value, buf); if (buf == NULL) return NULL; if (i < (count - 1)) PRINT_AND_SKIP(buf, ","); } PRINT_AND_SKIP(buf, "}"); return buf; case JSONString: string = json_value_get_string(value); buf = json_serialize_string(string, buf); return buf; case JSONBoolean: if (json_value_get_boolean(value)) { PRINT_AND_SKIP(buf, "true"); } else { PRINT_AND_SKIP(buf, "false"); } return buf; case JSONNumber: num = json_value_get_number(value); if (num == ((double)(int)num)) { /* check if num is integer */ PRINTF_AND_SKIP(buf, "%d", (int)num); } else { PRINTF_AND_SKIP(buf, DOUBLE_SERIALIZATION_FORMAT, num); } return buf; case JSONNull: PRINT_AND_SKIP(buf, "null"); return buf; case JSONError: return NULL; default: return NULL; } } static char * json_serialize_string(const char *string, char *buf) { size_t i = 0, len = strlen(string); char c = '\0'; PRINT_AND_SKIP(buf, "\"") for (i = 0; i < len; i++) { c = string[i]; switch (c) { case '\"': PRINT_AND_SKIP(buf, "\\\""); break; case '\\': PRINT_AND_SKIP(buf, "\\\\"); break; case '\b': PRINT_AND_SKIP(buf, "\\b"); break; case '\f': PRINT_AND_SKIP(buf, "\\f"); break; case '\n': PRINT_AND_SKIP(buf, "\\n"); break; case '\r': PRINT_AND_SKIP(buf, "\\r"); break; case '\t': PRINT_AND_SKIP(buf, "\\t"); break; default: PRINTF_AND_SKIP(buf, "%c", c); break; } } PRINT_AND_SKIP(buf, "\""); return buf; } /* Parser API */ JSON_Value * json_parse_file(const char *filename) { char *file_contents = read_file(filename); JSON_Value *output_value = NULL; if (file_contents == NULL) return NULL; output_value = json_parse_string(file_contents); PARSON_FREE(file_contents); return output_value; } JSON_Value * json_parse_file_with_comments(const char *filename) { char *file_contents = read_file(filename); JSON_Value *output_value = NULL; if (file_contents == NULL) return NULL; output_value = json_parse_string_with_comments(file_contents); PARSON_FREE(file_contents); return output_value; } JSON_Value * json_parse_string(const char *string) { if (string == NULL) return NULL; SKIP_WHITESPACES(&string); if (*string != '{' && *string != '[') return NULL; return parse_value((const char**)&string, 0); } JSON_Value * json_parse_string_with_comments(const char *string) { JSON_Value *result = NULL; char *string_mutable_copy = NULL, *string_mutable_copy_ptr = NULL; string_mutable_copy = parson_strdup(string); if (string_mutable_copy == NULL) return NULL; remove_comments(string_mutable_copy, "/*", "*/"); remove_comments(string_mutable_copy, "//", "\n"); string_mutable_copy_ptr = string_mutable_copy; SKIP_WHITESPACES(&string_mutable_copy_ptr); if (*string_mutable_copy_ptr != '{' && *string_mutable_copy_ptr != '[') { PARSON_FREE(string_mutable_copy); return NULL; } result = parse_value((const char**)&string_mutable_copy_ptr, 0); PARSON_FREE(string_mutable_copy); return result; } /* JSON Object API */ JSON_Value * json_object_get_value(const JSON_Object *object, const char *name) { if (object == NULL || name == NULL) return NULL; return json_object_nget_value(object, name, strlen(name)); } const char * json_object_get_string(const JSON_Object *object, const char *name) { return json_value_get_string(json_object_get_value(object, name)); } double json_object_get_number(const JSON_Object *object, const char *name) { return json_value_get_number(json_object_get_value(object, name)); } JSON_Object * json_object_get_object(const JSON_Object *object, const char *name) { return json_value_get_object(json_object_get_value(object, name)); } JSON_Array * json_object_get_array(const JSON_Object *object, const char *name) { return json_value_get_array(json_object_get_value(object, name)); } int json_object_get_boolean(const JSON_Object *object, const char *name) { return json_value_get_boolean(json_object_get_value(object, name)); } JSON_Value * json_object_dotget_value(const JSON_Object *object, const char *name) { const char *dot_position = strchr(name, '.'); if (!dot_position) return json_object_get_value(object, name); object = json_value_get_object(json_object_nget_value(object, name, dot_position - name)); return json_object_dotget_value(object, dot_position + 1); } const char * json_object_dotget_string(const JSON_Object *object, const char *name) { return json_value_get_string(json_object_dotget_value(object, name)); } double json_object_dotget_number(const JSON_Object *object, const char *name) { return json_value_get_number(json_object_dotget_value(object, name)); } JSON_Object * json_object_dotget_object(const JSON_Object *object, const char *name) { return json_value_get_object(json_object_dotget_value(object, name)); } JSON_Array * json_object_dotget_array(const JSON_Object *object, const char *name) { return json_value_get_array(json_object_dotget_value(object, name)); } int json_object_dotget_boolean(const JSON_Object *object, const char *name) { return json_value_get_boolean(json_object_dotget_value(object, name)); } size_t json_object_get_count(const JSON_Object *object) { return object ? object->count : 0; } const char * json_object_get_name(const JSON_Object *object, size_t index) { if (index >= json_object_get_count(object)) return NULL; return object->names[index]; } /* JSON Array API */ JSON_Value * json_array_get_value(const JSON_Array *array, size_t index) { if (index >= json_array_get_count(array)) return NULL; return array->items[index]; } const char * json_array_get_string(const JSON_Array *array, size_t index) { return json_value_get_string(json_array_get_value(array, index)); } double json_array_get_number(const JSON_Array *array, size_t index) { return json_value_get_number(json_array_get_value(array, index)); } JSON_Object * json_array_get_object(const JSON_Array *array, size_t index) { return json_value_get_object(json_array_get_value(array, index)); } JSON_Array * json_array_get_array(const JSON_Array *array, size_t index) { return json_value_get_array(json_array_get_value(array, index)); } int json_array_get_boolean(const JSON_Array *array, size_t index) { return json_value_get_boolean(json_array_get_value(array, index)); } size_t json_array_get_count(const JSON_Array *array) { return array ? array->count : 0; } /* JSON Value API */ JSON_Value_Type json_value_get_type(const JSON_Value *value) { return value ? value->type : JSONError; } JSON_Object * json_value_get_object(const JSON_Value *value) { return json_value_get_type(value) == JSONObject ? value->value.object : NULL; } JSON_Array * json_value_get_array(const JSON_Value *value) { return json_value_get_type(value) == JSONArray ? value->value.array : NULL; } const char * json_value_get_string(const JSON_Value *value) { return json_value_get_type(value) == JSONString ? value->value.string : NULL; } double json_value_get_number(const JSON_Value *value) { return json_value_get_type(value) == JSONNumber ? value->value.number : 0; } int json_value_get_boolean(const JSON_Value *value) { return json_value_get_type(value) == JSONBoolean ? value->value.boolean : -1; } void json_value_free(JSON_Value *value) { switch (json_value_get_type(value)) { case JSONObject: json_object_free(value->value.object); break; case JSONString: if (value->value.string) { PARSON_FREE(value->value.string); } break; case JSONArray: json_array_free(value->value.array); break; default: break; } PARSON_FREE(value); } JSON_Value * json_value_init_object(void) { JSON_Value *new_value = (JSON_Value*)PARSON_MALLOC(sizeof(JSON_Value)); if (!new_value) return NULL; new_value->type = JSONObject; new_value->value.object = json_object_init(); if (!new_value->value.object) { PARSON_FREE(new_value); return NULL; } return new_value; } JSON_Value * json_value_init_array(void) { JSON_Value *new_value = (JSON_Value*)PARSON_MALLOC(sizeof(JSON_Value)); if (!new_value) return NULL; new_value->type = JSONArray; new_value->value.array = json_array_init(); if (!new_value->value.array) { PARSON_FREE(new_value); return NULL; } return new_value; } JSON_Value * json_value_init_string(const char *string) { char *copy = NULL; JSON_Value *value; if (string == NULL) return NULL; copy = parson_strdup(string); if (copy == NULL) return NULL; value = json_value_init_string_no_copy(copy); if (value == NULL) PARSON_FREE(copy); return value; } JSON_Value * json_value_init_number(double number) { JSON_Value *new_value = (JSON_Value*)PARSON_MALLOC(sizeof(JSON_Value)); if (!new_value) return NULL; new_value->type = JSONNumber; new_value->value.number = number; return new_value; } JSON_Value * json_value_init_boolean(int boolean) { JSON_Value *new_value = (JSON_Value*)PARSON_MALLOC(sizeof(JSON_Value)); if (!new_value) return NULL; new_value->type = JSONBoolean; new_value->value.boolean = boolean ? 1 : 0; return new_value; } JSON_Value * json_value_init_null(void) { JSON_Value *new_value = (JSON_Value*)PARSON_MALLOC(sizeof(JSON_Value)); if (!new_value) return NULL; new_value->type = JSONNull; return new_value; } JSON_Value * json_value_deep_copy(const JSON_Value *value) { size_t i = 0; JSON_Value *return_value = NULL, *temp_value_copy = NULL, *temp_value = NULL; const char *temp_string = NULL, *temp_string_copy = NULL, *temp_key = NULL; JSON_Array *temp_array = NULL, *temp_array_copy = NULL; JSON_Object *temp_object = NULL, *temp_object_copy = NULL; switch (json_value_get_type(value)) { case JSONArray: temp_array = json_value_get_array(value); return_value = json_value_init_array(); if (return_value == NULL) return NULL; temp_array_copy = json_value_get_array(return_value); for (i = 0; i < json_array_get_count(temp_array); i++) { temp_value = json_array_get_value(temp_array, i); temp_value_copy = json_value_deep_copy(temp_value); if (temp_value_copy == NULL) { json_value_free(return_value); return NULL; } if (json_array_add(temp_array_copy, temp_value_copy) == JSONFailure) { json_value_free(return_value); json_value_free(temp_value_copy); return NULL; } } return return_value; case JSONObject: temp_object = json_value_get_object(value); return_value = json_value_init_object(); if (return_value == NULL) return NULL; temp_object_copy = json_value_get_object(return_value); for (i = 0; i < json_object_get_count(temp_object); i++) { temp_key = json_object_get_name(temp_object, i); temp_value = json_object_get_value(temp_object, temp_key); temp_value_copy = json_value_deep_copy(temp_value); if (temp_value_copy == NULL) { json_value_free(return_value); return NULL; } if (json_object_add(temp_object_copy, temp_key, temp_value_copy) == JSONFailure) { json_value_free(return_value); json_value_free(temp_value_copy); return NULL; } } return return_value; case JSONBoolean: return json_value_init_boolean(json_value_get_boolean(value)); case JSONNumber: return json_value_init_number(json_value_get_number(value)); case JSONString: temp_string = json_value_get_string(value); temp_string_copy = parson_strdup(temp_string); if (temp_string_copy == NULL) return NULL; return_value = json_value_init_string_no_copy(temp_string_copy); if (return_value == NULL) PARSON_FREE(temp_string_copy); return return_value; case JSONNull: return json_value_init_null(); case JSONError: return NULL; default: return NULL; } } size_t json_serialization_size(const JSON_Value *value) { char buf[1100]; /* recursively allocating buffer on stack is a bad idea, so let's do it only once */ return json_serialization_size_r(value, buf) + 1; } JSON_Status json_serialize_to_buffer(const JSON_Value *value, char *buf, size_t buf_size_in_bytes) { char *serialization_result = NULL; size_t needed_size_in_bytes = json_serialization_size(value); if (buf_size_in_bytes < needed_size_in_bytes) { return JSONFailure; } serialization_result = json_serialize_to_buffer_r(value, buf); if(serialization_result == NULL) return JSONFailure; return JSONSuccess; } JSON_Status json_serialize_to_file(const JSON_Value *value, const char *filename) { JSON_Status return_code = JSONSuccess; FILE *fp = NULL; char *serialized_string = json_serialize_to_string(value); if (serialized_string == NULL) { return JSONFailure; } fp = fopen (filename, "w"); if (fp != NULL) { if (fputs (serialized_string, fp) == EOF) { return_code = JSONFailure; } if (fclose (fp) == EOF) { return_code = JSONFailure; } } json_free_serialized_string(serialized_string); return return_code; } char * json_serialize_to_string(const JSON_Value *value) { JSON_Status serialization_result = JSONFailure; size_t buf_size_bytes = json_serialization_size(value); char *buf = (char*)PARSON_MALLOC(buf_size_bytes); if (buf == NULL) return NULL; serialization_result = json_serialize_to_buffer(value, buf, buf_size_bytes); if (serialization_result == JSONFailure) { json_free_serialized_string(buf); return NULL; } return buf; } void json_free_serialized_string(char *string) { PARSON_FREE(string); } JSON_Status json_array_remove(JSON_Array *array, size_t ix) { size_t last_element_ix = 0; if (array == NULL || ix >= json_array_get_count(array)) { return JSONFailure; } last_element_ix = json_array_get_count(array) - 1; json_value_free(json_array_get_value(array, ix)); array->count -= 1; if (ix != last_element_ix) /* Replace value with one from the end of array */ array->items[ix] = json_array_get_value(array, last_element_ix); return JSONSuccess; } JSON_Status json_array_replace_value(JSON_Array *array, size_t ix, JSON_Value *value) { if (array == NULL || value == NULL || ix >= json_array_get_count(array)) { return JSONFailure; } json_value_free(json_array_get_value(array, ix)); array->items[ix] = value; return JSONSuccess; } JSON_Status json_array_replace_string(JSON_Array *array, size_t i, const char* string) { JSON_Value *value = json_value_init_string(string); if (value == NULL) return JSONFailure; if (json_array_replace_value(array, i, value) == JSONFailure) { json_value_free(value); return JSONFailure; } return JSONSuccess; } JSON_Status json_array_replace_number(JSON_Array *array, size_t i, double number) { JSON_Value *value = json_value_init_number(number); if (value == NULL) return JSONFailure; if (json_array_replace_value(array, i, value) == JSONFailure) { json_value_free(value); return JSONFailure; } return JSONSuccess; } JSON_Status json_array_replace_boolean(JSON_Array *array, size_t i, int boolean) { JSON_Value *value = json_value_init_boolean(boolean); if (value == NULL) return JSONFailure; if (json_array_replace_value(array, i, value) == JSONFailure) { json_value_free(value); return JSONFailure; } return JSONSuccess; } JSON_Status json_array_replace_null(JSON_Array *array, size_t i) { JSON_Value *value = json_value_init_null(); if (value == NULL) return JSONFailure; if (json_array_replace_value(array, i, value) == JSONFailure) { json_value_free(value); return JSONFailure; } return JSONSuccess; } JSON_Status json_array_clear(JSON_Array *array) { size_t i = 0; if (array == NULL) return JSONFailure; for (i = 0; i < json_array_get_count(array); i++) { json_value_free(json_array_get_value(array, i)); } array->count = 0; return JSONSuccess; } JSON_Status json_array_append_value(JSON_Array *array, JSON_Value *value) { if (array == NULL || value == NULL) return JSONFailure; return json_array_add(array, value); } JSON_Status json_array_append_string(JSON_Array *array, const char *string) { JSON_Value *value = json_value_init_string(string); if (value == NULL) return JSONFailure; if (json_array_append_value(array, value) == JSONFailure) { json_value_free(value); return JSONFailure; } return JSONSuccess; } JSON_Status json_array_append_number(JSON_Array *array, double number) { JSON_Value *value = json_value_init_number(number); if (value == NULL) return JSONFailure; if (json_array_append_value(array, value) == JSONFailure) { json_value_free(value); return JSONFailure; } return JSONSuccess; } JSON_Status json_array_append_boolean(JSON_Array *array, int boolean) { JSON_Value *value = json_value_init_boolean(boolean); if (value == NULL) return JSONFailure; if (json_array_append_value(array, value) == JSONFailure) { json_value_free(value); return JSONFailure; } return JSONSuccess; } JSON_Status json_array_append_null(JSON_Array *array) { JSON_Value *value = json_value_init_null(); if (value == NULL) return JSONFailure; if (json_array_append_value(array, value) == JSONFailure) { json_value_free(value); return JSONFailure; } return JSONSuccess; } JSON_Status json_object_set_value(JSON_Object *object, const char *name, JSON_Value *value) { size_t i = 0; JSON_Value *old_value; if (object == NULL || name == NULL || value == NULL) return JSONFailure; old_value = json_object_get_value(object, name); if (old_value != NULL) { /* free and overwrite old value */ json_value_free(old_value); for (i = 0; i < json_object_get_count(object); i++) { if (strcmp(object->names[i], name) == 0) { object->values[i] = value; return JSONSuccess; } } } /* add new key value pair */ return json_object_add(object, name, value); } JSON_Status json_object_set_string(JSON_Object *object, const char *name, const char *string) { return json_object_set_value(object, name, json_value_init_string(string)); } JSON_Status json_object_set_number(JSON_Object *object, const char *name, double number) { return json_object_set_value(object, name, json_value_init_number(number)); } JSON_Status json_object_set_boolean(JSON_Object *object, const char *name, int boolean) { return json_object_set_value(object, name, json_value_init_boolean(boolean)); } JSON_Status json_object_set_null(JSON_Object *object, const char *name) { return json_object_set_value(object, name, json_value_init_null()); } JSON_Status json_object_dotset_value(JSON_Object *object, const char *name, JSON_Value *value) { const char *dot_pos = NULL; const char *current_name = NULL; JSON_Object *temp_obj = NULL; JSON_Value *new_value = NULL; if (value == NULL || name == NULL || value == NULL) return JSONFailure; dot_pos = strchr(name, '.'); if (dot_pos == NULL) { return json_object_set_value(object, name, value); } else { current_name = parson_strndup(name, dot_pos - name); temp_obj = json_object_get_object(object, current_name); if (temp_obj == NULL) { new_value = json_value_init_object(); if (new_value == NULL) { PARSON_FREE(current_name); return JSONFailure; } if (json_object_add(object, current_name, new_value) == JSONFailure) { json_value_free(new_value); PARSON_FREE(current_name); return JSONFailure; } temp_obj = json_object_get_object(object, current_name); } PARSON_FREE(current_name); return json_object_dotset_value(temp_obj, dot_pos + 1, value); } return JSONFailure; } JSON_Status json_object_dotset_string(JSON_Object *object, const char *name, const char *string) { JSON_Value *value = json_value_init_string(string); if (value == NULL) return JSONFailure; if (json_object_dotset_value(object, name, value) == JSONFailure) { json_value_free(value); return JSONFailure; } return JSONSuccess; } JSON_Status json_object_dotset_number(JSON_Object *object, const char *name, double number) { JSON_Value *value = json_value_init_number(number); if (value == NULL) return JSONFailure; if (json_object_dotset_value(object, name, value) == JSONFailure) { json_value_free(value); return JSONFailure; } return JSONSuccess; } JSON_Status json_object_dotset_boolean(JSON_Object *object, const char *name, int boolean) { JSON_Value *value = json_value_init_boolean(boolean); if (value == NULL) return JSONFailure; if (json_object_dotset_value(object, name, value) == JSONFailure) { json_value_free(value); return JSONFailure; } return JSONSuccess; } JSON_Status json_object_dotset_null(JSON_Object *object, const char *name) { JSON_Value *value = json_value_init_null(); if (value == NULL) return JSONFailure; if (json_object_dotset_value(object, name, value) == JSONFailure) { json_value_free(value); return JSONFailure; } return JSONSuccess; } JSON_Status json_object_remove(JSON_Object *object, const char *name) { size_t i = 0, last_item_index = 0; if (object == NULL || json_object_get_value(object, name) == NULL) return JSONFailure; last_item_index = json_object_get_count(object) - 1; for (i = 0; i < json_object_get_count(object); i++) { if (strcmp(object->names[i], name) == 0) { PARSON_FREE(object->names[i]); json_value_free(object->values[i]); if (i != last_item_index) { /* Replace key value pair with one from the end */ object->names[i] = object->names[last_item_index]; object->values[i] = object->values[last_item_index]; } object->count -= 1; return JSONSuccess; } } return JSONFailure; /* No execution path should end here */ } JSON_Status json_object_dotremove(JSON_Object *object, const char *name) { const char *dot_pos = strchr(name, '.'); const char *current_name = NULL; JSON_Object *temp_obj = NULL; if (dot_pos == NULL) { return json_object_remove(object, name); } else { current_name = parson_strndup(name, dot_pos - name); temp_obj = json_object_get_object(object, current_name); if (temp_obj == NULL) { PARSON_FREE(current_name); return JSONFailure; } PARSON_FREE(current_name); return json_object_dotremove(temp_obj, dot_pos + 1); } return JSONFailure; } JSON_Status json_object_clear(JSON_Object *object) { size_t i = 0; if (object == NULL) { return JSONFailure; } for (i = 0; i < json_object_get_count(object); i++) { PARSON_FREE(object->names[i]); json_value_free(object->values[i]); } object->count = 0; return JSONSuccess; } JSON_Status json_validate(const JSON_Value *schema, const JSON_Value *value) { JSON_Value *temp_schema_value = NULL, *temp_value = NULL; JSON_Array *schema_array = NULL, *value_array = NULL; JSON_Object *schema_object = NULL, *value_object = NULL; JSON_Value_Type schema_type = JSONError, value_type = JSONError; const char *key = NULL; size_t i = 0, count = 0; if (schema == NULL || value == NULL) return JSONFailure; schema_type = json_value_get_type(schema); value_type = json_value_get_type(value); if (schema_type != value_type && schema_type != JSONNull) /* null represents all values */ return JSONFailure; switch (schema_type) { case JSONArray: schema_array = json_value_get_array(schema); value_array = json_value_get_array(value); count = json_array_get_count(schema_array); if (count == 0) return JSONSuccess; /* Empty array allows all types */ /* Get first value from array, rest is ignored */ temp_schema_value = json_array_get_value(schema_array, 0); for (i = 0; i < json_array_get_count(value_array); i++) { temp_value = json_array_get_value(value_array, i); if (json_validate(temp_schema_value, temp_value) == 0) { return JSONFailure; } } return JSONSuccess; case JSONObject: schema_object = json_value_get_object(schema); value_object = json_value_get_object(value); count = json_object_get_count(schema_object); if (count == 0) return JSONSuccess; /* Empty object allows all objects */ else if (json_object_get_count(value_object) < count) return JSONFailure; /* Tested object mustn't have less name-value pairs than schema */ for (i = 0; i < count; i++) { key = json_object_get_name(schema_object, i); temp_schema_value = json_object_get_value(schema_object, key); temp_value = json_object_get_value(value_object, key); if (temp_value == NULL) return JSONFailure; if (json_validate(temp_schema_value, temp_value) == JSONFailure) return JSONFailure; } return JSONSuccess; case JSONString: case JSONNumber: case JSONBoolean: case JSONNull: return JSONSuccess; /* equality already tested before switch */ case JSONError: default: return JSONFailure; } } JSON_Status json_value_equals(const JSON_Value *a, const JSON_Value *b) { JSON_Object *a_object = NULL, *b_object = NULL; JSON_Array *a_array = NULL, *b_array = NULL; const char *a_string = NULL, *b_string = NULL; const char *key = NULL; size_t a_count = 0, b_count = 0, i = 0; JSON_Value_Type a_type, b_type; a_type = json_value_get_type(a); b_type = json_value_get_type(b); if (a_type != b_type) { return 0; } switch (a_type) { case JSONArray: a_array = json_value_get_array(a); b_array = json_value_get_array(b); a_count = json_array_get_count(a_array); b_count = json_array_get_count(b_array); if (a_count != b_count) { return 0; } for (i = 0; i < a_count; i++) { if (!json_value_equals(json_array_get_value(a_array, i), json_array_get_value(b_array, i))) { return 0; } } return 1; case JSONObject: a_object = json_value_get_object(a); b_object = json_value_get_object(b); a_count = json_object_get_count(a_object); b_count = json_object_get_count(b_object); if (a_count != b_count) { return 0; } for (i = 0; i < a_count; i++) { key = json_object_get_name(a_object, i); if (!json_value_equals(json_object_get_value(a_object, key), json_object_get_value(b_object, key))) { return 0; } } return 1; case JSONString: a_string = json_value_get_string(a); b_string = json_value_get_string(b); return strcmp(a_string, b_string) == 0; case JSONBoolean: return json_value_get_boolean(a) == json_value_get_boolean(b); case JSONNumber: return fabs(json_value_get_number(a) - json_value_get_number(b)) < 0.000001; /* EPSILON */ case JSONError: return 1; case JSONNull: return 1; default: return 1; } } JSON_Value_Type json_type(const JSON_Value *value) { return json_value_get_type(value); } JSON_Object * json_object (const JSON_Value *value) { return json_value_get_object(value); } JSON_Array * json_array (const JSON_Value *value) { return json_value_get_array(value); } const char * json_string (const JSON_Value *value) { return json_value_get_string(value); } double json_number (const JSON_Value *value) { return json_value_get_number(value); } int json_boolean(const JSON_Value *value) { return json_value_get_boolean(value); } freshplayerplugin-0.3.9/3rdparty/parson/parson.h000066400000000000000000000226651321746453100220340ustar00rootroot00000000000000/* Parson ( http://kgabis.github.com/parson/ ) Copyright (c) 2012 - 2014 Krzysztof Gabis 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 parson_parson_h #define parson_parson_h #ifdef __cplusplus extern "C" { #endif #include /* size_t */ /* Types and enums */ typedef struct json_object_t JSON_Object; typedef struct json_array_t JSON_Array; typedef struct json_value_t JSON_Value; enum json_value_type { JSONError = -1, JSONNull = 1, JSONString = 2, JSONNumber = 3, JSONObject = 4, JSONArray = 5, JSONBoolean = 6 }; typedef int JSON_Value_Type; enum json_result_t { JSONSuccess = 0, JSONFailure = -1 }; typedef int JSON_Status; /* Parses first JSON value in a file, returns NULL in case of error */ JSON_Value * json_parse_file(const char *filename); /* Parses first JSON value in a file and ignores comments (/ * * / and //), returns NULL in case of error */ JSON_Value * json_parse_file_with_comments(const char *filename); /* Parses first JSON value in a string, returns NULL in case of error */ JSON_Value * json_parse_string(const char *string); /* Parses first JSON value in a string and ignores comments (/ * * / and //), returns NULL in case of error */ JSON_Value * json_parse_string_with_comments(const char *string); /* Serialization */ size_t json_serialization_size(const JSON_Value *value); JSON_Status json_serialize_to_buffer(const JSON_Value *value, char *buf, size_t buf_size_in_bytes); JSON_Status json_serialize_to_file(const JSON_Value *value, const char *filename); char * json_serialize_to_string(const JSON_Value *value); void json_free_serialized_string(char *string); /* frees string from json_serialize_to_string */ /* Comparing */ int json_value_equals(const JSON_Value *a, const JSON_Value *b); /* Validation This is *NOT* JSON Schema. It validates json by checking if object have identically named fields with matching types. For example schema {"name":"", "age":0} will validate {"name":"Joe", "age":25} and {"name":"Joe", "age":25, "gender":"m"}, but not {"name":"Joe"} or {"name":"Joe", "age":"Cucumber"}. In case of arrays, only first value in schema is checked against all values in tested array. Empty objects ({}) validate all objects, empty arrays ([]) validate all arrays, null validates values of every type. */ JSON_Status json_validate(const JSON_Value *schema, const JSON_Value *value); /* * JSON Object */ JSON_Value * json_object_get_value (const JSON_Object *object, const char *name); const char * json_object_get_string (const JSON_Object *object, const char *name); JSON_Object * json_object_get_object (const JSON_Object *object, const char *name); JSON_Array * json_object_get_array (const JSON_Object *object, const char *name); double json_object_get_number (const JSON_Object *object, const char *name); /* returns 0 on fail */ int json_object_get_boolean(const JSON_Object *object, const char *name); /* returns -1 on fail */ /* dotget functions enable addressing values with dot notation in nested objects, just like in structs or c++/java/c# objects (e.g. objectA.objectB.value). Because valid names in JSON can contain dots, some values may be inaccessible this way. */ JSON_Value * json_object_dotget_value (const JSON_Object *object, const char *name); const char * json_object_dotget_string (const JSON_Object *object, const char *name); JSON_Object * json_object_dotget_object (const JSON_Object *object, const char *name); JSON_Array * json_object_dotget_array (const JSON_Object *object, const char *name); double json_object_dotget_number (const JSON_Object *object, const char *name); /* returns 0 on fail */ int json_object_dotget_boolean(const JSON_Object *object, const char *name); /* returns -1 on fail */ /* Functions to get available names */ size_t json_object_get_count(const JSON_Object *object); const char * json_object_get_name (const JSON_Object *object, size_t index); /* Creates new name-value pair or frees and replaces old value with new one. */ JSON_Status json_object_set_value(JSON_Object *object, const char *name, JSON_Value *value); JSON_Status json_object_set_string(JSON_Object *object, const char *name, const char *string); JSON_Status json_object_set_number(JSON_Object *object, const char *name, double number); JSON_Status json_object_set_boolean(JSON_Object *object, const char *name, int boolean); JSON_Status json_object_set_null(JSON_Object *object, const char *name); /* Works like dotget functions, but creates whole hierarchy if necessary. */ JSON_Status json_object_dotset_value(JSON_Object *object, const char *name, JSON_Value *value); JSON_Status json_object_dotset_string(JSON_Object *object, const char *name, const char *string); JSON_Status json_object_dotset_number(JSON_Object *object, const char *name, double number); JSON_Status json_object_dotset_boolean(JSON_Object *object, const char *name, int boolean); JSON_Status json_object_dotset_null(JSON_Object *object, const char *name); /* Frees and removes name-value pair */ JSON_Status json_object_remove(JSON_Object *object, const char *name); /* Works like dotget function, but removes name-value pair only on exact match. */ JSON_Status json_object_dotremove(JSON_Object *object, const char *key); /* Removes all name-value pairs in object */ JSON_Status json_object_clear(JSON_Object *object); /* *JSON Array */ JSON_Value * json_array_get_value (const JSON_Array *array, size_t index); const char * json_array_get_string (const JSON_Array *array, size_t index); JSON_Object * json_array_get_object (const JSON_Array *array, size_t index); JSON_Array * json_array_get_array (const JSON_Array *array, size_t index); double json_array_get_number (const JSON_Array *array, size_t index); /* returns 0 on fail */ int json_array_get_boolean(const JSON_Array *array, size_t index); /* returns -1 on fail */ size_t json_array_get_count (const JSON_Array *array); /* Frees and removes value at given index, does nothing and returns JSONFailure if index doesn't exist. * Order of values in array may change during execution. */ JSON_Status json_array_remove(JSON_Array *array, size_t i); /* Frees and removes from array value at given index and replaces it with given one. * Does nothing and returns JSONFailure if index doesn't exist. */ JSON_Status json_array_replace_value(JSON_Array *array, size_t i, JSON_Value *value); JSON_Status json_array_replace_string(JSON_Array *array, size_t i, const char* string); JSON_Status json_array_replace_number(JSON_Array *array, size_t i, double number); JSON_Status json_array_replace_boolean(JSON_Array *array, size_t i, int boolean); JSON_Status json_array_replace_null(JSON_Array *array, size_t i); /* Frees and removes all values from array */ JSON_Status json_array_clear(JSON_Array *array); /* Appends new value at the end of array. */ JSON_Status json_array_append_value(JSON_Array *array, JSON_Value *value); JSON_Status json_array_append_string(JSON_Array *array, const char *string); JSON_Status json_array_append_number(JSON_Array *array, double number); JSON_Status json_array_append_boolean(JSON_Array *array, int boolean); JSON_Status json_array_append_null(JSON_Array *array); /* *JSON Value */ JSON_Value * json_value_init_object (void); JSON_Value * json_value_init_array (void); JSON_Value * json_value_init_string (const char *string); /* copies passed string */ JSON_Value * json_value_init_number (double number); JSON_Value * json_value_init_boolean(int boolean); JSON_Value * json_value_init_null (void); JSON_Value * json_value_deep_copy (const JSON_Value *value); void json_value_free (JSON_Value *value); JSON_Value_Type json_value_get_type (const JSON_Value *value); JSON_Object * json_value_get_object (const JSON_Value *value); JSON_Array * json_value_get_array (const JSON_Value *value); const char * json_value_get_string (const JSON_Value *value); double json_value_get_number (const JSON_Value *value); int json_value_get_boolean(const JSON_Value *value); /* Same as above, but shorter */ JSON_Value_Type json_type (const JSON_Value *value); JSON_Object * json_object (const JSON_Value *value); JSON_Array * json_array (const JSON_Value *value); const char * json_string (const JSON_Value *value); double json_number (const JSON_Value *value); int json_boolean(const JSON_Value *value); #ifdef __cplusplus } #endif #endif freshplayerplugin-0.3.9/3rdparty/parson/tests.c000066400000000000000000000432131321746453100216570ustar00rootroot00000000000000/* Parson ( http://kgabis.github.com/parson/ ) Copyright (c) 2012 - 2014 Krzysztof Gabis 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. */ #ifdef _MSC_VER #define _CRT_SECURE_NO_WARNINGS #endif #include "parson.h" #include #include #include #include #define TEST(A) printf("%-72s-",#A); \ if(A){puts(" OK");tests_passed++;} \ else{puts(" FAIL");tests_failed++;} #define STREQ(A, B) ((A) && (B) ? strcmp((A), (B)) == 0 : 0) #define EPSILON 0.000001 void test_suite_1(void); /* Test 3 files from json.org + serialization*/ void test_suite_2(JSON_Value *value); /* Test correctness of parsed values */ void test_suite_2_no_comments(void); void test_suite_2_with_comments(void); void test_suite_3(void); /* Test incorrect values */ void test_suite_4(void); /* Test deep copy function */ void test_suite_5(void); /* Test building json values from scratch */ void test_suite_6(void); /* Test value comparing verification */ void test_suite_7(void); /* Test schema validation */ void test_suite_8(void); /* Test serialization to file */ void print_commits_info(const char *username, const char *repo); void persistence_example(void); void serialization_example(void); static int tests_passed; static int tests_failed; int main() { /* Example functions from readme file: */ /* print_commits_info("torvalds", "linux"); */ /* serialization_example(); */ /* persistence_example(); */ test_suite_1(); test_suite_2_no_comments(); test_suite_2_with_comments(); test_suite_3(); test_suite_4(); test_suite_5(); test_suite_6(); test_suite_7(); test_suite_8(); printf("Tests failed: %d\n", tests_failed); printf("Tests passed: %d\n", tests_passed); return 0; } void test_suite_1(void) { JSON_Value *val; TEST((val = json_parse_file("tests/test_1_1.txt")) != NULL); TEST(json_value_equals(json_parse_string(json_serialize_to_string(val)), val)); if (val) { json_value_free(val); } TEST((val = json_parse_file("tests/test_1_2.txt")) != NULL); TEST(json_value_equals(json_parse_string(json_serialize_to_string(val)), val)); if (val) { json_value_free(val); } TEST((val = json_parse_file("tests/test_1_3.txt")) != NULL); TEST(json_value_equals(json_parse_string(json_serialize_to_string(val)), val)); if (val) { json_value_free(val); } TEST((val = json_parse_file_with_comments("tests/test_1_1.txt")) != NULL); TEST(json_value_equals(json_parse_string(json_serialize_to_string(val)), val)); if (val) { json_value_free(val); } TEST((val = json_parse_file_with_comments("tests/test_1_2.txt")) != NULL); TEST(json_value_equals(json_parse_string(json_serialize_to_string(val)), val)); if (val) { json_value_free(val); } TEST((val = json_parse_file_with_comments("tests/test_1_3.txt")) != NULL); TEST(json_value_equals(json_parse_string(json_serialize_to_string(val)), val)); if (val) { json_value_free(val); } } void test_suite_2(JSON_Value *root_value) { JSON_Object *root_object; JSON_Array *array; size_t i; TEST(root_value); TEST(json_value_get_type(root_value) == JSONObject); root_object = json_value_get_object(root_value); TEST(STREQ(json_object_get_string(root_object, "string"), "lorem ipsum")); TEST(STREQ(json_object_get_string(root_object, "utf string"), "lorem ipsum")); TEST(STREQ(json_object_get_string(root_object, "utf-8 string"), "あいうえお")); TEST(STREQ(json_object_get_string(root_object, "surrogate string"), "lorem𝄞ipsum𝍧lorem")); TEST(json_object_get_number(root_object, "positive one") == 1.0); TEST(json_object_get_number(root_object, "negative one") == -1.0); TEST(fabs(json_object_get_number(root_object, "hard to parse number") - (-0.000314)) < EPSILON); TEST(json_object_get_boolean(root_object, "boolean true") == 1); TEST(json_object_get_boolean(root_object, "boolean false") == 0); TEST(json_value_get_type(json_object_get_value(root_object, "null")) == JSONNull); array = json_object_get_array(root_object, "string array"); if (array != NULL && json_array_get_count(array) > 1) { TEST(STREQ(json_array_get_string(array, 0), "lorem")); TEST(STREQ(json_array_get_string(array, 1), "ipsum")); } else { tests_failed++; } array = json_object_get_array(root_object, "x^2 array"); if (array != NULL) { for (i = 0; i < json_array_get_count(array); i++) { TEST(json_array_get_number(array, i) == (i * i)); } } else { tests_failed++; } TEST(json_object_get_array(root_object, "non existent array") == NULL); TEST(STREQ(json_object_dotget_string(root_object, "object.nested string"), "str")); TEST(json_object_dotget_boolean(root_object, "object.nested true") == 1); TEST(json_object_dotget_boolean(root_object, "object.nested false") == 0); TEST(json_object_dotget_value(root_object, "object.nested null") != NULL); TEST(json_object_dotget_number(root_object, "object.nested number") == 123); TEST(json_object_dotget_value(root_object, "should.be.null") == NULL); TEST(json_object_dotget_value(root_object, "should.be.null.") == NULL); TEST(json_object_dotget_value(root_object, ".") == NULL); TEST(json_object_dotget_value(root_object, "") == NULL); array = json_object_dotget_array(root_object, "object.nested array"); TEST(array != NULL); TEST(json_array_get_count(array) > 1); if (array != NULL && json_array_get_count(array) > 1) { TEST(STREQ(json_array_get_string(array, 0), "lorem")); TEST(STREQ(json_array_get_string(array, 1), "ipsum")); } TEST(json_object_dotget_boolean(root_object, "nested true")); TEST(STREQ(json_object_get_string(root_object, "/**/"), "comment")); TEST(STREQ(json_object_get_string(root_object, "//"), "comment")); TEST(STREQ(json_object_get_string(root_object, "url"), "https://www.example.com/search?q=12345")); TEST(STREQ(json_object_get_string(root_object, "escaped chars"), "\" \\ /")); } void test_suite_2_no_comments(void) { const char *filename = "tests/test_2.txt"; JSON_Value *root_value = NULL; root_value = json_parse_file(filename); test_suite_2(root_value); TEST(json_value_equals(root_value, json_parse_string(json_serialize_to_string(root_value)))); json_value_free(root_value); } void test_suite_2_with_comments(void) { const char *filename = "tests/test_2_comments.txt"; JSON_Value *root_value = NULL; root_value = json_parse_file_with_comments(filename); test_suite_2(root_value); TEST(json_value_equals(root_value, json_parse_string(json_serialize_to_string(root_value)))); json_value_free(root_value); } void test_suite_3(void) { char nested_20x[] = "[[[[[[[[[[[[[[[[[[[[\"hi\"]]]]]]]]]]]]]]]]]]]]"; puts("Testing invalid strings:"); TEST(json_parse_string(NULL) == NULL); TEST(json_parse_string("") == NULL); /* empty string */ TEST(json_parse_string("[\"lorem\",]") == NULL); TEST(json_parse_string("{\"lorem\":\"ipsum\",}") == NULL); TEST(json_parse_string("{lorem:ipsum}") == NULL); TEST(json_parse_string("[,]") == NULL); TEST(json_parse_string("[,") == NULL); TEST(json_parse_string("[") == NULL); TEST(json_parse_string("]") == NULL); TEST(json_parse_string("{\"a\":0,\"a\":0}") == NULL); /* duplicate keys */ TEST(json_parse_string("{:,}") == NULL); TEST(json_parse_string("{,}") == NULL); TEST(json_parse_string("{,") == NULL); TEST(json_parse_string("{:") == NULL); TEST(json_parse_string("{") == NULL); TEST(json_parse_string("}") == NULL); TEST(json_parse_string("x") == NULL); TEST(json_parse_string("\"string\"") == NULL); TEST(json_parse_string("{:\"no name\"}") == NULL); TEST(json_parse_string("[,\"no first value\"]") == NULL); TEST(json_parse_string("[\"\\u00zz\"]") == NULL); /* invalid utf value */ TEST(json_parse_string("[\"\\u00\"]") == NULL); /* invalid utf value */ TEST(json_parse_string("[\"\\u\"]") == NULL); /* invalid utf value */ TEST(json_parse_string("[\"\\\"]") == NULL); /* control character */ TEST(json_parse_string("[\"\"\"]") == NULL); /* control character */ TEST(json_parse_string("[\"\0\"]") == NULL); /* control character */ TEST(json_parse_string("[\"\a\"]") == NULL); /* control character */ TEST(json_parse_string("[\"\b\"]") == NULL); /* control character */ TEST(json_parse_string("[\"\t\"]") == NULL); /* control character */ TEST(json_parse_string("[\"\n\"]") == NULL); /* control character */ TEST(json_parse_string("[\"\f\"]") == NULL); /* control character */ TEST(json_parse_string("[\"\r\"]") == NULL); /* control character */ TEST(json_parse_string(nested_20x) == NULL); /* too deep */ TEST(json_parse_string("[0x2]") == NULL); /* hex */ TEST(json_parse_string("[0X2]") == NULL); /* HEX */ TEST(json_parse_string("[07]") == NULL); /* octals */ TEST(json_parse_string("[0070]") == NULL); TEST(json_parse_string("[07.0]") == NULL); TEST(json_parse_string("[-07]") == NULL); TEST(json_parse_string("[-007]") == NULL); TEST(json_parse_string("[-07.0]") == NULL); TEST(json_parse_string("[\"\\uDF67\\uD834\"]") == NULL); /* wrong order surrogate pair */ } void test_suite_4() { const char *filename = "tests/test_2.txt"; JSON_Value *a = NULL, *a_copy = NULL; printf("Testing %s:\n", filename); a = json_parse_file(filename); TEST(json_value_equals(a, a)); /* test equality test */ a_copy = json_value_deep_copy(a); TEST(a_copy != NULL); TEST(json_value_equals(a, a_copy)); } void test_suite_5(void) { JSON_Value *val_from_file = json_parse_file("tests/test_5.txt"); JSON_Value *val = NULL; JSON_Object *obj = NULL; JSON_Array *interests_arr = NULL; val = json_value_init_object(); TEST(val != NULL); obj = json_value_get_object(val); TEST(obj != NULL); TEST(json_object_set_string(obj, "first", "John") == JSONSuccess); TEST(json_object_set_string(obj, "last", "Doe") == JSONSuccess); TEST(json_object_set_number(obj, "age", 25) == JSONSuccess); TEST(json_object_set_boolean(obj, "registered", 1) == JSONSuccess); TEST(json_object_set_value(obj, "interests", json_value_init_array()) == JSONSuccess); interests_arr = json_object_get_array(obj, "interests"); TEST(interests_arr != NULL); TEST(json_array_append_string(interests_arr, "Writing") == JSONSuccess); TEST(json_array_append_string(interests_arr, "Mountain Biking") == JSONSuccess); TEST(json_array_replace_string(interests_arr, 0, "Reading") == JSONSuccess); TEST(json_object_dotset_string(obj, "favorites.color", "blue") == JSONSuccess); TEST(json_object_dotset_string(obj, "favorites.sport", "running") == JSONSuccess); TEST(json_object_dotset_string(obj, "favorites.fruit", "apple") == JSONSuccess); TEST(json_object_dotremove(obj, "favorites.fruit") == JSONSuccess); TEST(json_object_set_string(obj, "utf string", "lorem ipsum") == JSONSuccess); TEST(json_object_set_string(obj, "utf-8 string", "あいうえお") == JSONSuccess); TEST(json_object_set_string(obj, "surrogate string", "lorem𝄞ipsum𝍧lorem") == JSONSuccess); TEST(json_object_set_string(obj, "windows path", "C:\\Windows\\Path") == JSONSuccess); TEST(json_value_equals(val_from_file, val)); TEST(json_object_set_string(obj, NULL, "") == JSONFailure); TEST(json_object_set_string(obj, "last", NULL) == JSONFailure); TEST(json_object_set_string(obj, NULL, NULL) == JSONFailure); TEST(json_object_set_value(obj, NULL, NULL) == JSONFailure); TEST(json_object_dotset_string(obj, NULL, "") == JSONFailure); TEST(json_object_dotset_string(obj, "favorites.color", NULL) == JSONFailure); TEST(json_object_dotset_string(obj, NULL, NULL) == JSONFailure); TEST(json_object_dotset_value(obj, NULL, NULL) == JSONFailure); TEST(json_array_append_string(NULL, "lorem") == JSONFailure); TEST(json_array_append_value(interests_arr, NULL) == JSONFailure); TEST(json_array_append_value(NULL, NULL) == JSONFailure); TEST(json_array_remove(NULL, 0) == JSONFailure); TEST(json_array_replace_value(interests_arr, 0, NULL) == JSONFailure); TEST(json_array_replace_string(NULL, 0, "lorem") == JSONFailure); TEST(json_array_replace_string(interests_arr, 100, "not existing") == JSONFailure); TEST(json_array_append_string(json_object_get_array(obj, "interests"), NULL) == JSONFailure); } void test_suite_6(void) { const char *filename = "tests/test_2.txt"; JSON_Value *a = NULL; JSON_Value *b = NULL; a = json_parse_file(filename); b = json_parse_file(filename); TEST(json_value_equals(a, b)); json_object_set_string(json_object(a), "string", "eki"); TEST(!json_value_equals(a, b)); a = json_value_deep_copy(b); TEST(json_value_equals(a, b)); json_array_append_number(json_object_get_array(json_object(b), "string array"), 1337); TEST(!json_value_equals(a, b)); } void test_suite_7(void) { JSON_Value *val_from_file = json_parse_file("tests/test_5.txt"); JSON_Value *schema = json_value_init_object(); JSON_Object *schema_obj = json_value_get_object(schema); json_object_set_string(schema_obj, "first", ""); json_object_set_string(schema_obj, "last", ""); json_object_set_number(schema_obj, "age", 0); json_object_set_null(schema_obj, "favorites"); TEST(json_validate(schema, val_from_file) == JSONSuccess); json_object_set_string(schema_obj, "age", ""); TEST(json_validate(schema, val_from_file) == JSONFailure); } void test_suite_8(void) { const char *filename = "tests/test_2.txt"; const char *temp_filename = "tests/test_2_serialized.txt"; JSON_Value *a = NULL; JSON_Value *b = NULL; a = json_parse_file(filename); TEST(json_serialize_to_file(a, temp_filename) == JSONSuccess); b = json_parse_file(temp_filename); TEST(json_value_equals(a, b)); remove(temp_filename); } void print_commits_info(const char *username, const char *repo) { JSON_Value *root_value; JSON_Array *commits; JSON_Object *commit; size_t i; char curl_command[512]; char cleanup_command[256]; char output_filename[] = "commits.json"; /* it ain't pretty, but it's not a libcurl tutorial */ sprintf(curl_command, "curl -s \"https://api.github.com/repos/%s/%s/commits\" > %s", username, repo, output_filename); sprintf(cleanup_command, "rm -f %s", output_filename); system(curl_command); /* parsing json and validating output */ root_value = json_parse_file(output_filename); if (json_value_get_type(root_value) != JSONArray) { system(cleanup_command); return; } /* getting array from root value and printing commit info */ commits = json_value_get_array(root_value); printf("%-10.10s %-10.10s %s\n", "Date", "SHA", "Author"); for (i = 0; i < json_array_get_count(commits); i++) { commit = json_array_get_object(commits, i); printf("%.10s %.10s %s\n", json_object_dotget_string(commit, "commit.author.date"), json_object_get_string(commit, "sha"), json_object_dotget_string(commit, "commit.author.name")); } /* cleanup code */ json_value_free(root_value); system(cleanup_command); } void persistence_example(void) { JSON_Value *schema = json_parse_string("{\"name\":\"\"}"); JSON_Value *user_data = json_parse_file("user_data.json"); char buf[256]; const char *name = NULL; if (user_data == NULL || json_validate(schema, user_data) != JSONSuccess) { puts("Enter your name:"); scanf("%s", buf); user_data = json_value_init_object(); json_object_set_string(json_object(user_data), "name", buf); json_serialize_to_file(user_data, "user_data.json"); } name = json_object_get_string(json_object(user_data), "name"); printf("Hello, %s.", name); json_value_free(schema); json_value_free(user_data); return; } void serialization_example(void) { JSON_Value *root_value = json_value_init_object(); JSON_Object *root_object = json_value_get_object(root_value); char *serialized_string = NULL; json_object_set_string(root_object, "name", "John Smith"); json_object_set_number(root_object, "age", 25); json_object_dotset_string(root_object, "address.city", "Cupertino"); json_object_dotset_value(root_object, "contact.emails", json_parse_string("[\"email@example.com\", \"email2@example.com\"]")); serialized_string = json_serialize_to_string(root_value); puts(serialized_string); json_free_serialized_string(serialized_string); json_value_free(root_value); } freshplayerplugin-0.3.9/3rdparty/parson/tests/000077500000000000000000000000001321746453100215105ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/parson/tests/test_1_1.txt000066400000000000000000000026441321746453100236760ustar00rootroot00000000000000 [ "JSON Test Pattern pass1", {"object with 1 member":["array with 1 element"]}, {}, [], -42, true, false, null, { "integer": 1234567890, "real": -9876.543210, "e": 0.123456789e-12, "E": 1.234567890E+34, "": 23456789012E66, "zero": 0, "one": 1, "space": " ", "quote": "\"", "backslash": "\\", "controls": "\b\f\n\r\t", "slash": "/ & \/", "alpha": "abcdefghijklmnopqrstuvwyz", "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ", "digit": "0123456789", "0123456789": "digit", "special": "`1~!@#$%^&*()_+-={':[,]}|;.?", "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A", "true": true, "false": false, "null": null, "array":[ ], "object":{ }, "address": "50 St. James Street", "url": "http://www.JSON.org/", "comment": "// /* */": " ", " s p a c e d " :[1,2 , 3 , 4 , 5 , 6 ,7 ],"compact":[1,2,3,4,5,6,7], "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}", "quotes": "" \u0022 %22 0x22 034 "", "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?" : "A key can be any string" }, 0.5 ,98.6 , 99.44 , 1066, 1e1, 0.1e1, 1e-1, 1e00,2e+00,2e-00 ,"rosebud"]freshplayerplugin-0.3.9/3rdparty/parson/tests/test_1_2.txt000066400000000000000000000000641321746453100236710ustar00rootroot00000000000000[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]freshplayerplugin-0.3.9/3rdparty/parson/tests/test_1_3.txt000066400000000000000000000002241321746453100236700ustar00rootroot00000000000000{ "JSON Test Pattern pass3": { "The outermost value": "must be an object or array.", "In this test": "It is an object." } } freshplayerplugin-0.3.9/3rdparty/parson/tests/test_2.txt000066400000000000000000000014441321746453100234540ustar00rootroot00000000000000{ "string" : "lorem ipsum", "utf string" : "\u006corem\u0020ipsum", "utf-8 string": "あいうえお", "surrogate string": "lorem\uD834\uDD1Eipsum\uD834\uDF67lorem", "positive one" : 1, "negative one" : -1, "pi" : 3.14, "hard to parse number" : -3.14e-4, "boolean true" : true, "boolean false" : false, "null" : null, "string array" : ["lorem", "ipsum"], "x^2 array" : [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100], "object_empty" : { }, "/*" : null, "object" : { "nested string" : "str", "nested true" : true, "nested false" : false, "nested null" : null, "nested number" : 123, "nested array" : ["lorem", "ipsum"] }, "*/" : null, "/**/" : "comment", "//" : "comment", "url" : "https:\/\/www.example.com\/search?q=12345", "escaped chars" : "\" \\ \/" } freshplayerplugin-0.3.9/3rdparty/parson/tests/test_2_comments.txt000066400000000000000000000024611321746453100253610ustar00rootroot00000000000000/* *Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor *ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud *dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. */ // Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor { /* lorem ipsum */ "string" : "lorem ipsum", // lorem ipsum "utf string" : "\u006corem\u0020ipsum", // lorem ipsum // "utf-8 string": "あいうえお", // /* lorem ipsum */ "surrogate string": "lorem\uD834\uDD1Eipsum\uD834\uDF67lorem", "positive one" : 1, "negative one" : -1, "pi" : 3.14, "hard to parse number" : -3.14e-4, "boolean true" : true, "boolean false" : false, "null" : null, "string array" : ["lorem",/*in array*/"ipsum"], "x^2 array" : [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100], /* "x^2 array" : [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100], */ "object_empty" : { }, "/*" : null, "object" : { "nested string" : "str", "nested true" : /* lorem ipsum */ true, "nested false" : false, "nested null" : null, // lorem ipsum "nested number" : 123, "nested array" : ["lorem", "ipsum"] }, "*/" : null, "/**/" : "comment", "//" : "comment", "url" : "https:\/\/www.example.com\/search?q=12345", "escaped chars" : "\" \\ \/" } /**/ //freshplayerplugin-0.3.9/3rdparty/parson/tests/test_5.txt000066400000000000000000000005631321746453100234600ustar00rootroot00000000000000{ "first": "John", "last": "Doe", "age": 25, "registered": true, "interests": [ "Reading", "Mountain Biking" ], "favorites": { "color": "blue", "sport": "running" }, "utf string" : "\u006corem\u0020ipsum", "utf-8 string": "あいうえお", "surrogate string": "lorem\uD834\uDD1Eipsum\uD834\uDF67lorem", "windows path": "C:\\Windows\\Path" }freshplayerplugin-0.3.9/3rdparty/ppapi/000077500000000000000000000000001321746453100201555ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/ppapi/LICENSE000066400000000000000000000052301321746453100211620ustar00rootroot00000000000000// Copyright (c) 2012 The Chromium Authors. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* ** Copyright (c) 2007-2010 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including ** without limitation the rights to use, copy, modify, merge, publish, ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are 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 Materials. ** ** THE MATERIALS ARE 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 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/000077500000000000000000000000001321746453100203775ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/000077500000000000000000000000001321746453100211555ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/deprecated_bool.h000066400000000000000000000023771321746453100244520ustar00rootroot00000000000000/* Copyright (c) 2010 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef PPAPI_C_DEV_DEPRECATED_BOOL_H_ #define PPAPI_C_DEV_DEPRECATED_BOOL_H_ /** * @file * Defines the API ... * * @addtogroup PP * @{ */ // TODO(ppapi authors): Remove ppp_class_deprecated.h and ppb_var_deprecated.h // and remove this file. This is only here to ease the transition from // deprecated interfaces to the new ones. Add a usable definition of bool for // C code. #if !defined(__cplusplus) # if defined(_MSC_VER) || !defined(__STDC_VERSION__) || \ (__STDC_VERSION__ < 199901L) // The Visual Studio C compiler and older versions of GCC do not support C99 // and thus have no bool or stdbool.h. Make a simple definition of bool, // true, and false to make this deprecated interface compile in C. Force it // to 1 byte to have some chance of ABI compatibility between C and C++, in // case we don't remove this. typedef char bool; # define false 0 # define true 1 # else // In C99-compliant compilers, we can include stdbool.h to get a bool // definition. # include # endif #endif /** * @} * End addtogroup PP */ #endif /* PPAPI_C_DEV_DEPRECATED_BOOL_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/pp_cursor_type_dev.h000066400000000000000000000040341321746453100252420ustar00rootroot00000000000000/* Copyright (c) 2011 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/pp_cursor_type_dev.idl modified Thu Nov 17 15:27:17 2011. */ #ifndef PPAPI_C_DEV_PP_CURSOR_TYPE_DEV_H_ #define PPAPI_C_DEV_PP_CURSOR_TYPE_DEV_H_ #include "ppapi/c/pp_macros.h" /** * @file * This file defines enumerations for cursor types. */ /** * @addtogroup Enums * @{ */ enum PP_CursorType_Dev { PP_CURSORTYPE_CUSTOM = -1, PP_CURSORTYPE_POINTER = 0, PP_CURSORTYPE_CROSS = 1, PP_CURSORTYPE_HAND = 2, PP_CURSORTYPE_IBEAM = 3, PP_CURSORTYPE_WAIT = 4, PP_CURSORTYPE_HELP = 5, PP_CURSORTYPE_EASTRESIZE = 6, PP_CURSORTYPE_NORTHRESIZE = 7, PP_CURSORTYPE_NORTHEASTRESIZE = 8, PP_CURSORTYPE_NORTHWESTRESIZE = 9, PP_CURSORTYPE_SOUTHRESIZE = 10, PP_CURSORTYPE_SOUTHEASTRESIZE = 11, PP_CURSORTYPE_SOUTHWESTRESIZE = 12, PP_CURSORTYPE_WESTRESIZE = 13, PP_CURSORTYPE_NORTHSOUTHRESIZE = 14, PP_CURSORTYPE_EASTWESTRESIZE = 15, PP_CURSORTYPE_NORTHEASTSOUTHWESTRESIZE = 16, PP_CURSORTYPE_NORTHWESTSOUTHEASTRESIZE = 17, PP_CURSORTYPE_COLUMNRESIZE = 18, PP_CURSORTYPE_ROWRESIZE = 19, PP_CURSORTYPE_MIDDLEPANNING = 20, PP_CURSORTYPE_EASTPANNING = 21, PP_CURSORTYPE_NORTHPANNING = 22, PP_CURSORTYPE_NORTHEASTPANNING = 23, PP_CURSORTYPE_NORTHWESTPANNING = 24, PP_CURSORTYPE_SOUTHPANNING = 25, PP_CURSORTYPE_SOUTHEASTPANNING = 26, PP_CURSORTYPE_SOUTHWESTPANNING = 27, PP_CURSORTYPE_WESTPANNING = 28, PP_CURSORTYPE_MOVE = 29, PP_CURSORTYPE_VERTICALTEXT = 30, PP_CURSORTYPE_CELL = 31, PP_CURSORTYPE_CONTEXTMENU = 32, PP_CURSORTYPE_ALIAS = 33, PP_CURSORTYPE_PROGRESS = 34, PP_CURSORTYPE_NODROP = 35, PP_CURSORTYPE_COPY = 36, PP_CURSORTYPE_NONE = 37, PP_CURSORTYPE_NOTALLOWED = 38, PP_CURSORTYPE_ZOOMIN = 39, PP_CURSORTYPE_ZOOMOUT = 40, PP_CURSORTYPE_GRAB = 41, PP_CURSORTYPE_GRABBING = 42 }; PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_CursorType_Dev, 4); /** * @} */ #endif /* PPAPI_C_DEV_PP_CURSOR_TYPE_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/pp_print_settings_dev.h000066400000000000000000000037151321746453100257450ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/pp_print_settings_dev.idl modified Fri Jan 16 13:30:14 2015. */ #ifndef PPAPI_C_DEV_PP_PRINT_SETTINGS_DEV_H_ #define PPAPI_C_DEV_PP_PRINT_SETTINGS_DEV_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" /** * @file * This file defines the struct for PrintSettings. */ /** * @addtogroup Enums * @{ */ typedef enum { PP_PRINTORIENTATION_NORMAL = 0, PP_PRINTORIENTATION_ROTATED_90_CW = 1, PP_PRINTORIENTATION_ROTATED_180 = 2, PP_PRINTORIENTATION_ROTATED_90_CCW = 3 } PP_PrintOrientation_Dev; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_PrintOrientation_Dev, 4); typedef enum { PP_PRINTOUTPUTFORMAT_RASTER = 1u << 0, PP_PRINTOUTPUTFORMAT_PDF = 1u << 1, PP_PRINTOUTPUTFORMAT_POSTSCRIPT = 1u << 2, PP_PRINTOUTPUTFORMAT_EMF = 1u << 3 } PP_PrintOutputFormat_Dev; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_PrintOutputFormat_Dev, 4); typedef enum { PP_PRINTSCALINGOPTION_NONE = 0, PP_PRINTSCALINGOPTION_FIT_TO_PRINTABLE_AREA = 1, PP_PRINTSCALINGOPTION_SOURCE_SIZE = 2 } PP_PrintScalingOption_Dev; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_PrintScalingOption_Dev, 4); /** * @} */ /** * @addtogroup Structs * @{ */ struct PP_PrintSettings_Dev { /** This is the size of the printable area in points (1/72 of an inch). */ struct PP_Rect printable_area; struct PP_Rect content_area; struct PP_Size paper_size; int32_t dpi; PP_PrintOrientation_Dev orientation; PP_PrintScalingOption_Dev print_scaling_option; PP_Bool grayscale; /** Note that Chrome currently only supports PDF printing. */ PP_PrintOutputFormat_Dev format; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_PrintSettings_Dev, 60); /** * @} */ #endif /* PPAPI_C_DEV_PP_PRINT_SETTINGS_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/pp_video_capture_dev.h000066400000000000000000000032461321746453100255210ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/pp_video_capture_dev.idl modified Mon Nov 14 10:36:01 2011. */ #ifndef PPAPI_C_DEV_PP_VIDEO_CAPTURE_DEV_H_ #define PPAPI_C_DEV_PP_VIDEO_CAPTURE_DEV_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" /** * @file * Structs for dealing with video capture. */ /** * @addtogroup Structs * @{ */ /** * PP_VideoCaptureDeviceInfo_Dev is a structure that represent a video capture * configuration, such as resolution and frame rate. */ struct PP_VideoCaptureDeviceInfo_Dev { uint32_t width; uint32_t height; uint32_t frames_per_second; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoCaptureDeviceInfo_Dev, 12); /** * @} */ /** * @addtogroup Enums * @{ */ /** * PP_VideoCaptureStatus_Dev is an enumeration that defines the various possible * states of a VideoCapture. */ typedef enum { /** * Initial state, capture is stopped. */ PP_VIDEO_CAPTURE_STATUS_STOPPED = 0, /** * StartCapture has been called, but capture hasn't started yet. */ PP_VIDEO_CAPTURE_STATUS_STARTING = 1, /** * Capture has been started. */ PP_VIDEO_CAPTURE_STATUS_STARTED = 2, /** * Capture has been started, but is paused because no buffer is available. */ PP_VIDEO_CAPTURE_STATUS_PAUSED = 3, /** * StopCapture has been called, but capture hasn't stopped yet. */ PP_VIDEO_CAPTURE_STATUS_STOPPING = 4 } PP_VideoCaptureStatus_Dev; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoCaptureStatus_Dev, 4); /** * @} */ #endif /* PPAPI_C_DEV_PP_VIDEO_CAPTURE_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/pp_video_dev.h000066400000000000000000000076711321746453100240040ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/pp_video_dev.idl modified Tue Apr 30 14:58:38 2013. */ #ifndef PPAPI_C_DEV_PP_VIDEO_DEV_H_ #define PPAPI_C_DEV_PP_VIDEO_DEV_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" /** * @file * NOTE: these must be kept in sync with the versions in media/! */ /** * @addtogroup Enums * @{ */ /** * Video format. * * Keep the values in this enum unique, as they imply format (h.264 vs. VP8, * for example), and keep the values for a particular format grouped together * for clarity. * Note: Keep these in sync with media::VideoCodecProfile. */ typedef enum { PP_VIDEODECODER_PROFILE_UNKNOWN = -1, PP_VIDEODECODER_H264PROFILE_NONE = 0, PP_VIDEODECODER_H264PROFILE_BASELINE = 1, PP_VIDEODECODER_H264PROFILE_MAIN = 2, PP_VIDEODECODER_H264PROFILE_EXTENDED = 3, PP_VIDEODECODER_H264PROFILE_HIGH = 4, PP_VIDEODECODER_H264PROFILE_HIGH10PROFILE = 5, PP_VIDEODECODER_H264PROFILE_HIGH422PROFILE = 6, PP_VIDEODECODER_H264PROFILE_HIGH444PREDICTIVEPROFILE = 7, PP_VIDEODECODER_H264PROFILE_SCALABLEBASELINE = 8, PP_VIDEODECODER_H264PROFILE_SCALABLEHIGH = 9, PP_VIDEODECODER_H264PROFILE_STEREOHIGH = 10, PP_VIDEODECODER_H264PROFILE_MULTIVIEWHIGH = 11, PP_VIDEODECODER_VP8PROFILE_ANY = 12 } PP_VideoDecoder_Profile; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoDecoder_Profile, 4); /** * @} */ /** * @addtogroup Structs * @{ */ /** * The data structure for video bitstream buffer. */ struct PP_VideoBitstreamBuffer_Dev { /** * Client-specified identifier for the bitstream buffer. Valid values are * non-negative. */ int32_t id; /** * Buffer to hold the bitstream data. Should be allocated using the * PPB_Buffer interface for consistent interprocess behaviour. */ PP_Resource data; /** * Size of the bitstream contained in buffer (in bytes). */ uint32_t size; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoBitstreamBuffer_Dev, 12); /** * Struct for specifying texture-backed picture data. */ struct PP_PictureBuffer_Dev { /** * Client-specified id for the picture buffer. By using this value client can * keep track of the buffers it has assigned to the video decoder and how they * are passed back to it. Valid values are non-negative. */ int32_t id; /** * Dimensions of the buffer. */ struct PP_Size size; /** * Texture ID in the given context where picture is stored. */ uint32_t texture_id; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_PictureBuffer_Dev, 16); /** * Structure to describe a decoded output frame. */ struct PP_Picture_Dev { /** * ID of the picture buffer where the picture is stored. */ int32_t picture_buffer_id; /** * ID of the bitstream from which this data was decoded. */ int32_t bitstream_buffer_id; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Picture_Dev, 8); /** * @} */ /** * @addtogroup Enums * @{ */ /** * Decoder error codes reported to the plugin. A reasonable naive * error handling policy is for the plugin to Destroy() the decoder on error. */ typedef enum { /** * An operation was attempted during an incompatible decoder state. */ PP_VIDEODECODERERROR_ILLEGAL_STATE = 1, /** * Invalid argument was passed to an API method. */ PP_VIDEODECODERERROR_INVALID_ARGUMENT = 2, /** * Encoded input is unreadable. */ PP_VIDEODECODERERROR_UNREADABLE_INPUT = 3, /** * A failure occurred at the browser layer or lower. Examples of such * failures include GPU hardware failures, GPU driver failures, GPU library * failures, browser programming errors, and so on. */ PP_VIDEODECODERERROR_PLATFORM_FAILURE = 4 } PP_VideoDecodeError_Dev; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoDecodeError_Dev, 4); /** * @} */ #endif /* PPAPI_C_DEV_PP_VIDEO_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_audio_input_dev.h000066400000000000000000000225001321746453100253440ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_audio_input_dev.idl modified Thu Dec 12 15:35:39 2013. */ #ifndef PPAPI_C_DEV_PPB_AUDIO_INPUT_DEV_H_ #define PPAPI_C_DEV_PPB_AUDIO_INPUT_DEV_H_ #include "ppapi/c/dev/ppb_device_ref_dev.h" #include "ppapi/c/pp_array_output.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" #define PPB_AUDIO_INPUT_DEV_INTERFACE_0_3 "PPB_AudioInput(Dev);0.3" #define PPB_AUDIO_INPUT_DEV_INTERFACE_0_4 "PPB_AudioInput(Dev);0.4" #define PPB_AUDIO_INPUT_DEV_INTERFACE PPB_AUDIO_INPUT_DEV_INTERFACE_0_4 /** * @file * This file defines the PPB_AudioInput_Dev interface, which * provides realtime audio input capture. */ /** * @addtogroup Typedefs * @{ */ /** * PPB_AudioInput_Callback defines the type of an audio callback * function used to provide the audio buffer with data. This callback will be * called on a separate thread from the creation thread. * * @param[in] sample_buffer A buffer providing audio input data. * @param[in] buffer_size_in_bytes The size of the buffer in bytes. * @param[in] latency The time that has elapsed since the data was recorded. * @param[inout] user_data An opaque pointer that was passed into * PPB_AudioInput_Dev.Open(). */ typedef void (*PPB_AudioInput_Callback)(const void* sample_buffer, uint32_t buffer_size_in_bytes, PP_TimeDelta latency, void* user_data); typedef void (*PPB_AudioInput_Callback_0_3)(const void* sample_buffer, uint32_t buffer_size_in_bytes, void* user_data); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_AudioInput_Dev interface contains pointers to several * functions for handling audio input resources. * * TODO(brettw) before moving out of dev, we need to resolve the issue of * the mismatch between the current audio config interface and this one. * * In particular, the params for input assume stereo, but this class takes * everything as mono. We either need to not use an audio config resource, or * add mono support. * * In addition, RecommendSampleFrameCount is completely wrong for audio input. * RecommendSampleFrameCount returns the frame count for the current * low-latency output device, which is likely inappropriate for a random input * device. We may want to move the "recommend" functions to the input or output * classes rather than the config. */ struct PPB_AudioInput_Dev_0_4 { /** * Creates an audio input resource. * * @param[in] instance A PP_Instance identifying one instance of * a module. * * @return A PP_Resource corresponding to an audio input resource * if successful, 0 if failed. */ PP_Resource (*Create)(PP_Instance instance); /** * Determines if the given resource is an audio input resource. * * @param[in] resource A PP_Resource containing a resource. * * @return A PP_Bool containing PP_TRUE if the given * resource is an audio input resource, otherwise PP_FALSE. */ PP_Bool (*IsAudioInput)(PP_Resource resource); /** * Enumerates audio input devices. * * @param[in] audio_input A PP_Resource corresponding to an audio * input resource. * @param[in] output An output array which will receive * PPB_DeviceRef_Dev resources on success. Please note that the * ref count of those resources has already been increased by 1 for the * caller. * @param[in] callback A PP_CompletionCallback to run on * completion. * * @return An error code from pp_errors.h. */ int32_t (*EnumerateDevices)(PP_Resource audio_input, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); /** * Requests device change notifications. * * @param[in] audio_input A PP_Resource corresponding to an audio * input resource. * @param[in] callback The callback to receive notifications. If not NULL, it * will be called once for the currently available devices, and then every * time the list of available devices changes. All calls will happen on the * same thread as the one on which MonitorDeviceChange() is called. It will * receive notifications until audio_input is destroyed or * MonitorDeviceChange() is called to set a new callback for * audio_input. You can pass NULL to cancel sending * notifications. * @param[inout] user_data An opaque pointer that will be passed to * callback. * * @return An error code from pp_errors.h. */ int32_t (*MonitorDeviceChange)(PP_Resource audio_input, PP_MonitorDeviceChangeCallback callback, void* user_data); /** * Opens an audio input device. No sound will be captured until * StartCapture() is called. * * @param[in] audio_input A PP_Resource corresponding to an audio * input resource. * @param[in] device_ref Identifies an audio input device. It could be one of * the resource in the array returned by EnumerateDevices(), or 0 which means * the default device. * @param[in] config A PPB_AudioConfig audio configuration * resource. * @param[in] audio_input_callback A PPB_AudioInput_Callback * function that will be called when data is available. * @param[inout] user_data An opaque pointer that will be passed into * audio_input_callback. * @param[in] callback A PP_CompletionCallback to run when this * open operation is completed. * * @return An error code from pp_errors.h. */ int32_t (*Open)(PP_Resource audio_input, PP_Resource device_ref, PP_Resource config, PPB_AudioInput_Callback audio_input_callback, void* user_data, struct PP_CompletionCallback callback); /** * Returns an audio config resource for the given audio input resource. * * @param[in] audio_input A PP_Resource corresponding to an audio * input resource. * * @return A PP_Resource containing the audio config resource if * successful. */ PP_Resource (*GetCurrentConfig)(PP_Resource audio_input); /** * Starts the capture of the audio input resource and begins periodically * calling the callback. * * @param[in] audio_input A PP_Resource corresponding to an audio * input resource. * * @return A PP_Bool containing PP_TRUE if * successful, otherwise PP_FALSE. * Also returns PP_TRUE (and is a no-op) if called while capture * is already started. */ PP_Bool (*StartCapture)(PP_Resource audio_input); /** * Stops the capture of the audio input resource. * * @param[in] audio_input A PP_Resource containing the audio input resource. * * @return A PP_Bool containing PP_TRUE if * successful, otherwise PP_FALSE. * Also returns PP_TRUE (and is a no-op) if called while capture * is already stopped. If a buffer is being captured, StopCapture will block * until the call completes. */ PP_Bool (*StopCapture)(PP_Resource audio_input); /** * Closes the audio input device, and stops capturing if necessary. It is * not valid to call Open() again after a call to this method. * If an audio input resource is destroyed while a device is still open, then * it will be implicitly closed, so you are not required to call this method. * * @param[in] audio_input A PP_Resource corresponding to an audio * input resource. */ void (*Close)(PP_Resource audio_input); }; typedef struct PPB_AudioInput_Dev_0_4 PPB_AudioInput_Dev; struct PPB_AudioInput_Dev_0_3 { PP_Resource (*Create)(PP_Instance instance); PP_Bool (*IsAudioInput)(PP_Resource resource); int32_t (*EnumerateDevices)(PP_Resource audio_input, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); int32_t (*MonitorDeviceChange)(PP_Resource audio_input, PP_MonitorDeviceChangeCallback callback, void* user_data); int32_t (*Open)(PP_Resource audio_input, PP_Resource device_ref, PP_Resource config, PPB_AudioInput_Callback_0_3 audio_input_callback, void* user_data, struct PP_CompletionCallback callback); PP_Resource (*GetCurrentConfig)(PP_Resource audio_input); PP_Bool (*StartCapture)(PP_Resource audio_input); PP_Bool (*StopCapture)(PP_Resource audio_input); void (*Close)(PP_Resource audio_input); }; /** * @} */ #endif /* PPAPI_C_DEV_PPB_AUDIO_INPUT_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_buffer_dev.h000066400000000000000000000034621321746453100243030ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_buffer_dev.idl modified Wed Oct 5 14:06:02 2011. */ #ifndef PPAPI_C_DEV_PPB_BUFFER_DEV_H_ #define PPAPI_C_DEV_PPB_BUFFER_DEV_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_BUFFER_DEV_INTERFACE_0_4 "PPB_Buffer(Dev);0.4" #define PPB_BUFFER_DEV_INTERFACE PPB_BUFFER_DEV_INTERFACE_0_4 /** * @file * This file defines the PPB_Buffer_Dev interface. */ /** * @addtogroup Interfaces * @{ */ struct PPB_Buffer_Dev_0_4 { /** * Allocates a buffer of the given size in bytes. The return value will have * a non-zero ID on success, or zero on failure. Failure means the module * handle was invalid. The buffer will be initialized to contain zeroes. */ PP_Resource (*Create)(PP_Instance instance, uint32_t size_in_bytes); /** * Returns PP_TRUE if the given resource is a Buffer. Returns PP_FALSE if the * resource is invalid or some type other than a Buffer. */ PP_Bool (*IsBuffer)(PP_Resource resource); /** * Gets the size of the buffer. Returns PP_TRUE on success, PP_FALSE * if the resource is not a buffer. On failure, |*size_in_bytes| is not set. */ PP_Bool (*Describe)(PP_Resource resource, uint32_t* size_in_bytes); /** * Maps this buffer into the plugin address space and returns a pointer to * the beginning of the data. */ void* (*Map)(PP_Resource resource); /** * Unmaps this buffer. */ void (*Unmap)(PP_Resource resource); }; typedef struct PPB_Buffer_Dev_0_4 PPB_Buffer_Dev; /** * @} */ #endif /* PPAPI_C_DEV_PPB_BUFFER_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_char_set_dev.h000066400000000000000000000077151321746453100246270ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_ #define PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_CHAR_SET_DEV_INTERFACE_0_4 "PPB_CharSet(Dev);0.4" #define PPB_CHAR_SET_DEV_INTERFACE PPB_CHAR_SET_DEV_INTERFACE_0_4 // Specifies the error behavior for the character set conversion functions. // This will affect two cases: where the input is not encoded correctly, and // when the requested character can not be converted to the destination // character set. enum PP_CharSet_ConversionError { // Causes the entire conversion to fail if an error is encountered. The // conversion function will return NULL. PP_CHARSET_CONVERSIONERROR_FAIL, // Silently skips over errors. Unrepresentable characters and input encoding // errors will be removed from the output. PP_CHARSET_CONVERSIONERROR_SKIP, // Replaces the error or unrepresentable character with a substitution // character. When converting to a Unicode character set (UTF-8 or UTF-16) // it will use the unicode "substitution character" U+FFFD. When converting // to another character set, the character will be charset-specific. For // many languages this will be the representation of the '?' character. PP_CHARSET_CONVERSIONERROR_SUBSTITUTE }; PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_CharSet_ConversionError, 4); struct PPB_CharSet_Dev_0_4 { // Converts the UTF-16 string pointed to in |*utf16| to an 8-bit string in the // specified code page. |utf16_len| is measured in UTF-16 units, not bytes. // This value may not be NULL. // // The return value is a NULL-terminated 8-bit string corresponding to the // new character set, or NULL on failure. THIS STRING MUST BE FREED USING // PPB_Core::MemFree(). The length of the returned string, not including the // terminating NULL, will be placed into *output_length. When there is no // error, the result will always be non-NULL, even if the output is 0-length. // In this case, it will only contain the terminator. You must still call // MemFree any time the return value is non-NULL. // // This function will return NULL if there was an error converting the string // and you requested PP_CHARSET_CONVERSIONERROR_FAIL, or the output character // set was unknown. char* (*UTF16ToCharSet)(PP_Instance instance, const uint16_t* utf16, uint32_t utf16_len, const char* output_char_set, enum PP_CharSet_ConversionError on_error, uint32_t* output_length); // Same as UTF16ToCharSet except converts in the other direction. The input // is in the given charset, and the |input_len| is the number of bytes in // the |input| string. |*output_length| is the number of 16-bit values in // the output not counting the terminating NULL. // // Since UTF16 can represent every Unicode character, the only time the // replacement character will be used is if the encoding in the input string // is incorrect. uint16_t* (*CharSetToUTF16)(PP_Instance instance, const char* input, uint32_t input_len, const char* input_char_set, enum PP_CharSet_ConversionError on_error, uint32_t* output_length); // Returns a string var representing the current multi-byte character set of // the current system. // // WARNING: You really shouldn't be using this function unless you're dealing // with legacy data. You should be using UTF-8 or UTF-16 and you don't have // to worry about the character sets. struct PP_Var (*GetDefaultCharSet)(PP_Instance instance); }; typedef struct PPB_CharSet_Dev_0_4 PPB_CharSet_Dev; #endif /* PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_crypto_dev.h000066400000000000000000000016701321746453100243510ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_crypto_dev.idl modified Wed Nov 7 13:40:08 2012. */ #ifndef PPAPI_C_DEV_PPB_CRYPTO_DEV_H_ #define PPAPI_C_DEV_PPB_CRYPTO_DEV_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #define PPB_CRYPTO_DEV_INTERFACE_0_1 "PPB_Crypto(Dev);0.1" #define PPB_CRYPTO_DEV_INTERFACE PPB_CRYPTO_DEV_INTERFACE_0_1 /** * @file * This file defines the PPB_Crypto_Dev interface. */ /** * @addtogroup Interfaces * @{ */ struct PPB_Crypto_Dev_0_1 { /** * Fills the given buffer with random bytes. This is potentially slow so only * request the amount of data you need. */ void (*GetRandomBytes)(char* buffer, uint32_t num_bytes); }; typedef struct PPB_Crypto_Dev_0_1 PPB_Crypto_Dev; /** * @} */ #endif /* PPAPI_C_DEV_PPB_CRYPTO_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_cursor_control_dev.h000066400000000000000000000055761321746453100261170ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_cursor_control_dev.idl modified Fri Nov 18 15:58:00 2011. */ #ifndef PPAPI_C_DEV_PPB_CURSOR_CONTROL_DEV_H_ #define PPAPI_C_DEV_PPB_CURSOR_CONTROL_DEV_H_ #include "ppapi/c/dev/pp_cursor_type_dev.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_CURSOR_CONTROL_DEV_INTERFACE_0_4 "PPB_CursorControl(Dev);0.4" #define PPB_CURSOR_CONTROL_DEV_INTERFACE PPB_CURSOR_CONTROL_DEV_INTERFACE_0_4 /** * @file * This file defines the PPB_CursorControl_Dev interface * implemented by the browser for controlling the cursor. */ /** * @addtogroup Interfaces * @{ */ struct PPB_CursorControl_Dev_0_4 { /** * Set a cursor. If "type" is PP_CURSORTYPE_CUSTOM, then "custom_image" * must be an ImageData resource containing the cursor and "hot_spot" must * contain the offset within that image that refers to the cursor's position. */ PP_Bool (*SetCursor)(PP_Instance instance, enum PP_CursorType_Dev type, PP_Resource custom_image, const struct PP_Point* hot_spot); /** * This method causes the cursor to be moved to the center of the * instance and be locked, preventing the user from moving it. * The cursor is implicitly hidden from the user while locked. * Cursor lock may only be requested in response to a * PP_InputEvent_MouseDown, and then only if the event was generated via * user gesture. * * While the cursor is locked, any movement of the mouse will * generate a PP_InputEvent_Type_MouseMove, whose x and y values * indicate the position the cursor would have been moved to had * the cursor not been locked, and had the screen been infinite in size. * * The browser may revoke cursor lock for reasons including but not * limited to the user pressing the ESC key, the user activating * another program via a reserved keystroke (e.g., ALT+TAB), or * some other system event. * * Returns PP_TRUE if the cursor could be locked, PP_FALSE otherwise. */ PP_Bool (*LockCursor)(PP_Instance instance); /** * Causes the cursor to be unlocked, allowing it to track user * movement again. */ PP_Bool (*UnlockCursor)(PP_Instance instance); /** * Returns PP_TRUE if the cursor is locked, PP_FALSE otherwise. */ PP_Bool (*HasCursorLock)(PP_Instance instance); /** * Returns PP_TRUE if the cursor can be locked, PP_FALSE otherwise. */ PP_Bool (*CanLockCursor)(PP_Instance instance); }; typedef struct PPB_CursorControl_Dev_0_4 PPB_CursorControl_Dev; /** * @} */ #endif /* PPAPI_C_DEV_PPB_CURSOR_CONTROL_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_device_ref_dev.h000066400000000000000000000056771321746453100251370ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_device_ref_dev.idl modified Wed Nov 07 13:28:37 2012. */ #ifndef PPAPI_C_DEV_PPB_DEVICE_REF_DEV_H_ #define PPAPI_C_DEV_PPB_DEVICE_REF_DEV_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_DEVICEREF_DEV_INTERFACE_0_1 "PPB_DeviceRef(Dev);0.1" #define PPB_DEVICEREF_DEV_INTERFACE PPB_DEVICEREF_DEV_INTERFACE_0_1 /** * @file * This file defines the PPB_DeviceRef_Dev interface. */ /** * @addtogroup Typedefs * @{ */ /** * Defines the callback type to receive device change notifications for * PPB_AudioInput_Dev.MonitorDeviceChange() and * PPB_VideoCapture_Dev.MonitorDeviceChange(). * * @param[inout] user_data The opaque pointer that the caller passed into * MonitorDeviceChange(). * @param[in] device_count How many devices in the array. * @param[in] devices An array of PPB_DeviceRef_Dev. Please note * that the ref count of the elements is not increased on behalf of the plugin. */ typedef void (*PP_MonitorDeviceChangeCallback)(void* user_data, uint32_t device_count, const PP_Resource devices[]); /** * @} */ /** * @addtogroup Enums * @{ */ /** * Device types. */ typedef enum { PP_DEVICETYPE_DEV_INVALID = 0, PP_DEVICETYPE_DEV_AUDIOCAPTURE = 1, PP_DEVICETYPE_DEV_VIDEOCAPTURE = 2 } PP_DeviceType_Dev; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DeviceType_Dev, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ struct PPB_DeviceRef_Dev_0_1 { /** * Determines if the provided resource is a device reference. * * @param[in] resource A PP_Resource corresponding to a generic * resource. * * @return A PP_Bool that is PP_TRUE if the given * resource is a device reference, otherwise PP_FALSE. */ PP_Bool (*IsDeviceRef)(PP_Resource resource); /** * Gets the device type. * * @param[in] device_ref A PP_Resource corresponding to a device * reference. * * @return A PP_DeviceType_Dev value. */ PP_DeviceType_Dev (*GetType)(PP_Resource device_ref); /** * Gets the device name. * * @param[in] device_ref A PP_Resource corresponding to a device * reference. * * @return A PP_Var of type PP_VARTYPE_STRING * containing the name of the device if successful; a PP_Var of * type PP_VARTYPE_UNDEFINED if failed. */ struct PP_Var (*GetName)(PP_Resource device_ref); }; typedef struct PPB_DeviceRef_Dev_0_1 PPB_DeviceRef_Dev; /** * @} */ #endif /* PPAPI_C_DEV_PPB_DEVICE_REF_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_file_chooser_dev.h000066400000000000000000000124711321746453100254730ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_file_chooser_dev.idl modified Mon Jun 4 12:44:29 2012. */ #ifndef PPAPI_C_DEV_PPB_FILE_CHOOSER_DEV_H_ #define PPAPI_C_DEV_PPB_FILE_CHOOSER_DEV_H_ #include "ppapi/c/pp_array_output.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_FILECHOOSER_DEV_INTERFACE_0_5 "PPB_FileChooser(Dev);0.5" #define PPB_FILECHOOSER_DEV_INTERFACE_0_6 "PPB_FileChooser(Dev);0.6" #define PPB_FILECHOOSER_DEV_INTERFACE PPB_FILECHOOSER_DEV_INTERFACE_0_6 /** * @file * This file defines the PPB_FileChooser_Dev interface. */ /** * @addtogroup Enums * @{ */ /** * This enumeration contains constants to control the behavior of the file * chooser dialog. */ typedef enum { /** * Mode for choosing a single existing file. */ PP_FILECHOOSERMODE_OPEN = 0, /** * Mode for choosing multiple existing files. */ PP_FILECHOOSERMODE_OPENMULTIPLE = 1 } PP_FileChooserMode_Dev; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileChooserMode_Dev, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ struct PPB_FileChooser_Dev_0_6 { /** * This function creates a file chooser dialog resource. The chooser is * associated with a particular instance, so that it may be positioned on the * screen relative to the tab containing the instance. * * @param[in] instance A PP_Instance identifying one instance * of a module. * @param[in] mode A PP_FileChooserMode_Dev value that controls * the behavior of the file chooser dialog. * @param[in] accept_types A comma-separated list of MIME types and file * extensions such as "audio/ *,text/plain,.html" (note there should be no * space between the '/' and the '*', but one is added to avoid confusing C++ * comments). The dialog may restrict selectable files to the specified MIME * types and file extensions. If a string in the comma-separated list begins * with a period (.) then the string is interpreted as a file extension, * otherwise it is interpreted as a MIME-type. An empty string or an undefined * var may be given to indicate that all types should be accepted. * * @return A PP_Resource containing the file chooser if * successful or 0 if it could not be created. */ PP_Resource (*Create)(PP_Instance instance, PP_FileChooserMode_Dev mode, struct PP_Var accept_types); /** * Determines if the provided resource is a file chooser. * * @param[in] resource A PP_Resource corresponding to a generic * resource. * * @return A PP_Bool that is PP_TRUE if the given * resource is a file chooser resource, otherwise PP_FALSE. */ PP_Bool (*IsFileChooser)(PP_Resource resource); /** * This function displays a previously created file chooser resource as a * dialog box, prompting the user to choose a file or files. This function * must be called in response to a user gesture, such as a mouse click or * touch event. The callback is called with PP_OK on successful completion * with a file (or files) selected, PP_ERROR_USERCANCEL if the user selected * no file, or another error code from pp_errors.h on failure. * * Subtle note: This function will only work when the tab containing * the plugin is visible. Show() will fail if the tab is in the background. * Since it's not normally possible to get input events while invisible, this * is not normally an issue. But there is a race condition because events are * processed asynchronously. If the user clicks and switches tabs very * quickly, a plugin could believe the tab is visible while Chrome believes * it is invisible and the Show() call will fail. This will not generally * cause user confusion since the user will have switched tabs and will not * want to see a file chooser from a different tab. * * @param[in] chooser The file chooser resource. * * @param[in] output An output array which will receive PP_Resource(s) * identifying the PPB_FileRef objects that the user selected on * success. * * @param[in] callback A CompletionCallback to be called after * the user has closed the file chooser dialog. * * @return PP_OK_COMPLETIONPENDING if request to show the dialog was * successful, another error code from pp_errors.h on failure. */ int32_t (*Show)(PP_Resource chooser, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); }; typedef struct PPB_FileChooser_Dev_0_6 PPB_FileChooser_Dev; struct PPB_FileChooser_Dev_0_5 { PP_Resource (*Create)(PP_Instance instance, PP_FileChooserMode_Dev mode, struct PP_Var accept_types); PP_Bool (*IsFileChooser)(PP_Resource resource); int32_t (*Show)(PP_Resource chooser, struct PP_CompletionCallback callback); PP_Resource (*GetNextChosenFile)(PP_Resource chooser); }; /** * @} */ #endif /* PPAPI_C_DEV_PPB_FILE_CHOOSER_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_font_dev.h000066400000000000000000000230111321746453100237700ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_font_dev.idl modified Thu Mar 28 10:56:39 2013. */ #ifndef PPAPI_C_DEV_PPB_FONT_DEV_H_ #define PPAPI_C_DEV_PPB_FONT_DEV_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_FONT_DEV_INTERFACE_0_6 "PPB_Font(Dev);0.6" #define PPB_FONT_DEV_INTERFACE PPB_FONT_DEV_INTERFACE_0_6 /** * @file * This file defines the PPB_Font_Dev interface. */ /** * @addtogroup Enums * @{ */ typedef enum { /** * Uses the user's default web page font (normally either the default serif * or sans serif font). */ PP_FONTFAMILY_DEFAULT = 0, /** * These families will use the default web page font corresponding to the * given family. */ PP_FONTFAMILY_SERIF = 1, PP_FONTFAMILY_SANSSERIF = 2, PP_FONTFAMILY_MONOSPACE = 3 } PP_FontFamily_Dev; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FontFamily_Dev, 4); /** * Specifies the font weight. Normally users will only use NORMAL or BOLD. */ typedef enum { PP_FONTWEIGHT_100 = 0, PP_FONTWEIGHT_200 = 1, PP_FONTWEIGHT_300 = 2, PP_FONTWEIGHT_400 = 3, PP_FONTWEIGHT_500 = 4, PP_FONTWEIGHT_600 = 5, PP_FONTWEIGHT_700 = 6, PP_FONTWEIGHT_800 = 7, PP_FONTWEIGHT_900 = 8, PP_FONTWEIGHT_NORMAL = PP_FONTWEIGHT_400, PP_FONTWEIGHT_BOLD = PP_FONTWEIGHT_700 } PP_FontWeight_Dev; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FontWeight_Dev, 4); /** * @} */ /** * @addtogroup Structs * @{ */ struct PP_FontDescription_Dev { /** * Font face name as a string. This can also be an undefined var, in which * case the generic family will be obeyed. If the face is not available on * the system, the browser will attempt to do font fallback or pick a default * font. */ struct PP_Var face; /** * When Create()ing a font and the face is an undefined var, the family * specifies the generic font family type to use. If the face is specified, * this will be ignored. * * When Describe()ing a font, the family will be the value you passed in when * the font was created. In other words, if you specify a face name, the * family will not be updated to reflect whether the font name you requested * is serif or sans serif. */ PP_FontFamily_Dev family; /** * Size in pixels. * * You can specify 0 to get the default font size. The default font size * may vary depending on the requested font. The typical example is that * the user may have a different font size for the default monospace font to * give it a similar optical size to the proportionally spaced fonts. */ uint32_t size; /** * Normally you will use either PP_FONTWEIGHT_NORMAL or PP_FONTWEIGHT_BOLD. */ PP_FontWeight_Dev weight; PP_Bool italic; PP_Bool small_caps; /** * Adjustment to apply to letter and word spacing, respectively. Initialize * to 0 to get normal spacing. Negative values bring letters/words closer * together, positive values separate them. */ int32_t letter_spacing; int32_t word_spacing; /** * Ensure that this struct is 48-bytes wide by padding the end. In some * compilers, PP_Var is 8-byte aligned, so those compilers align this struct * on 8-byte boundaries as well and pad it to 16 bytes even without this * padding attribute. This padding makes its size consistent across * compilers. */ int32_t padding; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FontDescription_Dev, 48); struct PP_FontMetrics_Dev { int32_t height; int32_t ascent; int32_t descent; int32_t line_spacing; int32_t x_height; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FontMetrics_Dev, 20); struct PP_TextRun_Dev { /** * This var must either be a string or a null/undefined var (which will be * treated as a 0-length string). */ struct PP_Var text; /** * Set to PP_TRUE if the text is right-to-left. * * When override_direction is false, the browser will perform * the Unicode Bidirectional Algorithm (http://unicode.org/reports/tr9/) on * the text. The value of the rtl flag specifies the * directionality of the surrounding environment. This means that Hebrew * word will always display right to left, even if rtl is false. * * When override_direction is true, no autodetection will be done * and rtl specifies the direction of the text. * * TODO(brettw) note that autodetection with rtl = true is currently * unimplemented. */ PP_Bool rtl; /** * Set to PP_TRUE to force the directionality of the text regardless of * content. * * If this flag is set, the browser will skip autodetection of the content * and will display all text in the direction specified by the * rtl flag. */ PP_Bool override_direction; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_TextRun_Dev, 24); /** * @} */ /** * @addtogroup Interfaces * @{ */ struct PPB_Font_Dev_0_6 { /** * Returns a list of all available font families on the system. You can use * this list to decide whether to Create() a font. * * The return value will be a single string with null characters delimiting * the end of each font name. For example: "Arial\0Courier\0Times\0". * * Returns an undefined var on failure (this typically means you passed an * invalid instance). */ struct PP_Var (*GetFontFamilies)(PP_Instance instance); /** * Returns a font which best matches the given description. The return value * will have a non-zero ID on success, or zero on failure. */ PP_Resource (*Create)(PP_Instance instance, const struct PP_FontDescription_Dev* description); /** * Returns PP_TRUE if the given resource is a Font. Returns PP_FALSE if the * resource is invalid or some type other than a Font. */ PP_Bool (*IsFont)(PP_Resource resource); /** * Loads the description and metrics of the font into the given structures. * The description will be different than the description the font was * created with since it will be filled with the real values from the font * that was actually selected. * * The PP_Var in the description should be of type Void on input. On output, * this will contain the string and will have a reference count of 1. The * plugin is responsible for calling Release on this var. * * Returns PP_TRUE on success, PP_FALSE if the font is invalid or if the Var * in the description isn't Null (to prevent leaks). */ PP_Bool (*Describe)(PP_Resource font, struct PP_FontDescription_Dev* description, struct PP_FontMetrics_Dev* metrics); /** * Draws the text to the image buffer. * * The given point represents the baseline of the left edge of the font, * regardless of whether it is left-to-right or right-to-left (in the case of * RTL text, this will actually represent the logical end of the text). * * The clip is optional and may be NULL. In this case, the text will be * clipped to the image. * * The image_data_is_opaque flag indicates whether subpixel antialiasing can * be performed, if it is supported. When the image below the text is * opaque, subpixel antialiasing is supported and you should set this to * PP_TRUE to pick up the user's default preferences. If your plugin is * partially transparent, then subpixel antialiasing is not possible and * grayscale antialiasing will be used instead (assuming the user has * antialiasing enabled at all). */ PP_Bool (*DrawTextAt)(PP_Resource font, PP_Resource image_data, const struct PP_TextRun_Dev* text, const struct PP_Point* position, uint32_t color, const struct PP_Rect* clip, PP_Bool image_data_is_opaque); /** * Returns the width of the given string. If the font is invalid or the var * isn't a valid string, this will return -1. * * Note that this function handles complex scripts such as Arabic, combining * accents, etc. so that adding the width of substrings won't necessarily * produce the correct width of the entire string. * * Returns -1 on failure. */ int32_t (*MeasureText)(PP_Resource font, const struct PP_TextRun_Dev* text); /** * Returns the character at the given pixel X position from the beginning of * the string. This handles complex scripts such as Arabic, where characters * may be combined or replaced depending on the context. Returns (uint32)-1 * on failure. */ uint32_t (*CharacterOffsetForPixel)(PP_Resource font, const struct PP_TextRun_Dev* text, int32_t pixel_position); /** * Returns the horizontal advance to the given character if the string was * placed at the given position. This handles complex scripts such as Arabic, * where characters may be combined or replaced depending on context. Returns * -1 on error. */ int32_t (*PixelOffsetForCharacter)(PP_Resource font, const struct PP_TextRun_Dev* text, uint32_t char_offset); }; typedef struct PPB_Font_Dev_0_6 PPB_Font_Dev; /** * @} */ #endif /* PPAPI_C_DEV_PPB_FONT_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h000066400000000000000000000045271321746453100311650ustar00rootroot00000000000000// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef PPAPI_C_DEV_PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_H_ #define PPAPI_C_DEV_PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_H_ #include "ppapi/c/pp_resource.h" #include "ppapi/c/ppb_opengles2.h" #define PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE_0_1 \ "PPB_GLESChromiumTextureMapping(Dev);0.1" #define PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE \ PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE_0_1 // PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE is deprecated. Please use // PPB_OPENGLES2_CHROMIUMMAPSUB_INTERFACE instead. #define PPB_OPENGLES2_CHROMIUMMAPSUB_DEV_INTERFACE_1_0 \ "PPB_OpenGLES2ChromiumMapSub(Dev);1.0" // PPB_OPENGLES2_CHROMIUMMAPSUB_DEV_INTERFACE_1_0 is also deprecated. Please // use PPB_OPENGLES2_CHROMIUMMAPSUB_INTERFACE instead. struct PPB_GLESChromiumTextureMapping_Dev_0_1 { // Maps the sub-image of a texture. 'level', 'xoffset', 'yoffset', 'width', // 'height', 'format' and 'type' correspond to the similarly named parameters // of TexSubImage2D, and define the sub-image region, as well as the format of // the data. 'access' must be one of GL_READ_ONLY, GL_WRITE_ONLY or // GL_READ_WRITE. If READ is included, the returned buffer will contain the // pixel data for the sub-image. If WRITE is included, the pixel data for the // sub-image will be updated to the contents of the buffer when // UnmapTexSubImage2DCHROMIUM is called. NOTE: for a GL_WRITE_ONLY map, it // means that all the values of the buffer must be written. void* (*MapTexSubImage2DCHROMIUM)( PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLenum access); // Unmaps the sub-image of a texture. If the sub-image was mapped with one of // the WRITE accesses, the pixels are updated at this time to the contents of // the buffer. 'mem' must be the pointer returned by MapTexSubImage2DCHROMIUM. void (*UnmapTexSubImage2DCHROMIUM)(PP_Resource context, const void* mem); }; typedef struct PPB_GLESChromiumTextureMapping_Dev_0_1 PPB_GLESChromiumTextureMapping_Dev; #endif // PPAPI_C_DEV_PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_H_ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_ime_input_event_dev.h000066400000000000000000000142221321746453100262200ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_ime_input_event_dev.idl modified Wed May 16 17:08:03 2012. */ #ifndef PPAPI_C_DEV_PPB_IME_INPUT_EVENT_DEV_H_ #define PPAPI_C_DEV_PPB_IME_INPUT_EVENT_DEV_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/ppb_input_event.h" #define PPB_IME_INPUT_EVENT_DEV_INTERFACE_0_1 "PPB_IMEInputEvent(Dev);0.1" #define PPB_IME_INPUT_EVENT_DEV_INTERFACE_0_2 "PPB_IMEInputEvent(Dev);0.2" #define PPB_IME_INPUT_EVENT_DEV_INTERFACE PPB_IME_INPUT_EVENT_DEV_INTERFACE_0_2 /** * @file * This file defines the PPB_IMEInputEvent_Dev interface. */ /** * @addtogroup Interfaces * @{ */ struct PPB_IMEInputEvent_Dev_0_2 { /** * Create() creates an IME input event with the given parameters. Normally * you will get an IME event passed through the HandleInputEvent * and will not need to create them, but some applications may want to create * their own for internal use. * * @param[in] instance The instance for which this event occurred. * * @param[in] type A PP_InputEvent_Type identifying the type of * input event. The type must be one of the IME event types. * * @param[in] time_stamp A PP_TimeTicks indicating the time * when the event occurred. * * @param[in] text The string returned by GetText. * * @param[in] segment_number The number returned by * GetSegmentNumber. * * @param[in] segment_offsets The array of numbers returned by * GetSegmentOffset. If segment_number is zero, * the number of elements of the array should be zero. If * segment_number is non-zero, the length of the array must be * segment_number + 1. * * @param[in] target_segment The number returned by * GetTargetSegment. * * @param[in] selection_start The start index returned by * GetSelection. * * @param[in] selection_end The end index returned by * GetSelection. * * @return A PP_Resource containing the new IME input event. */ PP_Resource (*Create)(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, struct PP_Var text, uint32_t segment_number, const uint32_t segment_offsets[], int32_t target_segment, uint32_t selection_start, uint32_t selection_end); /** * IsIMEInputEvent() determines if a resource is an IME event. * * @param[in] resource A PP_Resource corresponding to an event. * * @return PP_TRUE if the given resource is a valid input event. */ PP_Bool (*IsIMEInputEvent)(PP_Resource resource); /** * GetText() returns the composition text as a UTF-8 string for the given IME * event. * * @param[in] ime_event A PP_Resource corresponding to an IME * event. * * @return A string var representing the composition text. For non-IME input * events the return value will be an undefined var. */ struct PP_Var (*GetText)(PP_Resource ime_event); /** * GetSegmentNumber() returns the number of segments in the composition text. * * @param[in] ime_event A PP_Resource corresponding to an IME * event. * * @return The number of segments. For events other than COMPOSITION_UPDATE, * returns 0. */ uint32_t (*GetSegmentNumber)(PP_Resource ime_event); /** * GetSegmentOffset() returns the position of the index-th segmentation point * in the composition text. The position is given by a byte-offset (not a * character-offset) of the string returned by GetText(). It always satisfies * 0=GetSegmentOffset(0) < ... < GetSegmentOffset(i) < GetSegmentOffset(i+1) * < ... < GetSegmentOffset(GetSegmentNumber())=(byte-length of GetText()). * Note that [GetSegmentOffset(i), GetSegmentOffset(i+1)) represents the range * of the i-th segment, and hence GetSegmentNumber() can be a valid argument * to this function instead of an off-by-1 error. * * @param[in] ime_event A PP_Resource corresponding to an IME * event. * * @param[in] index An integer indicating a segment. * * @return The byte-offset of the segmentation point. If the event is not * COMPOSITION_UPDATE or index is out of range, returns 0. */ uint32_t (*GetSegmentOffset)(PP_Resource ime_event, uint32_t index); /** * GetTargetSegment() returns the index of the current target segment of * composition. * * @param[in] ime_event A PP_Resource corresponding to an IME * event. * * @return An integer indicating the index of the target segment. When there * is no active target segment, or the event is not COMPOSITION_UPDATE, * returns -1. */ int32_t (*GetTargetSegment)(PP_Resource ime_event); /** * GetSelection() returns the range selected by caret in the composition text. * * @param[in] ime_event A PP_Resource corresponding to an IME * event. * * @param[out] start The start position of the current selection. * * @param[out] end The end position of the current selection. */ void (*GetSelection)(PP_Resource ime_event, uint32_t* start, uint32_t* end); }; typedef struct PPB_IMEInputEvent_Dev_0_2 PPB_IMEInputEvent_Dev; struct PPB_IMEInputEvent_Dev_0_1 { PP_Bool (*IsIMEInputEvent)(PP_Resource resource); struct PP_Var (*GetText)(PP_Resource ime_event); uint32_t (*GetSegmentNumber)(PP_Resource ime_event); uint32_t (*GetSegmentOffset)(PP_Resource ime_event, uint32_t index); int32_t (*GetTargetSegment)(PP_Resource ime_event); void (*GetSelection)(PP_Resource ime_event, uint32_t* start, uint32_t* end); }; /** * @} */ #endif /* PPAPI_C_DEV_PPB_IME_INPUT_EVENT_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_memory_dev.h000066400000000000000000000025731321746453100243440ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_memory_dev.idl modified Fri Nov 18 15:58:00 2011. */ #ifndef PPAPI_C_DEV_PPB_MEMORY_DEV_H_ #define PPAPI_C_DEV_PPB_MEMORY_DEV_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #define PPB_MEMORY_DEV_INTERFACE_0_1 "PPB_Memory(Dev);0.1" #define PPB_MEMORY_DEV_INTERFACE PPB_MEMORY_DEV_INTERFACE_0_1 /** * @file * This file defines the PPB_Memory interface for functions * related to memory management. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_Memory_Dev interface contains pointers to functions related to memory * management. * */ struct PPB_Memory_Dev_0_1 { /** * MemAlloc is a pointer to a function that allocate memory. * * @param[in] num_bytes A number of bytes to allocate. * @return A pointer to the memory if successful, NULL If the * allocation fails. */ void* (*MemAlloc)(uint32_t num_bytes); /** * MemFree is a pointer to a function that deallocates memory. * * @param[in] ptr A pointer to the memory to deallocate. It is safe to * pass NULL to this function. */ void (*MemFree)(void* ptr); }; typedef struct PPB_Memory_Dev_0_1 PPB_Memory_Dev; /** * @} */ #endif /* PPAPI_C_DEV_PPB_MEMORY_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_opengles2ext_dev.h000066400000000000000000000026051321746453100254470ustar00rootroot00000000000000/* Copyright 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_opengles2ext_dev.idl modified Fri Sep 5 14:52:51 2014. */ #ifndef PPAPI_C_DEV_PPB_OPENGLES2EXT_DEV_H_ #define PPAPI_C_DEV_PPB_OPENGLES2EXT_DEV_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/ppb_opengles2.h" #define PPB_OPENGLES2_DRAWBUFFERS_DEV_INTERFACE_1_0 \ "PPB_OpenGLES2DrawBuffers(Dev);1.0" #define PPB_OPENGLES2_DRAWBUFFERS_DEV_INTERFACE \ PPB_OPENGLES2_DRAWBUFFERS_DEV_INTERFACE_1_0 /** * @file * This file is auto-generated from * gpu/command_buffer/build_gles2_cmd_buffer.py * It's formatted by clang-format using chromium coding style: * clang-format -i -style=chromium filename * DO NOT EDIT! */ #include "ppapi/c/pp_resource.h" #include "ppapi/c/ppb_opengles2.h" /** * @addtogroup Interfaces * @{ */ struct PPB_OpenGLES2DrawBuffers_Dev_1_0 { void (*DrawBuffersEXT)(PP_Resource context, GLsizei count, const GLenum* bufs); }; struct PPB_OpenGLES2DrawBuffers_Dev { void (*DrawBuffersEXT)(PP_Resource context, GLsizei count, const GLenum* bufs); }; /** * @} */ #endif /* PPAPI_C_DEV_PPB_OPENGLES2EXT_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_printing_dev.h000066400000000000000000000041051321746453100246570ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_printing_dev.idl modified Fri Apr 19 10:45:09 2013. */ #ifndef PPAPI_C_DEV_PPB_PRINTING_DEV_H_ #define PPAPI_C_DEV_PPB_PRINTING_DEV_H_ #include "ppapi/c/dev/pp_print_settings_dev.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #define PPB_PRINTING_DEV_INTERFACE_0_7 "PPB_Printing(Dev);0.7" #define PPB_PRINTING_DEV_INTERFACE PPB_PRINTING_DEV_INTERFACE_0_7 /** * @file * Definition of the PPB_Printing interface. */ /** * @addtogroup Interfaces * @{ */ struct PPB_Printing_Dev_0_7 { /** Create a resource for accessing printing functionality. * * @param[in] instance A PP_Instance identifying one instance * of a module. * * @return A PP_Resource containing the printing resource if * successful or 0 if it could not be created. */ PP_Resource (*Create)(PP_Instance instance); /** * Outputs the default print settings for the default printer into * print_settings. The callback is called with * PP_OK when the settings have been retrieved successfully. * * @param[in] resource The printing resource. * * @param[in] callback A CompletionCallback to be called when * print_settings have been retrieved. * * @return PP_OK_COMPLETIONPENDING if request for the default print settings * was successful, another error code from pp_errors.h on failure. */ int32_t (*GetDefaultPrintSettings)( PP_Resource resource, struct PP_PrintSettings_Dev* print_settings, struct PP_CompletionCallback callback); }; typedef struct PPB_Printing_Dev_0_7 PPB_Printing_Dev; /** * @} */ #endif /* PPAPI_C_DEV_PPB_PRINTING_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_text_input_dev.h000066400000000000000000000122721321746453100252340ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_text_input_dev.idl modified Tue Aug 6 10:37:25 2013. */ #ifndef PPAPI_C_DEV_PPB_TEXT_INPUT_DEV_H_ #define PPAPI_C_DEV_PPB_TEXT_INPUT_DEV_H_ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #define PPB_TEXTINPUT_DEV_INTERFACE_0_1 "PPB_TextInput(Dev);0.1" #define PPB_TEXTINPUT_DEV_INTERFACE_0_2 "PPB_TextInput(Dev);0.2" #define PPB_TEXTINPUT_DEV_INTERFACE PPB_TEXTINPUT_DEV_INTERFACE_0_2 /** * @file * This file defines the PPB_TextInput_Dev interface. */ /** * @addtogroup Enums * @{ */ /** * PP_TextInput_Type is used to indicate the status of a plugin in regard to * text input. */ typedef enum { /** * Input caret is not in an editable mode, no input method shall be used. */ PP_TEXTINPUT_TYPE_DEV_NONE = 0, /** * Input caret is in a normal editable mode, any input method can be used. */ PP_TEXTINPUT_TYPE_DEV_TEXT = 1, /** * Input caret is in a password box, an input method may be used only if * it's suitable for password input. */ PP_TEXTINPUT_TYPE_DEV_PASSWORD = 2, PP_TEXTINPUT_TYPE_DEV_SEARCH = 3, PP_TEXTINPUT_TYPE_DEV_EMAIL = 4, PP_TEXTINPUT_TYPE_DEV_NUMBER = 5, PP_TEXTINPUT_TYPE_DEV_TELEPHONE = 6, PP_TEXTINPUT_TYPE_DEV_URL = 7 } PP_TextInput_Type_Dev; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TextInput_Type_Dev, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * PPB_TextInput_Dev provides a set of functions for giving hints * to the browser about the text input status of plugins, and functions for * controlling input method editors (IMEs). */ struct PPB_TextInput_Dev_0_2 { /** * Informs the browser about the current text input mode of the plugin. * Typical use of this information in the browser is to properly * display/suppress tools for supporting text inputs (such as virtual * keyboards in touch screen based devices, or input method editors often * used for composing East Asian characters). */ void (*SetTextInputType)(PP_Instance instance, PP_TextInput_Type_Dev type); /** * Informs the browser about the coordinates of the text input caret and the * bounding box of the text input area. Typical use of this information in * the browser is to layout IME windows etc. */ void (*UpdateCaretPosition)(PP_Instance instance, const struct PP_Rect* caret, const struct PP_Rect* bounding_box); /** * Cancels the current composition in IME. */ void (*CancelCompositionText)(PP_Instance instance); /** * In response to the PPP_TextInput_Dev::RequestSurroundingText * call, informs the browser about the current text selection and surrounding * text. text is a UTF-8 string that contains the current range * of text selection in the plugin. caret is the byte-index of * the caret position within text. anchor is the * byte-index of the anchor position (i.e., if a range of text is selected, * it is the other edge of selection different from caret. If * there are no selection, anchor is equal to caret. * * Typical use of this information in the browser is to enable "reconversion" * features of IME that puts back the already committed text into the * pre-commit composition state. Another use is to improve the precision * of suggestion of IME by taking the context into account (e.g., if the caret * looks to be on the beginning of a sentence, suggest capital letters in a * virtual keyboard). * * When the focus is not on text, call this function setting text * to an empty string and caret and anchor to zero. * Also, the plugin should send the empty text when it does not want to reveal * the selection to IME (e.g., when the surrounding text is containing * password text). */ void (*UpdateSurroundingText)(PP_Instance instance, const char* text, uint32_t caret, uint32_t anchor); /** * Informs the browser when a range of text selection is changed in a plugin. * When the browser needs to know the content of the updated selection, it * pings back by PPP_TextInput_Dev::RequestSurroundingText. The * plugin then should send the information with * UpdateSurroundingText. */ void (*SelectionChanged)(PP_Instance instance); }; typedef struct PPB_TextInput_Dev_0_2 PPB_TextInput_Dev; struct PPB_TextInput_Dev_0_1 { void (*SetTextInputType)(PP_Instance instance, PP_TextInput_Type_Dev type); void (*UpdateCaretPosition)(PP_Instance instance, const struct PP_Rect* caret, const struct PP_Rect* bounding_box); void (*CancelCompositionText)(PP_Instance instance); }; /** * @} */ #endif /* PPAPI_C_DEV_PPB_TEXT_INPUT_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_trace_event_dev.h000066400000000000000000000103561321746453100253310ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_trace_event_dev.idl modified Tue Jun 25 16:12:08 2013. */ #ifndef PPAPI_C_DEV_PPB_TRACE_EVENT_DEV_H_ #define PPAPI_C_DEV_PPB_TRACE_EVENT_DEV_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #define PPB_TRACE_EVENT_DEV_INTERFACE_0_1 "PPB_Trace_Event(Dev);0.1" #define PPB_TRACE_EVENT_DEV_INTERFACE_0_2 "PPB_Trace_Event(Dev);0.2" #define PPB_TRACE_EVENT_DEV_INTERFACE PPB_TRACE_EVENT_DEV_INTERFACE_0_2 /** * @file * This file defines the PPB_Trace_Event interface. It is meant * to be used in plugins as the API that trace macros from trace_event.h use. */ /** * @addtogroup Typedefs * @{ */ /** * A trace event timestamp. */ typedef int64_t PP_TraceEventTime; /** * @} */ /** * @addtogroup Interfaces * @{ */ struct PPB_Trace_Event_Dev_0_2 { /** * Gets a pointer to a character for identifying a category name in the * tracing system as well as for being able to early exit in client-side * tracing code. * * NB: This mem_t return value should technically be const, but return values * for Pepper IDL of mem_t type are not const. The same is true for the arg * |category_enabled| for AddTraceEvent. */ void* (*GetCategoryEnabled)(const char* category_name); /** * Adds a trace event to the platform tracing system. This function call is * usually the result of a TRACE_* macro from trace_event.h when tracing and * the category of the particular trace are enabled. It is not advisable to * call this function on its own; it is really only meant to be used by the * trace macros. */ void (*AddTraceEvent)(int8_t phase, const void* category_enabled, const char* name, uint64_t id, uint32_t num_args, const char* arg_names[], const uint8_t arg_types[], const uint64_t arg_values[], uint8_t flags); /** * Version of the above interface that allows specifying a custom thread id * and timestamp. This is useful for when tracing data cannot be registered * in real time. For example, this could be used by storing timestamps * internally and then registering the events retroactively. */ void (*AddTraceEventWithThreadIdAndTimestamp)(int8_t phase, const void* category_enabled, const char* name, uint64_t id, int32_t thread_id, PP_TraceEventTime timestamp, uint32_t num_args, const char* arg_names[], const uint8_t arg_types[], const uint64_t arg_values[], uint8_t flags); /** * Get the current clock value. Since this uses the same function as the trace * events use internally, it can be used to create events with explicit time * stamps. */ PP_TraceEventTime (*Now)(void); /** * Sets the thread name of the calling thread in the tracing system so it will * show up properly in chrome://tracing. */ void (*SetThreadName)(const char* thread_name); }; typedef struct PPB_Trace_Event_Dev_0_2 PPB_Trace_Event_Dev; struct PPB_Trace_Event_Dev_0_1 { void* (*GetCategoryEnabled)(const char* category_name); void (*AddTraceEvent)(int8_t phase, const void* category_enabled, const char* name, uint64_t id, uint32_t num_args, const char* arg_names[], const uint8_t arg_types[], const uint64_t arg_values[], uint8_t flags); void (*SetThreadName)(const char* thread_name); }; /** * @} */ #endif /* PPAPI_C_DEV_PPB_TRACE_EVENT_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_truetype_font_dev.h000066400000000000000000000260571321746453100257460ustar00rootroot00000000000000/* Copyright (c) 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_truetype_font_dev.idl modified Tue Oct 15 05:52:52 2013. */ #ifndef PPAPI_C_DEV_PPB_TRUETYPE_FONT_DEV_H_ #define PPAPI_C_DEV_PPB_TRUETYPE_FONT_DEV_H_ #include "ppapi/c/pp_array_output.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_TRUETYPEFONT_DEV_INTERFACE_0_1 "PPB_TrueTypeFont(Dev);0.1" #define PPB_TRUETYPEFONT_DEV_INTERFACE PPB_TRUETYPEFONT_DEV_INTERFACE_0_1 /** * @file * This file defines the PPB_TrueTypeFont_Dev interface. This * interface exposes font table data for 'sfnt' fonts on the host system. These * include TrueType and OpenType fonts. */ /** * @addtogroup Enums * @{ */ /** * The PP_TrueTypeFontFamily_Dev defines generic font families. These can be * used to create generic fonts consistent with the user's browser settings. */ typedef enum { /** * For a description of these default families, see the * * 3.1.1 Generic font families documentation. */ PP_TRUETYPEFONTFAMILY_SERIF = 0, PP_TRUETYPEFONTFAMILY_SANSSERIF = 1, PP_TRUETYPEFONTFAMILY_CURSIVE = 2, PP_TRUETYPEFONTFAMILY_FANTASY = 3, PP_TRUETYPEFONTFAMILY_MONOSPACE = 4 } PP_TrueTypeFontFamily_Dev; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TrueTypeFontFamily_Dev, 4); /** * The PP_TrueTypeFontStyle_Dev enum defines font styles. */ typedef enum { PP_TRUETYPEFONTSTYLE_NORMAL = 0, PP_TRUETYPEFONTSTYLE_ITALIC = 1 } PP_TrueTypeFontStyle_Dev; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TrueTypeFontStyle_Dev, 4); /** * The PP_TrueTypeFontWeight_Dev enum defines font weights. */ typedef enum { PP_TRUETYPEFONTWEIGHT_THIN = 100, PP_TRUETYPEFONTWEIGHT_ULTRALIGHT = 200, PP_TRUETYPEFONTWEIGHT_LIGHT = 300, PP_TRUETYPEFONTWEIGHT_NORMAL = 400, PP_TRUETYPEFONTWEIGHT_MEDIUM = 500, PP_TRUETYPEFONTWEIGHT_SEMIBOLD = 600, PP_TRUETYPEFONTWEIGHT_BOLD = 700, PP_TRUETYPEFONTWEIGHT_ULTRABOLD = 800, PP_TRUETYPEFONTWEIGHT_HEAVY = 900 } PP_TrueTypeFontWeight_Dev; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TrueTypeFontWeight_Dev, 4); /** * The PP_TrueTypeFontWidth_Dev enum defines font widths. */ typedef enum { PP_TRUETYPEFONTWIDTH_ULTRACONDENSED = 0, PP_TRUETYPEFONTWIDTH_EXTRACONDENSED = 1, PP_TRUETYPEFONTWIDTH_CONDENSED = 2, PP_TRUETYPEFONTWIDTH_SEMICONDENSED = 3, PP_TRUETYPEFONTWIDTH_NORMAL = 4, PP_TRUETYPEFONTWIDTH_SEMIEXPANDED = 5, PP_TRUETYPEFONTWIDTH_EXPANDED = 6, PP_TRUETYPEFONTWIDTH_EXTRAEXPANDED = 7, PP_TRUETYPEFONTWIDTH_ULTRAEXPANDED = 8 } PP_TrueTypeFontWidth_Dev; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TrueTypeFontWidth_Dev, 4); /** * The PP_TrueTypeFontCharset enum defines font character sets. */ typedef enum { PP_TRUETYPEFONTCHARSET_ANSI = 0, PP_TRUETYPEFONTCHARSET_DEFAULT = 1, PP_TRUETYPEFONTCHARSET_SYMBOL = 2, PP_TRUETYPEFONTCHARSET_MAC = 77, PP_TRUETYPEFONTCHARSET_SHIFTJIS = 128, PP_TRUETYPEFONTCHARSET_HANGUL = 129, PP_TRUETYPEFONTCHARSET_JOHAB = 130, PP_TRUETYPEFONTCHARSET_GB2312 = 134, PP_TRUETYPEFONTCHARSET_CHINESEBIG5 = 136, PP_TRUETYPEFONTCHARSET_GREEK = 161, PP_TRUETYPEFONTCHARSET_TURKISH = 162, PP_TRUETYPEFONTCHARSET_VIETNAMESE = 163, PP_TRUETYPEFONTCHARSET_HEBREW = 177, PP_TRUETYPEFONTCHARSET_ARABIC = 178, PP_TRUETYPEFONTCHARSET_BALTIC = 186, PP_TRUETYPEFONTCHARSET_RUSSIAN = 204, PP_TRUETYPEFONTCHARSET_THAI = 222, PP_TRUETYPEFONTCHARSET_EASTEUROPE = 238, PP_TRUETYPEFONTCHARSET_OEM = 255 } PP_TrueTypeFontCharset_Dev; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TrueTypeFontCharset_Dev, 4); /** * @} */ /** * @addtogroup Structs * @{ */ /** * The PP_TrueTypeFontDesc struct describes a TrueType font. It is * passed to Create(), and returned by Describe(). */ struct PP_TrueTypeFontDesc_Dev { /** * Font family name as a string. This can also be an undefined var, in which * case the generic family will be obeyed. If the face is not available on * the system, the browser will attempt to do font fallback or pick a default * font. */ struct PP_Var family; /** This value specifies a generic font family. If a family name string is * provided when creating a font, this is ignored. */ PP_TrueTypeFontFamily_Dev generic_family; /** This value specifies the font style. */ PP_TrueTypeFontStyle_Dev style; /** This value specifies the font weight. */ PP_TrueTypeFontWeight_Dev weight; /** This value specifies the font width, for condensed or expanded fonts */ PP_TrueTypeFontWidth_Dev width; /** This value specifies a character set. */ PP_TrueTypeFontCharset_Dev charset; /** * Ensure that this struct is 40-bytes wide by padding the end. In some * compilers, PP_Var is 8-byte aligned, so those compilers align this struct * on 8-byte boundaries as well and pad it to 16 bytes even without this * padding attribute. This padding makes its size consistent across * compilers. */ int32_t padding; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_TrueTypeFontDesc_Dev, 40); /** * @} */ /** * @addtogroup Interfaces * @{ */ struct PPB_TrueTypeFont_Dev_0_1 { /** * Gets an array of TrueType font family names available on the host. * These names can be used to create a font from a specific family. * * @param[in] instance A PP_Instance requesting the family names. * @param[in] output A PP_ArrayOutput to hold the names. * The output is an array of PP_Vars, each holding a family name. * @param[in] callback A PP_CompletionCallback to be called upon * completion of GetFontFamilies. * * @return If >= 0, the number of family names returned, otherwise an error * code from pp_errors.h. */ int32_t (*GetFontFamilies)(PP_Instance instance, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); /** * Gets an array of TrueType font descriptors for a given font family. These * descriptors can be used to create a font in that family and matching the * descriptor attributes. * * @param[in] instance A PP_Instance requesting the font * descriptors. * @param[in] family A PP_Var holding a string specifying the * font family. * @param[in] output A PP_ArrayOutput to hold the descriptors. * The output is an array of PP_TrueTypeFontDesc structs. Each * desc contains a PP_Var for the family name which must be released. * @param[in] callback A PP_CompletionCallback to be called upon * completion of GetFontsInFamily. * * @return If >= 0, the number of font descriptors returned, otherwise an * error code from pp_errors.h. */ int32_t (*GetFontsInFamily)(PP_Instance instance, struct PP_Var family, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); /** * Creates a font resource matching the given font characteristics. The * resource id will be non-zero on success, or zero on failure. * * @param[in] instance A PP_Instance to own the font. * @param[in] desc A pointer to a PP_TrueTypeFontDesc describing * the font. */ PP_Resource (*Create)(PP_Instance instance, const struct PP_TrueTypeFontDesc_Dev* desc); /** * Determines if the given resource is a TrueType font. * * @param[in] resource A PP_Resource corresponding to a resource. * * @return PP_TRUE if the resource is a * PPB_TrueTypeFont_Dev, PP_FALSE otherwise. */ PP_Bool (*IsTrueTypeFont)(PP_Resource resource); /** * Returns a description of the given font resource. This description may * differ from the description passed to Create, reflecting the host's font * matching and fallback algorithm. * * @param[in] font A PP_Resource corresponding to a font. * @param[out] desc A pointer to a PP_TrueTypeFontDesc to hold * the description. The internal 'family' PP_Var should be set to undefined, * since this function overwrites the PP_TrueTypeFontDesc. After * successful completion, the family will be set to a PP_Var with a single * reference, which the caller must release after use. * @param[in] callback A PP_CompletionCallback to be called upon * completion of Describe. * * @return A return code from pp_errors.h. If an error code is * returned, the PP_TrueTypeFontDesc will be unchanged. */ int32_t (*Describe)(PP_Resource font, struct PP_TrueTypeFontDesc_Dev* desc, struct PP_CompletionCallback callback); /** * Gets an array of identifying tags for each table in the font. These tags * can be used to request specific tables using GetTable. * * @param[in] font A PP_Resource corresponding to a font. * @param[in] output A PP_ArrayOutput to hold the tags. * The output is an array of 4 byte integers, each representing a table tag. * @param[in] callback A PP_CompletionCallback to be called upon * completion of GetTableTags. * * @return If >= 0, the number of table tags returned, otherwise an error * code from pp_errors.h. */ int32_t (*GetTableTags)(PP_Resource font, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); /** * Copies the given font table into client memory. * * @param[in] font A PP_Resource corresponding to a font. * @param[in] table A 4 byte value indicating which table to copy. * For example, 'glyf' will cause the outline table to be copied into the * output array. A zero tag value will cause the entire font to be copied. * @param[in] offset The offset into the font table. Passing an offset * greater than or equal to the table size will succeed with 0 bytes copied. * @param[in] max_data_length The maximum number of bytes to transfer from * offset. * @param[in] output A PP_ArrayOutput to hold the font data. * The output is an array of bytes. * @param[in] callback A PP_CompletionCallback to be called upon * completion of GetTable. * * @return If >= 0, the table size in bytes, otherwise an error code from * pp_errors.h. */ int32_t (*GetTable)(PP_Resource font, uint32_t table, int32_t offset, int32_t max_data_length, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); }; typedef struct PPB_TrueTypeFont_Dev_0_1 PPB_TrueTypeFont_Dev; /** * @} */ #endif /* PPAPI_C_DEV_PPB_TRUETYPE_FONT_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_url_util_dev.h000066400000000000000000000205621321746453100246710ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_url_util_dev.idl modified Wed Aug 28 19:09:17 2013. */ #ifndef PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_ #define PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_URLUTIL_DEV_INTERFACE_0_6 "PPB_URLUtil(Dev);0.6" #define PPB_URLUTIL_DEV_INTERFACE_0_7 "PPB_URLUtil(Dev);0.7" #define PPB_URLUTIL_DEV_INTERFACE PPB_URLUTIL_DEV_INTERFACE_0_7 /** * @file * This file defines the PPB_URLUtil_Dev interface. */ /** * @addtogroup Structs * @{ */ /* * A component specifies the range of the part of the URL. The begin specifies * the index into the string of the first character of that component. The len * specifies the length of that component. * * This range does not include any special delimiter for that component, so * the scheme doesn't include the trailing colon, the username and password * don't include the @ and :, the port doesn't include the colon, the query * doesn't include the ?, and the ref doesn't include the #. * * The exception is that the path *does* include the first /, since that's an * integral part of the path. * * If the component is not present at all, begin will be 0 and len will be -1. * If the component is present but empty, the length will be 0 instead. Example: * http://foo/search -> query = (0, -1) * http://foo/search? -> query = (18, 0) */ struct PP_URLComponent_Dev { int32_t begin; int32_t len; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_URLComponent_Dev, 8); struct PP_URLComponents_Dev { struct PP_URLComponent_Dev scheme; struct PP_URLComponent_Dev username; struct PP_URLComponent_Dev password; struct PP_URLComponent_Dev host; struct PP_URLComponent_Dev port; struct PP_URLComponent_Dev path; struct PP_URLComponent_Dev query; struct PP_URLComponent_Dev ref; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_URLComponents_Dev, 64); /** * @} */ /** * @addtogroup Interfaces * @{ */ /* * URL encoding: URLs are supplied to this interface as NULL-terminated 8-bit * strings. You can pass non-ASCII characters which will be interpreted as * UTF-8. Canonicalized URL strings returned by these functions will be ASCII * except for the reference fragment (stuff after the '#') which will be * encoded as UTF-8. */ struct PPB_URLUtil_Dev_0_7 { /* * Canonicalizes the given URL string according to the rules of the host * browser. If the URL is invalid or the var is not a string, this will * return a Null var and the components structure will be unchanged. * * The components pointer, if non-NULL and the canonicalized URL is valid, * will identify the components of the resulting URL. Components may be NULL * to specify that no component information is necessary. */ struct PP_Var (*Canonicalize)(struct PP_Var url, struct PP_URLComponents_Dev* components); /* * Resolves the given URL relative to the given base URL. The resulting URL * is returned as a string. If the resolution is invalid or either of the * inputs are not strings, a Null var will be returned. The resulting URL * will also be canonicalized according to the rules of the browser. * * Note that the "relative" URL may in fact be absolute, in which case it * will be returned. This function is identical to resolving the full URL * for an on a web page. Attempting to resolve a relative URL * on a base URL that doesn't support this (e.g. "data") will fail and will * return a Null var, unless the relative URL is itself absolute. * * The components pointer, if non-NULL and the canonicalized URL is valid, * will identify the components of the resulting URL. Components may be NULL * to specify that no component information is necessary. */ struct PP_Var (*ResolveRelativeToURL)( struct PP_Var base_url, struct PP_Var relative_string, struct PP_URLComponents_Dev* components); /* * Identical to ResolveRelativeToURL except that the base URL is the base * URL of the document containing the given plugin instance. * * Danger: This will be identical to resolving a relative URL on the page, * and might be overridden by the page to something different than its actual * URL via the tag. Therefore, resolving a relative URL of "" won't * necessarily give you the URL of the page! */ struct PP_Var (*ResolveRelativeToDocument)( PP_Instance instance, struct PP_Var relative_string, struct PP_URLComponents_Dev* components); /* * Checks whether the given two URLs are in the same security origin. Returns * FALSE if either of the URLs are invalid. */ PP_Bool (*IsSameSecurityOrigin)(struct PP_Var url_a, struct PP_Var url_b); /* * Checks whether the document hosting the given plugin instance can access * the given URL according to the same origin policy of the browser. Returns * PP_FALSE if the instance or the URL is invalid. */ PP_Bool (*DocumentCanRequest)(PP_Instance instance, struct PP_Var url); /* * Checks whether the document containing the |active| plugin instance can * access the document containing the |target| plugin instance according to * the security policy of the browser. This includes the same origin policy * and any cross-origin capabilities enabled by the document. If either of * the plugin instances are invalid, returns PP_FALSE. */ PP_Bool (*DocumentCanAccessDocument)(PP_Instance active, PP_Instance target); /* * Returns the URL for the document. This is a safe way to retrieve * window.location.href. * The components pointer, if non-NULL and the canonicalized URL is valid, * will identify the components of the resulting URL. Components may be NULL * to specify that no component information is necessary. */ struct PP_Var (*GetDocumentURL)(PP_Instance instance, struct PP_URLComponents_Dev* components); /* * Returns the Source URL for the plugin. This returns the URL that would be * streamed to the plugin if it were a NPAPI plugin. This is usually the src * attribute on the element, but the rules are obscure and different * based on whether the plugin is loaded from an element or an * element. * The components pointer, if non-NULL and the canonicalized URL is valid, * will identify the components of the resulting URL. Components may be NULL * to specify that no component information is necessary. */ struct PP_Var (*GetPluginInstanceURL)( PP_Instance instance, struct PP_URLComponents_Dev* components); /* * Returns the Referrer URL of the HTTP request that loaded the plugin. This * is the value of the 'Referer' header of the request. An undefined value * means the 'Referer' header was absent. * The components pointer, if non-NULL and the canonicalized URL is valid, * will identify the components of the resulting URL. Components may be NULL * to specify that no component information is necessary. */ struct PP_Var (*GetPluginReferrerURL)( PP_Instance instance, struct PP_URLComponents_Dev* components); }; typedef struct PPB_URLUtil_Dev_0_7 PPB_URLUtil_Dev; struct PPB_URLUtil_Dev_0_6 { struct PP_Var (*Canonicalize)(struct PP_Var url, struct PP_URLComponents_Dev* components); struct PP_Var (*ResolveRelativeToURL)( struct PP_Var base_url, struct PP_Var relative_string, struct PP_URLComponents_Dev* components); struct PP_Var (*ResolveRelativeToDocument)( PP_Instance instance, struct PP_Var relative_string, struct PP_URLComponents_Dev* components); PP_Bool (*IsSameSecurityOrigin)(struct PP_Var url_a, struct PP_Var url_b); PP_Bool (*DocumentCanRequest)(PP_Instance instance, struct PP_Var url); PP_Bool (*DocumentCanAccessDocument)(PP_Instance active, PP_Instance target); struct PP_Var (*GetDocumentURL)(PP_Instance instance, struct PP_URLComponents_Dev* components); struct PP_Var (*GetPluginInstanceURL)( PP_Instance instance, struct PP_URLComponents_Dev* components); }; /** * @} */ #endif /* PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_var_deprecated.h000066400000000000000000000223331321746453100251420ustar00rootroot00000000000000/* Copyright (c) 2010 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef PPAPI_C_PPB_VAR_DEPRECATED_H_ #define PPAPI_C_PPB_VAR_DEPRECATED_H_ #include "ppapi/c/dev/deprecated_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" struct PPP_Class_Deprecated; #define PPB_VAR_DEPRECATED_INTERFACE_0_3 "PPB_Var(Deprecated);0.3" #define PPB_VAR_DEPRECATED_INTERFACE PPB_VAR_DEPRECATED_INTERFACE_0_3 /** * @file * Defines the PPB_Var_Deprecated struct. * See http://code.google.com/p/ppapi/wiki/InterfacingWithJavaScript * for general information on using this interface. * {PENDING: Should the generated doc really be pointing to methods?} * * @addtogroup PPB * @{ */ struct PPB_Var_Deprecated { /** * Adds a reference to the given var. If this is not a refcounted object, * this function will do nothing so you can always call it no matter what the * type. */ void (*AddRef)(struct PP_Var var); /** * Removes a reference to given var, deleting it if the internal refcount * becomes 0. If the given var is not a refcounted object, this function will * do nothing so you can always call it no matter what the type. */ void (*Release)(struct PP_Var var); /** * Creates a string var from a string. The string must be encoded in valid * UTF-8 and is NOT NULL-terminated, the length must be specified in |len|. * It is an error if the string is not valid UTF-8. * * If the length is 0, the |data| pointer will not be dereferenced and may * be NULL. Note, however, that if you do this, the "NULL-ness" will not be * preserved, as VarToUtf8 will never return NULL on success, even for empty * strings. * * The resulting object will be a refcounted string object. It will be * AddRef()ed for the caller. When the caller is done with it, it should be * Release()d. * * On error (basically out of memory to allocate the string, or input that * is not valid UTF-8), this function will return a Null var. */ struct PP_Var (*VarFromUtf8)(PP_Module module, const char* data, uint32_t len); /** * Converts a string-type var to a char* encoded in UTF-8. This string is NOT * NULL-terminated. The length will be placed in |*len|. If the string is * valid but empty the return value will be non-NULL, but |*len| will still * be 0. * * If the var is not a string, this function will return NULL and |*len| will * be 0. * * The returned buffer will be valid as long as the underlying var is alive. * If the plugin frees its reference, the string will be freed and the pointer * will be to random memory. */ const char* (*VarToUtf8)(struct PP_Var var, uint32_t* len); /** * Returns true if the property with the given name exists on the given * object, false if it does not. Methods are also counted as properties. * * The name can either be a string or an integer var. It is an error to pass * another type of var as the name. * * If you pass an invalid name or object, the exception will be set (if it is * non-NULL, and the return value will be false). */ bool (*HasProperty)(struct PP_Var object, struct PP_Var name, struct PP_Var* exception); /** * Identical to HasProperty, except that HasMethod additionally checks if the * property is a function. */ bool (*HasMethod)(struct PP_Var object, struct PP_Var name, struct PP_Var* exception); /** * Returns the value of the given property. If the property doesn't exist, the * exception (if non-NULL) will be set and a "Void" var will be returned. */ struct PP_Var (*GetProperty)(struct PP_Var object, struct PP_Var name, struct PP_Var* exception); /** * Retrieves all property names on the given object. Property names include * methods. * * If there is a failure, the given exception will be set (if it is non-NULL). * On failure, |*properties| will be set to NULL and |*property_count| will be * set to 0. * * A pointer to the array of property names will be placesd in |*properties|. * The caller is responsible for calling Release() on each of these properties * (as per normal refcounted memory management) as well as freeing the array * pointer with PPB_Core.MemFree(). * * This function returns all "enumerable" properties. Some JavaScript * properties are "hidden" and these properties won't be retrieved by this * function, yet you can still set and get them. * * Example: *
  uint32_t count;
   *   PP_Var* properties;
   *   ppb_var.GetAllPropertyNames(object, &count, &properties);
   *
   *   ...use the properties here...
   *
   *   for (uint32_t i = 0; i < count; i++)
   *     ppb_var.Release(properties[i]);
   *   ppb_core.MemFree(properties); 
*/ void (*GetAllPropertyNames)(struct PP_Var object, uint32_t* property_count, struct PP_Var** properties, struct PP_Var* exception); /** * Sets the property with the given name on the given object. The exception * will be set, if it is non-NULL, on failure. */ void (*SetProperty)(struct PP_Var object, struct PP_Var name, struct PP_Var value, struct PP_Var* exception); /** * Removes the given property from the given object. The property name must * be an string or integer var, using other types will throw an exception * (assuming the exception pointer is non-NULL). */ void (*RemoveProperty)(struct PP_Var object, struct PP_Var name, struct PP_Var* exception); // TODO(brettw) need native array access here. /** * Invoke the function |method_name| on the given object. If |method_name| * is a Null var, the default method will be invoked, which is how you can * invoke function objects. * * Unless it is type Null, |method_name| must be a string. Unlike other * Var functions, integer lookup is not supported since you can't call * functions on integers in JavaScript. * * Pass the arguments to the function in order in the |argv| array, and the * number of arguments in the |argc| parameter. |argv| can be NULL if |argc| * is zero. * * Example: * Call(obj, VarFromUtf8("DoIt"), 0, NULL, NULL) = obj.DoIt() in JavaScript. * Call(obj, PP_MakeNull(), 0, NULL, NULL) = obj() in JavaScript. */ struct PP_Var (*Call)(struct PP_Var object, struct PP_Var method_name, uint32_t argc, struct PP_Var* argv, struct PP_Var* exception); /** * Invoke the object as a constructor. * * For example, if |object| is |String|, this is like saying |new String| in * JavaScript. */ struct PP_Var (*Construct)(struct PP_Var object, uint32_t argc, struct PP_Var* argv, struct PP_Var* exception); /** * If the object is an instance of the given class, then this method returns * true and sets *object_data to the value passed to CreateObject provided * object_data is non-NULL. Otherwise, this method returns false. */ bool (*IsInstanceOf)(struct PP_Var var, const struct PPP_Class_Deprecated* object_class, void** object_data); /** * Creates an object that the plugin implements. The plugin supplies a * pointer to the class interface it implements for that object, and its * associated internal data that represents that object. This object data * must be unique among all "live" objects. * * The returned object will have a reference count of 1. When the reference * count reached 0, the class' Destruct function wlil be called. * * On failure, this will return a null var. This probably means the module * was invalid. * * Example: Say we're implementing a "Point" object. *
  void PointDestruct(void* object) {
   *     delete (Point*)object;
   *   }
   *
   *   const PPP_Class_Deprecated point_class = {
   *     ... all the other class functions go here ...
   *     &PointDestruct
   *   };
   *
   *    * The plugin's internal object associated with the point.
   *   class Point {
   *     ...
   *   };
   *
   *   PP_Var MakePoint(int x, int y) {
   *     return CreateObject(&point_class, new Point(x, y));
   *   }
*/ struct PP_Var (*CreateObject)(PP_Instance instance, const struct PPP_Class_Deprecated* object_class, void* object_data); // Like CreateObject but takes a module. This will be deleted when all callers // can be changed to use the PP_Instance CreateObject one. struct PP_Var (*CreateObjectWithModuleDeprecated)( PP_Module module, const struct PPP_Class_Deprecated* object_class, void* object_data); }; /** * @} * End addtogroup PPB */ #endif /* PPAPI_C_PPB_VAR_DEPRECATED_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_video_capture_dev.h000066400000000000000000000154431321746453100256650ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_video_capture_dev.idl modified Thu Dec 12 15:36:11 2013. */ #ifndef PPAPI_C_DEV_PPB_VIDEO_CAPTURE_DEV_H_ #define PPAPI_C_DEV_PPB_VIDEO_CAPTURE_DEV_H_ #include "ppapi/c/dev/pp_video_capture_dev.h" #include "ppapi/c/dev/ppb_device_ref_dev.h" #include "ppapi/c/pp_array_output.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_VIDEOCAPTURE_DEV_INTERFACE_0_3 "PPB_VideoCapture(Dev);0.3" #define PPB_VIDEOCAPTURE_DEV_INTERFACE PPB_VIDEOCAPTURE_DEV_INTERFACE_0_3 /** * @file * This file defines the PPB_VideoCapture_Dev interface. */ /** * @addtogroup Interfaces * @{ */ /** * Video capture interface. It goes hand-in-hand with PPP_VideoCapture_Dev. * * Theory of operation: * 1- Create a VideoCapture resource using Create. * 2- Find available video capture devices using EnumerateDevices. * 3- Open a video capture device. In addition to a device reference (0 can be * used to indicate the default device), you pass in the requested info * (resolution, frame rate), as well as suggest a number of buffers you will * need. * 4- Start the capture using StartCapture. * 5- Receive the OnDeviceInfo callback, in PPP_VideoCapture_Dev, which will * give you the actual capture info (the requested one is not guaranteed), as * well as an array of buffers allocated by the browser. * 6- On every frame captured by the browser, OnBufferReady (in * PPP_VideoCapture_Dev) is called with the index of the buffer from the array * containing the new frame. The buffer is now "owned" by the plugin, and the * browser won't reuse it until ReuseBuffer is called. * 7- When the plugin is done with the buffer, call ReuseBuffer. * 8- Stop the capture using StopCapture. * 9- Close the device. * * The browser may change the resolution based on the constraints of the system, * in which case OnDeviceInfo will be called again, with new buffers. * * The buffers contain the pixel data for a frame. The format is planar YUV * 4:2:0, one byte per pixel, tightly packed (width x height Y values, then * width/2 x height/2 U values, then width/2 x height/2 V values). */ struct PPB_VideoCapture_Dev_0_3 { /** * Creates a new VideoCapture. */ PP_Resource (*Create)(PP_Instance instance); /** * Returns PP_TRUE if the given resource is a VideoCapture. */ PP_Bool (*IsVideoCapture)(PP_Resource video_capture); /** * Enumerates video capture devices. * * @param[in] video_capture A PP_Resource corresponding to a * video capture resource. * @param[in] output An output array which will receive * PPB_DeviceRef_Dev resources on success. Please note that the * ref count of those resources has already been increased by 1 for the * caller. * @param[in] callback A PP_CompletionCallback to run on * completion. * * @return An error code from pp_errors.h. */ int32_t (*EnumerateDevices)(PP_Resource video_capture, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); /** * Requests device change notifications. * * @param[in] video_capture A PP_Resource corresponding to a * video capture resource. * @param[in] callback The callback to receive notifications. If not NULL, it * will be called once for the currently available devices, and then every * time the list of available devices changes. All calls will happen on the * same thread as the one on which MonitorDeviceChange() is called. It will * receive notifications until video_capture is destroyed or * MonitorDeviceChange() is called to set a new callback for * video_capture. You can pass NULL to cancel sending * notifications. * @param[inout] user_data An opaque pointer that will be passed to * callback. * * @return An error code from pp_errors.h. */ int32_t (*MonitorDeviceChange)(PP_Resource video_capture, PP_MonitorDeviceChangeCallback callback, void* user_data); /** * Opens a video capture device. |device_ref| identifies a video capture * device. It could be one of the resource in the array returned by * |EnumerateDevices()|, or 0 which means the default device. * |requested_info| is a pointer to a structure containing the requested * resolution and frame rate. |buffer_count| is the number of buffers * requested by the plugin. Note: it is only used as advisory, the browser may * allocate more or fewer based on available resources. How many buffers * depends on usage. At least 2 to make sure latency doesn't cause lost * frames. If the plugin expects to hold on to more than one buffer at a time * (e.g. to do multi-frame processing, like video encoding), it should request * that many more. */ int32_t (*Open)(PP_Resource video_capture, PP_Resource device_ref, const struct PP_VideoCaptureDeviceInfo_Dev* requested_info, uint32_t buffer_count, struct PP_CompletionCallback callback); /** * Starts the capture. * * Returns PP_ERROR_FAILED if called when the capture was already started, or * PP_OK on success. */ int32_t (*StartCapture)(PP_Resource video_capture); /** * Allows the browser to reuse a buffer that was previously sent by * PPP_VideoCapture_Dev.OnBufferReady. |buffer| is the index of the buffer in * the array returned by PPP_VideoCapture_Dev.OnDeviceInfo. * * Returns PP_ERROR_BADARGUMENT if buffer is out of range (greater than the * number of buffers returned by PPP_VideoCapture_Dev.OnDeviceInfo), or if it * is not currently owned by the plugin. Returns PP_OK otherwise. */ int32_t (*ReuseBuffer)(PP_Resource video_capture, uint32_t buffer); /** * Stops the capture. * * Returns PP_ERROR_FAILED if the capture wasn't already started, or PP_OK on * success. */ int32_t (*StopCapture)(PP_Resource video_capture); /** * Closes the video capture device, and stops capturing if necessary. It is * not valid to call |Open()| again after a call to this method. * If a video capture resource is destroyed while a device is still open, then * it will be implicitly closed, so you are not required to call this method. */ void (*Close)(PP_Resource video_capture); }; typedef struct PPB_VideoCapture_Dev_0_3 PPB_VideoCapture_Dev; /** * @} */ #endif /* PPAPI_C_DEV_PPB_VIDEO_CAPTURE_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_video_decoder_dev.h000066400000000000000000000140521321746453100256220ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_video_decoder_dev.idl modified Tue Oct 29 00:32:59 2013. */ #ifndef PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_ #define PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_ #include "ppapi/c/dev/pp_video_dev.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #define PPB_VIDEODECODER_DEV_INTERFACE_0_16 "PPB_VideoDecoder(Dev);0.16" #define PPB_VIDEODECODER_DEV_INTERFACE PPB_VIDEODECODER_DEV_INTERFACE_0_16 /** * @file * This file defines the PPB_VideoDecoder_Dev interface. */ /** * @addtogroup Interfaces * @{ */ /** * Video decoder interface. * * Typical usage: * - Use Create() to create & configure a new PPB_VideoDecoder_Dev resource. * - Call Decode() to decode some video data. * - Receive ProvidePictureBuffers callback * - Supply the decoder with textures using AssignPictureBuffers. * - Receive PictureReady callbacks * - Hand the textures back to the decoder using ReusePictureBuffer. * - To signal EOS to the decoder: call Flush() and wait for NotifyFlushDone * callback. * - To reset the decoder (e.g. to implement Seek): call Reset() and wait for * NotifyResetDone callback. * - To tear down the decoder call Destroy(). * * See PPP_VideoDecoder_Dev for the notifications the decoder may send the * plugin. */ struct PPB_VideoDecoder_Dev_0_16 { /** * Creates & initializes a video decoder. * * Parameters: * |instance| pointer to the plugin instance. * |context| a PPB_Graphics3D resource in which decoding will happen. * |profile| the video stream's format profile. * * The created decoder is returned as PP_Resource. 0 means failure. */ PP_Resource (*Create)(PP_Instance instance, PP_Resource context, PP_VideoDecoder_Profile profile); /** * Tests whether |resource| is a video decoder created through Create * function of this interface. * * Parameters: * |resource| is handle to resource to test. * * Returns true if is a video decoder, false otherwise. */ PP_Bool (*IsVideoDecoder)(PP_Resource resource); /** * Dispatches bitstream buffer to the decoder. * * Parameters: * |video_decoder| is the previously created handle to the decoder resource. * |bitstream_buffer| is the bitstream buffer that contains at most one * input frame. * |callback| will be called when |bitstream_buffer| has been processed by * the decoder. * * Returns an error code from pp_errors.h. */ int32_t (*Decode)(PP_Resource video_decoder, const struct PP_VideoBitstreamBuffer_Dev* bitstream_buffer, struct PP_CompletionCallback callback); /** * Provides the decoder with texture-backed picture buffers for video * decoding. * * This function should be called when the plugin has its * ProvidePictureBuffers method called. The decoder will stall until it has * received all the buffers it's asked for. * * Parameters: * |video_decoder| is the previously created handle to the decoder resource. * |no_of_buffers| how many buffers are behind picture buffer pointer. * |buffers| contains the reference to the picture buffer that was * allocated. */ void (*AssignPictureBuffers)(PP_Resource video_decoder, uint32_t no_of_buffers, const struct PP_PictureBuffer_Dev buffers[]); /** * Tells the decoder to reuse the given picture buffer. Typical use of this * function is to call from PictureReady callback to recycle picture buffer * back to the decoder after blitting the image so that decoder can use the * image for output again. * * Parameters: * |video_decoder| is the previously created handle to the decoder resource. * |picture_buffer_id| contains the id of the picture buffer that was * processed. */ void (*ReusePictureBuffer)(PP_Resource video_decoder, int32_t picture_buffer_id); /** * Flush input and output buffers in the decoder. Any pending inputs are * decoded and pending outputs are delivered to the plugin. Once done * flushing, the decoder will call |callback|. * * Parameters: * |video_decoder| is the previously created handle to the decoder resource. * |callback| is one-time callback that will be called once the flushing * request has been completed. * * Returns an error code from pp_errors.h. */ int32_t (*Flush)(PP_Resource video_decoder, struct PP_CompletionCallback callback); /** * Reset the decoder as quickly as possible. Pending inputs and outputs are * dropped and the decoder is put back into a state ready to receive further * Decode() calls. |callback| will be called when the reset is done. * * Parameters: * |video_decoder| is the previously created handle to the decoder resource. * |callback| is one-time callback that will be called once the reset * request has been completed. * * Returns an error code from pp_errors.h. */ int32_t (*Reset)(PP_Resource video_decoder, struct PP_CompletionCallback callback); /** * Tear down the decoder as quickly as possible. Pending inputs and outputs * are dropped and the decoder frees all of its resources. Although resources * may be freed asynchronously, after this method returns no more callbacks * will be made on the client. Any resources held by the client at that point * may be freed. * * Parameters: * |video_decoder| is the previously created handle to the decoder resource. */ void (*Destroy)(PP_Resource video_decoder); }; typedef struct PPB_VideoDecoder_Dev_0_16 PPB_VideoDecoder_Dev; /** * @} */ #endif /* PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppb_view_dev.h000066400000000000000000000041031321746453100237750ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_view_dev.idl modified Mon Jun 18 14:55:58 2012. */ #ifndef PPAPI_C_DEV_PPB_VIEW_DEV_H_ #define PPAPI_C_DEV_PPB_VIEW_DEV_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_VIEW_DEV_INTERFACE_0_1 "PPB_View(Dev);0.1" #define PPB_VIEW_DEV_INTERFACE PPB_VIEW_DEV_INTERFACE_0_1 /** * @file * This file contains the PPB_View_Dev interface. */ /** * @addtogroup Interfaces * @{ */ /* PPB_View_Dev interface */ struct PPB_View_Dev_0_1 { /** * GetDeviceScale returns the scale factor between device pixels and DIPs * (also known as logical pixels or UI pixels on some platforms). This allows * the developer to render their contents at device resolution, even as * coordinates / sizes are given in DIPs through the API. * * Note that the coordinate system for Pepper APIs is DIPs. Also note that * one DIP might not equal one CSS pixel - when page scale/zoom is in effect. * * @param[in] resource A PP_Resource corresponding to a * PPB_View resource. * * @return A float value representing the number of device pixels * per DIP. If the resource is invalid, the value will be 0.0. */ float (*GetDeviceScale)(PP_Resource resource); /** * GetCSSScale returns the scale factor between DIPs and CSS pixels. This * allows proper scaling between DIPs - as sent via the Pepper API - and CSS * pixel coordinates used for Web content. * * @param[in] resource A PP_Resource corresponding to a * PPB_View resource. * * @return css_scale A float value representing the number of * DIPs per CSS pixel. If the resource is invalid, the value will be 0.0. */ float (*GetCSSScale)(PP_Resource resource); }; typedef struct PPB_View_Dev_0_1 PPB_View_Dev; /** * @} */ #endif /* PPAPI_C_DEV_PPB_VIEW_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppp_class_deprecated.h000066400000000000000000000113771321746453100255030ustar00rootroot00000000000000/* Copyright (c) 2010 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef PPAPI_C_PPP_CLASS_DEPRECATED_H_ #define PPAPI_C_PPP_CLASS_DEPRECATED_H_ #include "ppapi/c/dev/deprecated_bool.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" /** * @file * Defines the PPP_Class_Deprecated struct. * * @addtogroup PPP * @{ */ struct PP_Var; /** * Interface for the plugin to implement JavaScript-accessible objects. * * This interface has no interface name. Instead, the plugin passes a pointer * to this interface to PPB_Var_Deprecated.CreateObject that corresponds to the * object being implemented. * * See the PPB_Var_Deprecated interface for more information on these functions. * This interface just allows you to implement the "back end" of those * functions, so most of the contract is specified in that interface. * * See * http://code.google.com/p/ppapi/wiki/InterfacingWithJavaScript * for general information on using and implementing vars. */ struct PPP_Class_Deprecated { /** * |name| is guaranteed to be an integer or string type var. Exception is * guaranteed non-NULL. An integer is used for |name| when implementing * array access into the object. This test should only return true for * properties that are not methods. Use HasMethod() to handle methods. */ bool (*HasProperty)(void* object, struct PP_Var name, struct PP_Var* exception); /** * |name| is guaranteed to be a string-type. Exception is guaranteed non-NULL. * If the method does not exist, return false and don't set the exception. * Errors in this function will probably not occur in general usage, but * if you need to throw an exception, still return false. */ bool (*HasMethod)(void* object, struct PP_Var name, struct PP_Var* exception); /** * |name| is guaranteed to be a string-type or an integer-type var. Exception * is guaranteed non-NULL. An integer is used for |name| when implementing * array access into the object. If the property does not exist, set the * exception and return a var of type Void. A property does not exist if * a call HasProperty() for the same |name| would return false. */ struct PP_Var (*GetProperty)(void* object, struct PP_Var name, struct PP_Var* exception); /** * Exception is guaranteed non-NULL. * * This should include all enumerable properties, including methods. Be sure * to set |*property_count| to 0 and |properties| to NULL in all failure * cases, these should never be unset when calling this function. The * pointers passed in are guaranteed not to be NULL, so you don't have to * NULL check them. * * If you have any properties, allocate the property array with * PPB_Core.MemAlloc(sizeof(PP_Var) * property_count) and add a reference * to each property on behalf of the caller. The caller is responsible for * Release()ing each var and calling PPB_Core.MemFree on the property pointer. */ void (*GetAllPropertyNames)(void* object, uint32_t* property_count, struct PP_Var** properties, struct PP_Var* exception); /** * |name| is guaranteed to be an integer or string type var. Exception is * guaranteed non-NULL. */ void (*SetProperty)(void* object, struct PP_Var name, struct PP_Var value, struct PP_Var* exception); /** * |name| is guaranteed to be an integer or string type var. Exception is * guaranteed non-NULL. */ void (*RemoveProperty)(void* object, struct PP_Var name, struct PP_Var* exception); // TODO(brettw) need native array access here. /** * |name| is guaranteed to be a string type var. Exception is guaranteed * non-NULL */ struct PP_Var (*Call)(void* object, struct PP_Var method_name, uint32_t argc, struct PP_Var* argv, struct PP_Var* exception); /** Exception is guaranteed non-NULL. */ struct PP_Var (*Construct)(void* object, uint32_t argc, struct PP_Var* argv, struct PP_Var* exception); /** * Called when the reference count of the object reaches 0. Normally, plugins * would free their internal data pointed to by the |object| pointer. */ void (*Deallocate)(void* object); }; /** * @} * End addtogroup PPP */ #endif /* PPAPI_C_PPP_CLASS_DEPRECATED_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppp_network_state_dev.h000066400000000000000000000023211321746453100257320ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppp_network_state_dev.idl modified Wed Nov 7 09:50:23 2012. */ #ifndef PPAPI_C_DEV_PPP_NETWORK_STATE_DEV_H_ #define PPAPI_C_DEV_PPP_NETWORK_STATE_DEV_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #define PPP_NETWORK_STATE_DEV_INTERFACE_0_1 "PPP_NetworkState(Dev);0.1" #define PPP_NETWORK_STATE_DEV_INTERFACE PPP_NETWORK_STATE_DEV_INTERFACE_0_1 /** * @file * This file defines the PPP_NetworkState interface. */ /** * @addtogroup Interfaces * @{ */ struct PPP_NetworkState_Dev_0_1 { /** * Notification that the online state has changed for the user's network. * This will change as a result of a network cable being plugged or * unplugged, WiFi connections going up and down, or other events. * * Note that being "online" isn't a guarantee that any particular connections * will succeed. */ void (*SetOnLine)(PP_Bool is_online); }; typedef struct PPP_NetworkState_Dev_0_1 PPP_NetworkState_Dev; /** * @} */ #endif /* PPAPI_C_DEV_PPP_NETWORK_STATE_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppp_printing_dev.h000066400000000000000000000052221321746453100246760ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppp_printing_dev.idl modified Wed Jun 13 09:20:40 2012. */ #ifndef PPAPI_C_DEV_PPP_PRINTING_DEV_H_ #define PPAPI_C_DEV_PPP_PRINTING_DEV_H_ #include "ppapi/c/dev/pp_print_settings_dev.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #define PPP_PRINTING_DEV_INTERFACE_0_6 "PPP_Printing(Dev);0.6" #define PPP_PRINTING_DEV_INTERFACE PPP_PRINTING_DEV_INTERFACE_0_6 /** * @file * Definition of the PPP_Printing interface. */ /** * @addtogroup Structs * @{ */ /** * Specifies a contiguous range of page numbers to be printed. * The page numbers use a zero-based index. */ struct PP_PrintPageNumberRange_Dev { uint32_t first_page_number; uint32_t last_page_number; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_PrintPageNumberRange_Dev, 8); /** * @} */ /** * @addtogroup Interfaces * @{ */ struct PPP_Printing_Dev_0_6 { /** * Returns a bit field representing the supported print output formats. For * example, if only PDF and PostScript are supported, * QuerySupportedFormats returns a value equivalent to: * (PP_PRINTOUTPUTFORMAT_PDF | PP_PRINTOUTPUTFORMAT_POSTSCRIPT) */ uint32_t (*QuerySupportedFormats)(PP_Instance instance); /** * Begins a print session with the given print settings. Calls to PrintPages * can only be made after a successful call to Begin. Returns the number of * pages required for the print output at the given page size (0 indicates * a failure). */ int32_t (*Begin)(PP_Instance instance, const struct PP_PrintSettings_Dev* print_settings); /** * Prints the specified pages using the format specified in Begin. * Returns a PPB_Buffer resource that represents the printed output. Returns * 0 on failure. */ PP_Resource (*PrintPages)( PP_Instance instance, const struct PP_PrintPageNumberRange_Dev* page_ranges, uint32_t page_range_count); /** Ends the print session. Further calls to PrintPages will fail. */ void (*End)(PP_Instance instance); /** * Returns true if the current content should be printed into the full page * and not scaled down to fit within the printer's printable area. */ PP_Bool (*IsScalingDisabled)(PP_Instance instance); }; typedef struct PPP_Printing_Dev_0_6 PPP_Printing_Dev; /** * @} */ #endif /* PPAPI_C_DEV_PPP_PRINTING_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppp_text_input_dev.h000066400000000000000000000026311321746453100252500ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppp_text_input_dev.idl modified Thu Mar 28 10:55:30 2013. */ #ifndef PPAPI_C_DEV_PPP_TEXT_INPUT_DEV_H_ #define PPAPI_C_DEV_PPP_TEXT_INPUT_DEV_H_ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #define PPP_TEXTINPUT_DEV_INTERFACE_0_1 "PPP_TextInput(Dev);0.1" #define PPP_TEXTINPUT_DEV_INTERFACE PPP_TEXTINPUT_DEV_INTERFACE_0_1 /** * @file * This file defines the PPP_TextInput_Dev interface. */ /** * @addtogroup Interfaces * @{ */ /** * PPP_TextInput_Dev is a set of function pointers that the * plugin has to implement to provide hints for text input system (IME). */ struct PPP_TextInput_Dev_0_1 { /** * Requests the plugin to send back the text around the current caret or * selection by PPB_TextInput_Dev::UpdateSurroundingText. * It is recommended to include the desired_number_of_characters * characters before and after the selection, but not mandatory. */ void (*RequestSurroundingText)(PP_Instance instance, uint32_t desired_number_of_characters); }; typedef struct PPP_TextInput_Dev_0_1 PPP_TextInput_Dev; /** * @} */ #endif /* PPAPI_C_DEV_PPP_TEXT_INPUT_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppp_video_capture_dev.h000066400000000000000000000053471321746453100257050ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppp_video_capture_dev.idl modified Mon Oct 01 14:26:07 2012. */ #ifndef PPAPI_C_DEV_PPP_VIDEO_CAPTURE_DEV_H_ #define PPAPI_C_DEV_PPP_VIDEO_CAPTURE_DEV_H_ #include "ppapi/c/dev/pp_video_capture_dev.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPP_VIDEO_CAPTURE_DEV_INTERFACE_0_1 "PPP_VideoCapture(Dev);0.1" #define PPP_VIDEO_CAPTURE_DEV_INTERFACE PPP_VIDEO_CAPTURE_DEV_INTERFACE_0_1 /** * @file * This file defines the PPP_VideoCapture_Dev interface. */ /** * @addtogroup Interfaces * @{ */ /** * Video Capture client interface. See |PPB_VideoCapture_Dev| for general theory * of operation. */ struct PPP_VideoCapture_Dev_0_1 { /** * Signals the capture device information, such as resolution and frame rate, * and the array of buffers that the browser will use to send pixel data. * * |info| is a pointer to the PP_VideoCaptureDeviceInfo_Dev structure * containing resolution and frame rate. * |buffer_count| is the number of buffers, and |buffers| is the array of * PPB_Buffer_Dev buffers. * * Note: the buffers are passed without an extra reference. The plugin is * expected to add its own references to the buffers. */ void (*OnDeviceInfo)(PP_Instance instance, PP_Resource video_capture, const struct PP_VideoCaptureDeviceInfo_Dev* info, uint32_t buffer_count, const PP_Resource buffers[]); /** * Signals status changes on the VideoCapture. |status| is a * one of the values from PP_VideoCaptureStatus_Dev; */ void (*OnStatus)(PP_Instance instance, PP_Resource video_capture, uint32_t status); /** * Signals an error from the video capture system. * * Errors that can be generated: * - PP_ERROR_NOMEMORY: not enough memory was available to allocate buffers. * - PP_ERROR_FAILED: video capture could not start. */ void (*OnError)(PP_Instance instance, PP_Resource video_capture, uint32_t error_code); /** * Signals that a buffer is available for consumption by the plugin. * * |buffer| is the index of the buffer, in the array returned by OnDeviceInfo. */ void (*OnBufferReady)(PP_Instance instance, PP_Resource video_capture, uint32_t buffer); }; typedef struct PPP_VideoCapture_Dev_0_1 PPP_VideoCapture_Dev; /** * @} */ #endif /* PPAPI_C_DEV_PPP_VIDEO_CAPTURE_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/dev/ppp_video_decoder_dev.h000066400000000000000000000074431321746453100256460ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppp_video_decoder_dev.idl modified Fri Dec 13 15:21:30 2013. */ #ifndef PPAPI_C_DEV_PPP_VIDEO_DECODER_DEV_H_ #define PPAPI_C_DEV_PPP_VIDEO_DECODER_DEV_H_ #include "ppapi/c/dev/pp_video_dev.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #define PPP_VIDEODECODER_DEV_INTERFACE_0_11 "PPP_VideoDecoder(Dev);0.11" #define PPP_VIDEODECODER_DEV_INTERFACE PPP_VIDEODECODER_DEV_INTERFACE_0_11 /** * @file * This file defines the PPP_VideoDecoder_Dev interface. */ /** * @addtogroup Interfaces * @{ */ /** * PPP_VideoDecoder_Dev structure contains the function pointers that the * plugin MUST implement to provide services needed by the video decoder * implementation. * * See PPB_VideoDecoder_Dev for general usage tips. */ struct PPP_VideoDecoder_Dev_0_11 { /** * Callback function to provide buffers for the decoded output pictures. If * succeeds plugin must provide buffers through AssignPictureBuffers function * to the API. If |req_num_of_bufs| matching exactly the specification * given in the parameters cannot be allocated decoder should be destroyed. * * Decoding will not proceed until buffers have been provided. * * Parameters: * |instance| the plugin instance to which the callback is responding. * |decoder| the PPB_VideoDecoder_Dev resource. * |req_num_of_bufs| tells how many buffers are needed by the decoder. * |dimensions| tells the dimensions of the buffer to allocate. * |texture_target| the type of texture used. Sample targets in use are * TEXTURE_2D (most platforms) and TEXTURE_EXTERNAL_OES (on ARM). */ void (*ProvidePictureBuffers)(PP_Instance instance, PP_Resource decoder, uint32_t req_num_of_bufs, const struct PP_Size* dimensions, uint32_t texture_target); /** * Callback function for decoder to deliver unneeded picture buffers back to * the plugin. * * Parameters: * |instance| the plugin instance to which the callback is responding. * |decoder| the PPB_VideoDecoder_Dev resource. * |picture_buffer| points to the picture buffer that is no longer needed. */ void (*DismissPictureBuffer)(PP_Instance instance, PP_Resource decoder, int32_t picture_buffer_id); /** * Callback function for decoder to deliver decoded pictures ready to be * displayed. Decoder expects the plugin to return the buffer back to the * decoder through ReusePictureBuffer function in PPB Video Decoder API. * * Parameters: * |instance| the plugin instance to which the callback is responding. * |decoder| the PPB_VideoDecoder_Dev resource. * |picture| is the picture that is ready. */ void (*PictureReady)(PP_Instance instance, PP_Resource decoder, const struct PP_Picture_Dev* picture); /** * Error handler callback for decoder to deliver information about detected * errors to the plugin. * * Parameters: * |instance| the plugin instance to which the callback is responding. * |decoder| the PPB_VideoDecoder_Dev resource. * |error| error is the enumeration specifying the error. */ void (*NotifyError)(PP_Instance instance, PP_Resource decoder, PP_VideoDecodeError_Dev error); }; typedef struct PPP_VideoDecoder_Dev_0_11 PPP_VideoDecoder_Dev; /** * @} */ #endif /* PPAPI_C_DEV_PPP_VIDEO_DECODER_DEV_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_array_output.h000066400000000000000000000075611321746453100240160ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_array_output.idl modified Tue Oct 22 15:09:25 2013. */ #ifndef PPAPI_C_PP_ARRAY_OUTPUT_H_ #define PPAPI_C_PP_ARRAY_OUTPUT_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" /** * @file * PP_ArrayOutput_GetDataBuffer is a callback function to allocate plugin * memory for an array. It returns the allocated memory or null on failure. * * This function will be called reentrantly. This means that if you call a * function PPB_Foo.GetData(&array_output), GetData will call your * GetDataBuffer function before it returns. * * This function will be called even when returning 0-length arrays, so be sure * your implementation can support that. You can return NULL for 0 length * arrays and it will not be treated as a failure. * * You should not perform any processing in this callback, including calling * other PPAPI functions, outside of allocating memory. You should not throw * any exceptions. In C++, this means using "new (nothrow)" or being sure to * catch any exceptions before returning. * * The C++ wrapper provides a convenient templatized implementation around * std::vector which you should generally use instead of coding this * specifically. * * @param user_data The pointer provided in the PP_ArrayOutput structure. This * has no meaning to the browser, it is intended to be used by the * implementation to figure out where to put the data. * * @param element_count The number of elements in the array. This will be 0 * if there is no data to return. * * @param element_size The size of each element in bytes. * * @return Returns a pointer to the allocated memory. On failure, returns null. * You can also return null if the element_count is 0. When a non-null value is * returned, the buffer must remain valid until after the callback runs. If used * with a blocking callback, the buffer must remain valid until after the * function returns. The plugin can then free any memory that it allocated. */ /** * @addtogroup Typedefs * @{ */ typedef void* (*PP_ArrayOutput_GetDataBuffer)(void* user_data, uint32_t element_count, uint32_t element_size); /** * @} */ /** * @addtogroup Structs * @{ */ /** * A structure that defines a way for the browser to return arrays of data * to the plugin. The browser can not allocate memory on behalf of the plugin * because the plugin and browser may have different allocators. * * Array output works by having the browser call to the plugin to allocate a * buffer, and then the browser will copy the contents of the array into that * buffer. * * In C, you would typically implement this as follows: * * @code * struct MyArrayOutput { * void* data; * int element_count; * }; * void* MyGetDataBuffer(void* user_data, uint32_t count, uint32_t size) { * MyArrayOutput* output = (MyArrayOutput*)user_data; * output->element_count = count; * if (size) { * output->data = malloc(count * size); * if (!output->data) // Be careful to set size properly on malloc failure. * output->element_count = 0; * } else { * output->data = NULL; * } * return output->data; * } * void MyFunction() { * MyArrayOutput array = { NULL, 0 }; * PP_ArrayOutput output = { &MyGetDataBuffer, &array }; * ppb_foo->GetData(&output); * } * @endcode */ struct PP_ArrayOutput { /** * A pointer to the allocation function that the browser will call. */ PP_ArrayOutput_GetDataBuffer GetDataBuffer; /** * Data that is passed to the allocation function. Typically, this is used * to communicate how the data should be stored. */ void* user_data; }; /** * @} */ #endif /* PPAPI_C_PP_ARRAY_OUTPUT_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_bool.h000066400000000000000000000024331321746453100222040ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_bool.idl modified Thu Nov 1 13:48:33 2012. */ #ifndef PPAPI_C_PP_BOOL_H_ #define PPAPI_C_PP_BOOL_H_ #include "ppapi/c/pp_macros.h" /** * @file * This file defines the PP_Bool enumeration for use in PPAPI C * headers. */ /** * @addtogroup Enums * @{ */ /** * The PP_Bool enum is a boolean value for use in PPAPI C headers. * The standard bool type is not available to pre-C99 compilers, and is not * guaranteed to be compatible between C and C++, whereas the PPAPI C headers * can be included from C or C++ code. */ typedef enum { PP_FALSE = 0, PP_TRUE = 1 } PP_Bool; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Bool, 4); /** * @} */ #ifdef __cplusplus /** * Converts a C++ "bool" type to a PP_Bool. * * @param[in] b A C++ "bool" type. * * @return A PP_Bool. */ inline PP_Bool PP_FromBool(bool b) { return b ? PP_TRUE : PP_FALSE; } /** * Converts a PP_Bool to a C++ "bool" type. * * @param[in] b A PP_Bool. * * @return A C++ "bool" type. */ inline bool PP_ToBool(PP_Bool b) { return (b != PP_FALSE); } #endif /* __cplusplus */ #endif /* PPAPI_C_PP_BOOL_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_codecs.h000066400000000000000000000142001321746453100225040ustar00rootroot00000000000000/* Copyright (c) 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_codecs.idl modified Fri Sep 18 10:42:55 2015. */ #ifndef PPAPI_C_PP_CODECS_H_ #define PPAPI_C_PP_CODECS_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" /** * @file * Video profiles. */ /** * @addtogroup Enums * @{ */ typedef enum { PP_VIDEOPROFILE_H264BASELINE = 0, PP_VIDEOPROFILE_H264MAIN = 1, PP_VIDEOPROFILE_H264EXTENDED = 2, PP_VIDEOPROFILE_H264HIGH = 3, PP_VIDEOPROFILE_H264HIGH10PROFILE = 4, PP_VIDEOPROFILE_H264HIGH422PROFILE = 5, PP_VIDEOPROFILE_H264HIGH444PREDICTIVEPROFILE = 6, PP_VIDEOPROFILE_H264SCALABLEBASELINE = 7, PP_VIDEOPROFILE_H264SCALABLEHIGH = 8, PP_VIDEOPROFILE_H264STEREOHIGH = 9, PP_VIDEOPROFILE_H264MULTIVIEWHIGH = 10, PP_VIDEOPROFILE_VP8_ANY = 11, PP_VIDEOPROFILE_VP9_ANY = 12, PP_VIDEOPROFILE_MAX = PP_VIDEOPROFILE_VP9_ANY } PP_VideoProfile; /** * Audio profiles. */ typedef enum { PP_AUDIOPROFILE_OPUS = 0, PP_AUDIOPROFILE_MAX = PP_AUDIOPROFILE_OPUS } PP_AudioProfile; /** * Hardware acceleration options. */ typedef enum { /** Create a hardware accelerated resource only. */ PP_HARDWAREACCELERATION_ONLY = 0, /** * Create a hardware accelerated resource if possible. Otherwise, fall back * to the software implementation. */ PP_HARDWAREACCELERATION_WITHFALLBACK = 1, /** Create the software implementation only. */ PP_HARDWAREACCELERATION_NONE = 2, PP_HARDWAREACCELERATION_LAST = PP_HARDWAREACCELERATION_NONE } PP_HardwareAcceleration; /** * @} */ /** * @addtogroup Structs * @{ */ /** * Struct describing a decoded video picture. The decoded picture data is stored * in the GL texture corresponding to |texture_id|. The plugin can determine * which Decode call generated the picture using |decode_id|. */ struct PP_VideoPicture { /** * |decode_id| parameter of the Decode call which generated this picture. * See the PPB_VideoDecoder function Decode() for more details. */ uint32_t decode_id; /** * Texture ID in the plugin's GL context. The plugin can use this to render * the decoded picture. */ uint32_t texture_id; /** * The GL texture target for the decoded picture. Possible values are: * GL_TEXTURE_2D * GL_TEXTURE_RECTANGLE_ARB * GL_TEXTURE_EXTERNAL_OES * * The pixel format of the texture is GL_RGBA. */ uint32_t texture_target; /** * Dimensions of the texture holding the decoded picture. */ struct PP_Size texture_size; /** * The visible subrectangle of the picture. The plugin should display only * this part of the picture. */ struct PP_Rect visible_rect; }; /** * Struct describing a decoded video picture. The decoded picture data is stored * in the GL texture corresponding to |texture_id|. The plugin can determine * which Decode call generated the picture using |decode_id|. */ struct PP_VideoPicture_0_1 { /** * |decode_id| parameter of the Decode call which generated this picture. * See the PPB_VideoDecoder function Decode() for more details. */ uint32_t decode_id; /** * Texture ID in the plugin's GL context. The plugin can use this to render * the decoded picture. */ uint32_t texture_id; /** * The GL texture target for the decoded picture. Possible values are: * GL_TEXTURE_2D * GL_TEXTURE_RECTANGLE_ARB * GL_TEXTURE_EXTERNAL_OES * * The pixel format of the texture is GL_RGBA. */ uint32_t texture_target; /** * Dimensions of the texture holding the decoded picture. */ struct PP_Size texture_size; }; /** * Supported video profile information. See the PPB_VideoEncoder function * GetSupportedProfiles() for more details. */ struct PP_VideoProfileDescription { /** * The codec profile. */ PP_VideoProfile profile; /** * Dimensions of the maximum resolution of video frames, in pixels. */ struct PP_Size max_resolution; /** * The numerator of the maximum frame rate. */ uint32_t max_framerate_numerator; /** * The denominator of the maximum frame rate. */ uint32_t max_framerate_denominator; /** * Whether the profile is hardware accelerated. */ PP_Bool hardware_accelerated; }; /** * Supported video profile information. See the PPB_VideoEncoder function * GetSupportedProfiles() for more details. */ struct PP_VideoProfileDescription_0_1 { /** * The codec profile. */ PP_VideoProfile profile; /** * Dimensions of the maximum resolution of video frames, in pixels. */ struct PP_Size max_resolution; /** * The numerator of the maximum frame rate. */ uint32_t max_framerate_numerator; /** * The denominator of the maximum frame rate. */ uint32_t max_framerate_denominator; /** * A value indicating if the profile is available in hardware, software, or * both. */ PP_HardwareAcceleration acceleration; }; /** * Supported audio profile information. See the PPB_AudioEncoder function * GetSupportedProfiles() for more details. */ struct PP_AudioProfileDescription { /** * The codec profile. */ PP_AudioProfile profile; /** * Maximum number of channels that can be encoded. */ uint32_t max_channels; /** * Sample size. */ uint32_t sample_size; /** * Sampling rate that can be encoded */ uint32_t sample_rate; /** * Whether the profile is hardware accelerated. */ PP_Bool hardware_accelerated; }; /** * Struct describing a bitstream buffer. */ struct PP_BitstreamBuffer { /** * The size, in bytes, of the bitstream data. */ uint32_t size; /** * The base address of the bitstream data. */ void* buffer; /** * Whether the buffer represents a key frame. */ PP_Bool key_frame; }; /** * Struct describing an audio bitstream buffer. */ struct PP_AudioBitstreamBuffer { /** * The size, in bytes, of the bitstream data. */ uint32_t size; /** * The base address of the bitstream data. */ void* buffer; }; /** * @} */ #endif /* PPAPI_C_PP_CODECS_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_completion_callback.h000066400000000000000000000246011321746453100252370ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_completion_callback.idl modified Thu May 9 14:59:57 2013. */ #ifndef PPAPI_C_PP_COMPLETION_CALLBACK_H_ #define PPAPI_C_PP_COMPLETION_CALLBACK_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" /** * @file * This file defines the API to create and run a callback. */ /** * @addtogroup Typedefs * @{ */ /** * This typedef defines the signature that you implement to receive callbacks * on asynchronous completion of an operation. * * @param[in] user_data A pointer to user data passed to a callback function. * @param[in] result If result is 0 (PP_OK), the operation succeeded. Negative * values (other than -1 or PP_OK_COMPLETE) indicate error and are specified * in pp_errors.h. Positive values for result usually indicate success and have * some operation-dependent meaning (such as bytes read). */ typedef void (*PP_CompletionCallback_Func)(void* user_data, int32_t result); /** * @} */ /** * @addtogroup Enums * @{ */ /** * This enumeration contains flags used to control how non-NULL callbacks are * scheduled by asynchronous methods. */ typedef enum { /** * By default any non-NULL callback will always invoked asynchronously, * on success or error, even if the operation could complete synchronously * without blocking. * * The method taking such callback will always return PP_OK_COMPLETIONPENDING. * The callback will be invoked on the same thread on which the method was * invoked. * * NOTE: If the method taking the callback is invoked on a background * thread that has no valid PPB_MessageLoop resource attached, the system has * no way to run the callback on the correct thread. In this case, a log * message will be emitted and the plugin will be made to crash. */ PP_COMPLETIONCALLBACK_FLAG_NONE = 0 << 0, /** * This flag allows any method taking such callback to complete synchronously * and not call the callback if the operation would not block. This is useful * when performance is an issue, and the operation bandwidth should not be * limited to the processing speed of the message loop. * * On synchronous method completion, the completion result will be returned * by the method itself. Otherwise, the method will return * PP_OK_COMPLETIONPENDING, and the callback will be invoked asynchronously on * the same thread on which the method was invoked. If there is no valid * PPB_MessageLoop attached to that thread, and the callback would normally * run asynchronously, the invoked method will return * PP_ERROR_NO_MESSAGE_LOOP. */ PP_COMPLETIONCALLBACK_FLAG_OPTIONAL = 1 << 0 } PP_CompletionCallback_Flag; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CompletionCallback_Flag, 4); /** * @} */ /** * @addtogroup Structs * @{ */ /** * PP_CompletionCallback is a common mechanism for supporting * potentially asynchronous calls in browser interfaces. Any method that takes a * PP_CompletionCallback can be used in one of three different * ways: * - Required: The callback will always be invoked asynchronously on the * thread where the associated PPB method was invoked. The method * will always return PP_OK_COMPLETIONPENDING when a required * callback, and the callback will be invoked later (barring * system or thread shutdown; see PPB_MessageLoop for details). * Required callbacks are the default. *

* NOTE: If you use a required callback on a background thread, * you must have created and attached a PPB_MessageLoop. * Otherwise, the system can not run your callback on that thread, * and will instead emit a log message and crash your plugin to * make the problem more obvious. * * - Optional: The callback may be invoked asynchronously, or the PPB method * may complete synchronously if it can do so without blocking. * If the method will complete asynchronously, it will return * PP_OK_COMPLETIONPENDING. Otherwise, it will complete * synchronously and return an appropriate code (see below for * more information on the return code). Optional callbacks are * generally more difficult to use correctly than Required * callbacks, but can provide better performance for some APIs * (especially APIs with buffered reads, such as PPB_URLLoader or * PPB_FileIO). *

* NOTE: If you use an optional callback on a background thread, * and you have not created and attached a PPB_MessageLoop, then * the method you invoke will fail without running and return * PP_ERROR_NO_MESSAGE_LOOP. * * - Blocking: In this case, the callback's function pointer is NULL, and the * invoked method must complete synchronously. The method will * run to completion and return an appropriate code when finished * (see below for more information). Blocking completion * callbacks are only supported on background threads. *

* PP_BlockUntilComplete() provides a convenient way * to specify blocking behavior. Refer to * PP_BlockUntilComplete for more information. * * When the callback is run asynchronously, the result parameter passed to * func is an int32_t that, if negative indicates an error code * whose meaning is specific to the calling method (refer to * pp_error.h for further information). A positive or 0 value is a * return result indicating success whose meaning depends on the calling method * (e.g. number of bytes read). */ struct PP_CompletionCallback { /** * This value is a callback function that will be called, or NULL if this is * a blocking completion callback. */ PP_CompletionCallback_Func func; /** * This value is a pointer to user data passed to a callback function. */ void* user_data; /** * Flags used to control how non-NULL callbacks are scheduled by * asynchronous methods. */ int32_t flags; }; /** * @} */ #include /** * @addtogroup Functions * @{ */ /** * PP_MakeCompletionCallback() is used to create a * PP_CompletionCallback. * * Example, creating a Required callback: * * @code * struct PP_CompletionCallback cc = PP_MakeCompletionCallback(Foo, NULL); * @endcode * * Example, creating an Optional callback: * * @code * struct PP_CompletionCallback cc = PP_MakeCompletionCallback(Foo, NULL); * cc.flags = cc.flags | PP_COMPLETIONCALLBACK_FLAG_OPTIONAL; * @endcode * * @param[in] func A PP_CompletionCallback_Func that will be * called. * @param[in] user_data A pointer to user data passed to your callback * function. This is optional and is typically used to help track state * when you may have multiple callbacks pending. * * @return A PP_CompletionCallback structure. */ PP_INLINE struct PP_CompletionCallback PP_MakeCompletionCallback( PP_CompletionCallback_Func func, void* user_data) { struct PP_CompletionCallback cc; cc.func = func; cc.user_data = user_data; cc.flags = PP_COMPLETIONCALLBACK_FLAG_NONE; return cc; } /** * PP_MakeOptionalCompletionCallback() is used to create a PP_CompletionCallback * with PP_COMPLETIONCALLBACK_FLAG_OPTIONAL set. * * @param[in] func A PP_CompletionCallback_Func to be called on completion. * @param[in] user_data A pointer to user data passed to be passed to the * callback function. This is optional and is typically used to help track state * in case of multiple pending callbacks. * * @return A PP_CompletionCallback structure. */ PP_INLINE struct PP_CompletionCallback PP_MakeOptionalCompletionCallback( PP_CompletionCallback_Func func, void* user_data) { struct PP_CompletionCallback cc = PP_MakeCompletionCallback(func, user_data); cc.flags = cc.flags | PP_COMPLETIONCALLBACK_FLAG_OPTIONAL; return cc; } /** * @} */ /** * @addtogroup Functions * @{ */ /** * PP_RunCompletionCallback() is used to run a callback. It invokes * the callback function passing it user data specified on creation and * completion |result|. * * @param[in] cc A pointer to a PP_CompletionCallback that will be * run. * @param[in] result The result of the operation. Non-positive values correspond * to the error codes from pp_errors.h (excluding PP_OK_COMPLETIONPENDING). * Positive values indicate additional information such as bytes read. */ PP_INLINE void PP_RunCompletionCallback(struct PP_CompletionCallback* cc, int32_t result) { cc->func(cc->user_data, result); } /** * @} */ /** * @addtogroup Functions * @{ */ /** * PP_BlockUntilComplete() is used in place of an actual completion callback * to request blocking behavior. If specified, the calling thread will block * until the function completes. Blocking completion callbacks are only allowed * from background threads. * * @return A PP_CompletionCallback structure. */ PP_INLINE struct PP_CompletionCallback PP_BlockUntilComplete(void) { return PP_MakeCompletionCallback(NULL, NULL); } /** * PP_RunAndClearCompletionCallback() runs a callback and clears the reference * to that callback. * * This function is used when the null-ness of a completion callback is used as * a signal for whether a completion callback has been registered. In this * case, after the execution of the callback, it should be cleared. However, * this introduces a conflict if the completion callback wants to schedule more * work that involves the same completion callback again (for example, when * reading data from an URLLoader, one would typically queue up another read * callback). As a result, this function clears the pointer * before the provided callback is executed. */ PP_INLINE void PP_RunAndClearCompletionCallback( struct PP_CompletionCallback* cc, int32_t res) { struct PP_CompletionCallback temp = *cc; *cc = PP_BlockUntilComplete(); PP_RunCompletionCallback(&temp, res); } /** * @} */ #endif /* PPAPI_C_PP_COMPLETION_CALLBACK_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_directory_entry.h000066400000000000000000000014071321746453100244760ustar00rootroot00000000000000/* Copyright (c) 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_directory_entry.idl modified Tue Apr 30 05:44:50 2013. */ #ifndef PPAPI_C_PP_DIRECTORY_ENTRY_H_ #define PPAPI_C_PP_DIRECTORY_ENTRY_H_ #include "ppapi/c/pp_file_info.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" /** * @file * * This file defines the PP_DirectoryEntry struct. */ /** * @addtogroup Structs * @{ */ struct PP_DirectoryEntry { PP_Resource file_ref; PP_FileType file_type; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DirectoryEntry, 8); /** * @} */ #endif /* PPAPI_C_PP_DIRECTORY_ENTRY_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_errors.h000066400000000000000000000160441321746453100225700ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_errors.idl modified Tue Sep 23 15:37:27 2014. */ #ifndef PPAPI_C_PP_ERRORS_H_ #define PPAPI_C_PP_ERRORS_H_ #include "ppapi/c/pp_macros.h" /** * @file * This file defines an enumeration of all PPAPI error codes. */ /** * @addtogroup Enums * @{ */ /** * This enumeration contains enumerators of all PPAPI error codes. * * Errors are negative valued. Callers should treat all negative values as a * failure, even if it's not in the list, since the possible errors are likely * to expand and change over time. */ enum { /** * This value is returned by a function on successful synchronous completion * or is passed as a result to a PP_CompletionCallback_Func on successful * asynchronous completion. */ PP_OK = 0, /** * This value is returned by a function that accepts a PP_CompletionCallback * and cannot complete synchronously. This code indicates that the given * callback will be asynchronously notified of the final result once it is * available. */ PP_OK_COMPLETIONPENDING = -1, /**This value indicates failure for unspecified reasons. */ PP_ERROR_FAILED = -2, /** * This value indicates failure due to an asynchronous operation being * interrupted. The most common cause of this error code is destroying a * resource that still has a callback pending. All callbacks are guaranteed * to execute, so any callbacks pending on a destroyed resource will be * issued with PP_ERROR_ABORTED. * * If you get an aborted notification that you aren't expecting, check to * make sure that the resource you're using is still in scope. A common * mistake is to create a resource on the stack, which will destroy the * resource as soon as the function returns. */ PP_ERROR_ABORTED = -3, /** This value indicates failure due to an invalid argument. */ PP_ERROR_BADARGUMENT = -4, /** This value indicates failure due to an invalid PP_Resource. */ PP_ERROR_BADRESOURCE = -5, /** This value indicates failure due to an unavailable PPAPI interface. */ PP_ERROR_NOINTERFACE = -6, /** This value indicates failure due to insufficient privileges. */ PP_ERROR_NOACCESS = -7, /** This value indicates failure due to insufficient memory. */ PP_ERROR_NOMEMORY = -8, /** This value indicates failure due to insufficient storage space. */ PP_ERROR_NOSPACE = -9, /** This value indicates failure due to insufficient storage quota. */ PP_ERROR_NOQUOTA = -10, /** * This value indicates failure due to an action already being in * progress. */ PP_ERROR_INPROGRESS = -11, /** * The requested command is not supported by the browser. */ PP_ERROR_NOTSUPPORTED = -12, /** * Returned if you try to use a null completion callback to "block until * complete" on the main thread. Blocking the main thread is not permitted * to keep the browser responsive (otherwise, you may not be able to handle * input events, and there are reentrancy and deadlock issues). */ PP_ERROR_BLOCKS_MAIN_THREAD = -13, /** * This value indicates that the plugin sent bad input data to a resource, * leaving it in an invalid state. The resource can't be used after returning * this error and should be released. */ PP_ERROR_MALFORMED_INPUT = -14, /** * This value indicates that a resource has failed. The resource can't be * used after returning this error and should be released. */ PP_ERROR_RESOURCE_FAILED = -15, /** This value indicates failure due to a file that does not exist. */ PP_ERROR_FILENOTFOUND = -20, /** This value indicates failure due to a file that already exists. */ PP_ERROR_FILEEXISTS = -21, /** This value indicates failure due to a file that is too big. */ PP_ERROR_FILETOOBIG = -22, /** * This value indicates failure due to a file having been modified * unexpectedly. */ PP_ERROR_FILECHANGED = -23, /** This value indicates that the pathname does not reference a file. */ PP_ERROR_NOTAFILE = -24, /** This value indicates failure due to a time limit being exceeded. */ PP_ERROR_TIMEDOUT = -30, /** * This value indicates that the user cancelled rather than providing * expected input. */ PP_ERROR_USERCANCEL = -40, /** * This value indicates failure due to lack of a user gesture such as a * mouse click or key input event. Examples of actions requiring a user * gesture are showing the file chooser dialog and going into fullscreen * mode. */ PP_ERROR_NO_USER_GESTURE = -41, /** * This value indicates that the graphics context was lost due to a * power management event. */ PP_ERROR_CONTEXT_LOST = -50, /** * Indicates an attempt to make a PPAPI call on a thread without previously * registering a message loop via PPB_MessageLoop.AttachToCurrentThread. * Without this registration step, no PPAPI calls are supported. */ PP_ERROR_NO_MESSAGE_LOOP = -51, /** * Indicates that the requested operation is not permitted on the current * thread. */ PP_ERROR_WRONG_THREAD = -52, /** * Indicates that a null completion callback was used on a thread handling a * blocking message from JavaScript. Null completion callbacks "block until * complete", which could cause the main JavaScript thread to be blocked * excessively. */ PP_ERROR_WOULD_BLOCK_THREAD = -53, /** * This value indicates that the connection was closed. For TCP sockets, it * corresponds to a TCP FIN. */ PP_ERROR_CONNECTION_CLOSED = -100, /** * This value indicates that the connection was reset. For TCP sockets, it * corresponds to a TCP RST. */ PP_ERROR_CONNECTION_RESET = -101, /** * This value indicates that the connection attempt was refused. */ PP_ERROR_CONNECTION_REFUSED = -102, /** * This value indicates that the connection was aborted. For TCP sockets, it * means the connection timed out as a result of not receiving an ACK for data * sent. This can include a FIN packet that did not get ACK'd. */ PP_ERROR_CONNECTION_ABORTED = -103, /** * This value indicates that the connection attempt failed. */ PP_ERROR_CONNECTION_FAILED = -104, /** * This value indicates that the connection attempt timed out. */ PP_ERROR_CONNECTION_TIMEDOUT = -105, /** * This value indicates that the IP address or port number is invalid. */ PP_ERROR_ADDRESS_INVALID = -106, /** * This value indicates that the IP address is unreachable. This usually means * that there is no route to the specified host or network. */ PP_ERROR_ADDRESS_UNREACHABLE = -107, /** * This value is returned when attempting to bind an address that is already * in use. */ PP_ERROR_ADDRESS_IN_USE = -108, /** * This value indicates that the message was too large for the transport. */ PP_ERROR_MESSAGE_TOO_BIG = -109, /** * This value indicates that the host name could not be resolved. */ PP_ERROR_NAME_NOT_RESOLVED = -110 }; /** * @} */ #endif /* PPAPI_C_PP_ERRORS_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_file_info.h000066400000000000000000000046061321746453100232070ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_file_info.idl modified Thu May 2 16:41:50 2013. */ #ifndef PPAPI_C_PP_FILE_INFO_H_ #define PPAPI_C_PP_FILE_INFO_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" /** * @file * This file defines three enumerations for use in the PPAPI C file IO APIs. */ /** * @addtogroup Enums * @{ */ /** * The PP_FileType enum contains file type constants. */ typedef enum { /** A regular file type */ PP_FILETYPE_REGULAR = 0, /** A directory */ PP_FILETYPE_DIRECTORY = 1, /** A catch-all for unidentified types */ PP_FILETYPE_OTHER = 2 } PP_FileType; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileType, 4); /** * The PP_FileSystemType enum contains file system type constants. */ typedef enum { /** For identified invalid return values */ PP_FILESYSTEMTYPE_INVALID = 0, /** For external file system types */ PP_FILESYSTEMTYPE_EXTERNAL = 1, /** For local persistent file system types */ PP_FILESYSTEMTYPE_LOCALPERSISTENT = 2, /** For local temporary file system types */ PP_FILESYSTEMTYPE_LOCALTEMPORARY = 3, /** For isolated file system types */ PP_FILESYSTEMTYPE_ISOLATED = 4 } PP_FileSystemType; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileSystemType, 4); /** * @} */ /** * @addtogroup Structs * @{ */ /** * The PP_FileInfo struct represents all information about a file, * such as size, type, and creation time. */ struct PP_FileInfo { /** This value represents the size of the file measured in bytes */ int64_t size; /** * This value represents the type of file as defined by the * PP_FileType enum */ PP_FileType type; /** * This value represents the file system type of the file as defined by the * PP_FileSystemType enum. */ PP_FileSystemType system_type; /** * This value represents the creation time of the file. */ PP_Time creation_time; /** * This value represents the last time the file was accessed. */ PP_Time last_access_time; /** * This value represents the last time the file was modified. */ PP_Time last_modified_time; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FileInfo, 40); /** * @} */ #endif /* PPAPI_C_PP_FILE_INFO_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_graphics_3d.h000066400000000000000000000050561321746453100234430ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_graphics_3d.idl modified Wed Oct 3 15:55:01 2012. */ #ifndef PPAPI_C_PP_GRAPHICS_3D_H_ #define PPAPI_C_PP_GRAPHICS_3D_H_ #include "ppapi/c/pp_macros.h" /** * @file * This file defines the PP_Graphics3DAttrib enumeration for use in * PPAPI C headers. */ /** * @addtogroup Enums * @{ */ typedef enum { /** * Bits of Alpha in the color buffer. */ PP_GRAPHICS3DATTRIB_ALPHA_SIZE = 0x3021, /** * Bits of Blue in the color buffer. */ PP_GRAPHICS3DATTRIB_BLUE_SIZE = 0x3022, /** * Bits of Green in the color buffer. */ PP_GRAPHICS3DATTRIB_GREEN_SIZE = 0x3023, /** * Bits of Red in the color buffer. */ PP_GRAPHICS3DATTRIB_RED_SIZE = 0x3024, /** * Bits of Z in the depth buffer. */ PP_GRAPHICS3DATTRIB_DEPTH_SIZE = 0x3025, /** * Bits of Stencil in the stencil buffer. */ PP_GRAPHICS3DATTRIB_STENCIL_SIZE = 0x3026, /** * Number of samples per pixel. */ PP_GRAPHICS3DATTRIB_SAMPLES = 0x3031, /** * Number of multisample buffers. */ PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS = 0x3032, /** * Attrib list terminator. */ PP_GRAPHICS3DATTRIB_NONE = 0x3038, /** * Height of surface in pixels. */ PP_GRAPHICS3DATTRIB_HEIGHT = 0x3056, /** * Width of surface in pixels. */ PP_GRAPHICS3DATTRIB_WIDTH = 0x3057, /** * Specifies the effect on the color buffer of posting a surface * with SwapBuffers. The initial value is chosen by the implementation. */ PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR = 0x3093, /** * Indicates that color buffer contents are unaffected. */ PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED = 0x3094, /** * Indicates that color buffer contents may be destroyed or changed. */ PP_GRAPHICS3DATTRIB_BUFFER_DESTROYED = 0x3095, /** * Specifies whether the context is intended to be low-power or * high-performance. The initial value is * PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_PERFORMANCE. */ PP_GRAPHICS3DATTRIB_GPU_PREFERENCE = 0x11000, /** * The context should be low-power, and may be created on an integrated gpu. */ PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_LOW_POWER = 0x11001, /** * The context may be high-power and may be created on a discrete gpu. */ PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_PERFORMANCE = 0x11002 } PP_Graphics3DAttrib; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Graphics3DAttrib, 4); /** * @} */ #endif /* PPAPI_C_PP_GRAPHICS_3D_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_input_event.h000066400000000000000000000205061321746453100236120ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_input_event.idl modified Thu Mar 28 10:52:59 2013. */ #ifndef PPAPI_C_PP_INPUT_EVENT_H_ #define PPAPI_C_PP_INPUT_EVENT_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/ppb_input_event.h" /** * @file * This file defines the API used to handle mouse and keyboard input events. */ /** * @addtogroup Structs * @{ */ /** * The PP_InputEvent_Key struct represents a key up or key down * event. * * Key up and key down events correspond to physical keys on the keyboard. The * actual character that the user typed (if any) will be delivered in a * "character" event. * * If the user loses focus on the module while a key is down, a key up * event might not occur. For example, if the module has focus and the user * presses and holds the shift key, the module will see a "shift down" message. * Then if the user clicks elsewhere on the web page, the module's focus will * be lost and no more input events will be delivered. * * If your module depends on receiving key up events, it should also handle * "lost focus" as the equivalent of "all keys up." */ struct PP_InputEvent_Key { /** This value is a bit field combination of the EVENT_MODIFIER flags. */ uint32_t modifier; /** * This value reflects the DOM KeyboardEvent keyCode field. * Chrome populates this with the Windows-style Virtual Key code of the key. */ uint32_t key_code; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Key, 8); /** * The PP_InputEvent_Character struct represents a typed character * event. * * Normally, the program will receive a key down event, followed by a character * event, followed by a key up event. The character event will have any * modifier keys applied. Obvious examples are symbols, where Shift-5 gives you * a '%'. The key down and up events will give you the scan code for the "5" * key, and the character event will give you the '%' character. * * You may not get a character event for all key down events if the key doesn't * generate a character. Likewise, you may actually get multiple character * events in a row. For example, some locales have an accent key that modifies * the next character typed. You might get this stream of events: accent down, * accent up (it didn't generate a character), letter key down, letter with * accent character event (it was modified by the previous accent key), letter * key up. If the letter can't be combined with the accent, like an umlaut and * an 'R', the system might send umlaut down, umlaut up, 'R' key down, umlaut * character (can't combine it with 'R', so just send the raw umlaut so it * isn't lost"), 'R' character event, 'R' key up. */ struct PP_InputEvent_Character { /** A combination of the PP_InputEvent_Modifier flags. */ uint32_t modifier; /** * This value represents the typed character as a single null-terminated UTF-8 * character. Any unused bytes will be filled with null bytes. Since the * maximum UTF-8 character is 4 bytes, there will always be at least one null * at the end so you can treat this as a null-terminated UTF-8 string. */ char text[5]; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Character, 12); /** * The PP_InputEvent_Mouse struct represents all mouse events * except mouse wheel events. */ struct PP_InputEvent_Mouse { /** * This value is a bit field combination of the * PP_InputEvent_Modifier flags. */ uint32_t modifier; /** * This value represents the button that changed for mouse down or up events. * This value will be PP_EVENT_MOUSEBUTTON_NONE for mouse move, * enter, and leave events. */ PP_InputEvent_MouseButton button; /** * This values represents the x coordinate of the mouse when the event * occurred. * * In most, but not all, cases these coordinates will just be integers. * For example, the plugin element might be arbitrarily scaled or transformed * in the DOM, and translating a mouse event into the coordinate space of the * plugin will give non-integer values. */ float x; /** * This values represents the y coordinate of the mouse when the event * occurred. * * In most, but not all, cases these coordinates will just be integers. * For example, the plugin element might be arbitrarily scaled or transformed * in the DOM, and translating a mouse event into the coordinate space of the * plugin will give non-integer values. */ float y; /* TODO(brettw) figure out exactly what this means. */ int32_t click_count; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Mouse, 20); /** * The PP_InputEvent_Wheel struct represents all mouse wheel * events. */ struct PP_InputEvent_Wheel { /** * This value represents a combination of the EVENT_MODIFIER * flags. */ uint32_t modifier; /** * The mouse wheel's horizontal scroll amount. A scroll to the right * (where the content moves left) is represented as positive values, * and a scroll to the left (where the content moves right) is * represented as negative values. * * The units are either in pixels (when scroll_by_page is false) or pages * (when scroll_by_page is true). For example, delta_y = -3 means scroll up 3 * pixels when scroll_by_page is false, and scroll up 3 pages when * scroll_by_page is true. * * This amount is system dependent and will take into account the user's * preferred scroll sensitivity and potentially also nonlinear acceleration * based on the speed of the scrolling. * * Devices will be of varying resolution. Some mice with large detents will * only generate integer scroll amounts. But fractional values are also * possible, for example, on some trackpads and newer mice that don't have * "clicks". */ float delta_x; /** * The mouse wheel's vertical scroll amount. A scroll down (where the * content moves up) is represented as positive values, and a scroll up * (where the content moves down) is represented as negative values. * * The units are either in pixels (when scroll_by_page is false) or pages * (when scroll_by_page is true). For example, delta_y = -3 means scroll up 3 * pixels when scroll_by_page is false, and scroll up 3 pages when * scroll_by_page is true. * * This amount is system dependent and will take into account the user's * preferred scroll sensitivity and potentially also nonlinear acceleration * based on the speed of the scrolling. * * Devices will be of varying resolution. Some mice with large detents will * only generate integer scroll amounts. But fractional values are also * possible, for example, on some trackpads and newer mice that don't have * "clicks". */ float delta_y; /** * The number of "clicks" of the scroll wheel that have produced the * event. The value may have system-specific acceleration applied to it, * depending on the device. The positive and negative meanings are the same * as for delta_x and delta_y. * * If you are scrolling, you probably want to use the delta values above. * These tick events can be useful if you aren't doing actual scrolling and * don't want or pixel values. An example may be cycling between different * items in a game. * * You may receive fractional values for the wheel ticks if the mouse wheel * is high resolution or doesn't have "clicks". If your program wants * discrete events (as in the "picking items" example) you should accumulate * fractional click values from multiple messages until the total value * reaches positive or negative one. This should represent a similar amount * of scrolling as for a mouse that has a discrete mouse wheel. */ float wheel_ticks_x; /** This value represents */ float wheel_ticks_y; /** * Indicates if the scroll delta_x/delta_y * indicates pages or lines to scroll by. When true, the user is requesting * to scroll by pages. */ PP_Bool scroll_by_page; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Wheel, 24); /** * @} */ #endif /* PPAPI_C_PP_INPUT_EVENT_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_instance.h000066400000000000000000000017621321746453100230610ustar00rootroot00000000000000/* Copyright (c) 2011 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_instance.idl modified Sat Jul 16 16:50:26 2011. */ #ifndef PPAPI_C_PP_INSTANCE_H_ #define PPAPI_C_PP_INSTANCE_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" /** * @file * This file defines the PP_Instance type which uniquely identifies one module * instance. */ /** * @addtogroup Typedefs * @{ */ /** * The PP_Instance value uniquely identifies one instance of a * module (.nexe/PP_Module). There will be one module instance for every * \ tag on a page. * * This identifier is an opaque handle assigned by the browser to the module. * It is guaranteed never to be 0, so a module can initialize it to 0 to * indicate a "NULL handle." */ typedef int32_t PP_Instance; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Instance, 4); /** * @} */ #endif /* PPAPI_C_PP_INSTANCE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_macros.h000066400000000000000000000065401321746453100225400ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_macros.idl modified Fri Jun 13 10:40:42 2014. */ #ifndef PPAPI_C_PP_MACROS_H_ #define PPAPI_C_PP_MACROS_H_ #define PPAPI_RELEASE 48 /** * @file * Defines the common macros such as assert, inline, ... */ /* * @addtogroup PP * @{ */ /* Use PP_INLINE to tell the compiler to inline functions. The main purpose of * inline functions in ppapi is to allow us to define convenience functions in * the ppapi header files, without requiring clients or implementers to link a * PPAPI C library. The "inline" keyword is not supported by pre-C99 C * compilers (such as MS Visual Studio 2008 and older versions of GCC). MSVS * supports __forceinline and GCC supports __inline__. Use of the static * keyword ensures (in C) that the function is not compiled on its own, which * could cause multiple definition errors. * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx * http://gcc.gnu.org/onlinedocs/gcc/Inline.html */ #if defined(__cplusplus) /* The inline keyword is part of C++ and guarantees we won't get multiple * definition errors. */ # define PP_INLINE inline #else # if defined(_MSC_VER) # define PP_INLINE static __forceinline # else # define PP_INLINE static __inline__ # endif #endif /* This is a compile-time assertion useful for ensuring that a given type is a given number of bytes wide. The size of the array is designed to be 1 (which should always be valid) if the enum's size is SIZE, and otherwise the size of the array will be -1 (which all/most compilers should flag as an error). This is wrapped inside a struct, because if it is a simple global we get multiple definition errors at link time. NAME is the name of the type without any spaces or the struct or enum keywords. CTYPENAME is the typename required by C. I.e., for a struct or enum, the appropriate keyword must be included. SIZE is the expected size in bytes. */ #define PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, CTYPENAME, SIZE) \ struct PP_Dummy_Struct_For_##NAME { \ char _COMPILE_ASSERT_FAILED_The_type_named_ \ ## NAME ## _is_not_ ## SIZE ## \ _bytes_wide[(sizeof(CTYPENAME) == SIZE) ? 1 : -1]; } /* PP_COMPILE_ASSERT_SIZE_IN_BYTES is for typenames that contain no spaces. E.g.: PP_COMPILE_ASSERT_SIZE_IN_BYTES(int, 4); typedef struct { int a; } Foo; PP_COMPILE_ASSERT_SIZE_IN_BYTES(Foo, 4); */ #define PP_COMPILE_ASSERT_SIZE_IN_BYTES(NAME, SIZE) \ PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, NAME, SIZE) /* PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES is for typenames that contain 'struct' in C. That is, struct names that are not typedefs. E.g.: struct Foo { int a; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(Foo, 4); */ #define PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(NAME, SIZE) \ PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, struct NAME, SIZE) /* PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES is for typenames that contain 'enum' in C. That is, enum names that are not typedefs. E.g.: enum Bar { A = 0, B = 1 }; PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(Foo, 4); */ #define PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(NAME, SIZE) \ PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, enum NAME, SIZE) /** * @} * End of addtogroup PP */ #endif /* PPAPI_C_PP_MACROS_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_module.h000066400000000000000000000015641321746453100225420ustar00rootroot00000000000000/* Copyright (c) 2011 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_module.idl modified Sat Jul 16 16:50:26 2011. */ #ifndef PPAPI_C_PP_MODULE_H_ #define PPAPI_C_PP_MODULE_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" /** * @file * This file defines the PP_Module type which uniquely identifies the module * or .nexe. */ /** * @addtogroup Typedefs * @{ */ /** * The PP_Module value uniquely identifies the module or .nexe. * * This identifier is an opaque handle assigned by the browser to the module. It * is guaranteed never to be 0, so a module can initialize it to 0 to * indicate a "NULL handle." */ typedef int32_t PP_Module; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Module, 4); /** * @} */ #endif /* PPAPI_C_PP_MODULE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_point.h000066400000000000000000000036431321746453100224060ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_point.idl modified Wed Oct 5 14:06:02 2011. */ #ifndef PPAPI_C_PP_POINT_H_ #define PPAPI_C_PP_POINT_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" /** * @file * This file defines the API to create a 2 dimensional point. * 0,0 is the upper-left starting coordinate. */ /** * @addtogroup Structs * @{ */ /** * The PP_Point structure defines the integer x and y coordinates of a point. */ struct PP_Point { /** * This value represents the horizontal coordinate of a point, starting with 0 * as the left-most coordinate. */ int32_t x; /** * This value represents the vertical coordinate of a point, starting with 0 * as the top-most coordinate. */ int32_t y; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Point, 8); /** * The PP_FloatPoint structure defines the floating-point x and y coordinates * of a point. */ struct PP_FloatPoint { float x; float y; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FloatPoint, 8); /** * @} */ /** * @addtogroup Functions * @{ */ /** * PP_MakePoint() creates a PP_Point given the x and y coordinates * as int32_t values. * * @param[in] x An int32_t value representing a horizontal coordinate of a * point, starting with 0 as the left-most coordinate. * @param[in] y An int32_t value representing a vertical coordinate of a point, * starting with 0 as the top-most coordinate. * * @return A PP_Point structure. */ PP_INLINE struct PP_Point PP_MakePoint(int32_t x, int32_t y) { struct PP_Point ret; ret.x = x; ret.y = y; return ret; } PP_INLINE struct PP_FloatPoint PP_MakeFloatPoint(float x, float y) { struct PP_FloatPoint ret; ret.x = x; ret.y = y; return ret; } /** * @} */ #endif /* PPAPI_C_PP_POINT_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_rect.h000066400000000000000000000057751321746453100222220ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_rect.idl modified Tue Jun 3 12:31:06 2014. */ #ifndef PPAPI_C_PP_RECT_H_ #define PPAPI_C_PP_RECT_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" /** * @file * This file defines the APIs for creating a 2 dimensional rectangle. */ /** * @addtogroup Structs * @{ */ /** * The PP_Rect struct contains the size and location of a 2D * rectangle. */ struct PP_Rect { /** * This value represents the x and y coordinates of the upper-left corner of * the rectangle. */ struct PP_Point point; /** This value represents the width and height of the rectangle. */ struct PP_Size size; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Rect, 16); /** * The PP_FloatRect struct contains the size and location of a 2D * rectangle. */ struct PP_FloatRect { /** * This value represents the x and y coordinates of the upper-left corner of * the rectangle. */ struct PP_FloatPoint point; /** This value represents the width and height of the rectangle. */ struct PP_FloatSize size; }; /** * @} */ /** * @addtogroup Functions * @{ */ /** * PP_MakeRectFromXYWH() creates a PP_Rect given x and y * coordinates and width and height dimensions as int32_t values. * * @param[in] x An int32_t value representing a horizontal coordinate of a * point, starting with 0 as the left-most coordinate. * @param[in] y An int32_t value representing a vertical coordinate of a point, * starting with 0 as the top-most coordinate. * @param[in] w An int32_t value representing a width. * @param[in] h An int32_t value representing a height. * * @return A PP_Rect structure. */ PP_INLINE struct PP_Rect PP_MakeRectFromXYWH(int32_t x, int32_t y, int32_t w, int32_t h) { struct PP_Rect ret; ret.point.x = x; ret.point.y = y; ret.size.width = w; ret.size.height = h; return ret; } /** * PP_MakeFloatRectFromXYWH() creates a PP_FloatRect given x and y * coordinates and width and height dimensions as float values. * * @param[in] x An float value representing a horizontal coordinate of a * point, starting with 0 as the left-most coordinate. * @param[in] y An float value representing a vertical coordinate of a point, * starting with 0 as the top-most coordinate. * @param[in] w An float value representing a width. * @param[in] h An float value representing a height. * * @return A PP_FloatRect structure. */ PP_INLINE struct PP_FloatRect PP_MakeFloatRectFromXYWH(float x, float y, float w, float h) { struct PP_FloatRect ret; ret.point.x = x; ret.point.y = y; ret.size.width = w; ret.size.height = h; return ret; } /** * @} */ #endif /* PPAPI_C_PP_RECT_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_resource.h000066400000000000000000000025551321746453100231050ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_resource.idl modified Thu Mar 28 10:09:51 2013. */ #ifndef PPAPI_C_PP_RESOURCE_H_ #define PPAPI_C_PP_RESOURCE_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" /** * @file * This file defines the PP_Resource type which represents data * associated with the module. */ /** * @addtogroup Typedefs * @{ */ /** * This typedef represents an opaque handle assigned by the browser to the * resource. The handle is guaranteed never to be 0 for a valid resource, so a * module can initialize it to 0 to indicate a "NULL handle." Some interfaces * may return a NULL resource to indicate failure. * * While a Var represents something callable to JS or from the module to * the DOM, a resource has no meaning or visibility outside of the module * interface. * * Resources are reference counted. Use AddRefResource() * and ReleaseResource() in ppb_core.h to manage the * reference count of a resource. The data will be automatically destroyed when * the internal reference count reaches 0. */ typedef int32_t PP_Resource; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Resource, 4); /** * @} */ #endif /* PPAPI_C_PP_RESOURCE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_size.h000066400000000000000000000036451321746453100222310ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_size.idl modified Tue Jun 3 12:31:20 2014. */ #ifndef PPAPI_C_PP_SIZE_H_ #define PPAPI_C_PP_SIZE_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" /** * @file * This file defines the width and height of a 2D rectangle. */ /** * @addtogroup Structs * @{ */ /** * The PP_Size struct contains the size of a 2D rectangle. */ struct PP_Size { /** This value represents the width of the rectangle. */ int32_t width; /** This value represents the height of the rectangle. */ int32_t height; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Size, 8); /** * The PP_FloatSize struct contains the size of a 2D rectangle. */ struct PP_FloatSize { /** This value represents the width of the rectangle. */ float width; /** This value represents the height of the rectangle. */ float height; }; /** * @} */ /** * @addtogroup Functions * @{ */ /** * PP_MakeSize() creates a PP_Size given a width and height as * int32_t values. * * @param[in] w An int32_t value representing a width. * @param[in] h An int32_t value representing a height. * * @return A PP_Size structure. */ PP_INLINE struct PP_Size PP_MakeSize(int32_t w, int32_t h) { struct PP_Size ret; ret.width = w; ret.height = h; return ret; } /** * PP_MakeFloatSize() creates a PP_FloatSize given a * width and height as float values. * * @param[in] w An float value representing a width. * @param[in] h An float value representing a height. * * @return A PP_FloatSize structure. */ PP_INLINE struct PP_FloatSize PP_MakeFloatSize(float w, float h) { struct PP_FloatSize ret; ret.width = w; ret.height = h; return ret; } /** * @} */ #endif /* PPAPI_C_PP_SIZE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_stdint.h000066400000000000000000000025521321746453100225600ustar00rootroot00000000000000/* Copyright (c) 2011 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_stdint.idl modified Mon Jul 18 17:53:53 2011. */ #ifndef PPAPI_C_PP_STDINT_H_ #define PPAPI_C_PP_STDINT_H_ #include "ppapi/c/pp_macros.h" /** * @file * This file provides a definition of C99 sized types * for Microsoft compilers. These definitions only apply * for trusted modules. */ /** * * @addtogroup Typedefs * @{ */ #if defined(_MSC_VER) /** This value represents a guaranteed unsigned 8 bit integer. */ typedef unsigned char uint8_t; /** This value represents a guaranteed signed 8 bit integer. */ typedef signed char int8_t; /** This value represents a guaranteed unsigned 16 bit short. */ typedef unsigned short uint16_t; /** This value represents a guaranteed signed 16 bit short. */ typedef short int16_t; /** This value represents a guaranteed unsigned 32 bit integer. */ typedef unsigned int uint32_t; /** This value represents a guaranteed signed 32 bit integer. */ typedef int int32_t; /** This value represents a guaranteed signed 64 bit integer. */ typedef __int64 int64_t; /** This value represents a guaranteed unsigned 64 bit integer. */ typedef unsigned __int64 uint64_t; #else #include #endif /** * @} */ #endif /* PPAPI_C_PP_STDINT_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_time.h000066400000000000000000000030261321746453100222060ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_time.idl modified Fri May 10 15:48:42 2013. */ #ifndef PPAPI_C_PP_TIME_H_ #define PPAPI_C_PP_TIME_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" /** * @file * This file defines time, time ticks and time delta types. */ /** * @addtogroup Typedefs * @{ */ /** * The PP_Time type represents the "wall clock time" according * to the browser and is defined as the number of seconds since the Epoch * (00:00:00 UTC, January 1, 1970). */ typedef double PP_Time; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Time, 8); /** * A PP_TimeTicks value represents time ticks which are measured * in seconds and are used for indicating the time that certain messages were * received. In contrast to PP_Time, PP_TimeTicks * does not correspond to any actual wall clock time and will not change * discontinuously if the user changes their computer clock. * * The units are in seconds, but are not measured relative to any particular * epoch, so the most you can do is compare two values. */ typedef double PP_TimeTicks; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TimeTicks, 8); /** * A PP_TimeDelta value represents a duration of time which is * measured in seconds. */ typedef double PP_TimeDelta; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TimeDelta, 8); /** * @} */ #endif /* PPAPI_C_PP_TIME_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_touch_point.h000066400000000000000000000047101321746453100236040ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_touch_point.idl modified Thu Mar 28 10:13:07 2013. */ #ifndef PPAPI_C_PP_TOUCH_POINT_H_ #define PPAPI_C_PP_TOUCH_POINT_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_stdint.h" /** * @file * This file defines the API to create a touch point or position where fingers * makes contact with touch screen device. */ /** * @addtogroup Structs * @{ */ /** * The PP_TouchPoint struct represents all information about a * single touch point, such as position, id, rotation angle, and pressure. */ struct PP_TouchPoint { /** * This value represents the identifier for this TouchPoint. The id * corresponds to the order in which the points were pressed. For example, * the first point to be pressed has an id of 0, the second has an id of 1, * and so on. An id can be reused when a touch point is released. For * example, if two fingers are down, with id 0 and 1, and finger 0 releases, * the next finger to be pressed can be assigned to id 0. */ uint32_t id; /** * This value represents the x and y pixel position of this TouchPoint * relative to the upper-left of the module instance receiving the event. */ struct PP_FloatPoint position; /** * This value represents the elliptical radii, in screen pixels, in the x * and y direction of this TouchPoint. */ struct PP_FloatPoint radius; /** * This value represents the angle of rotation in degrees of the elliptical * model of this TouchPoint clockwise from "up." */ float rotation_angle; /** * This value represents the pressure applied to this TouchPoint. This value * is typically between 0 and 1, with 0 indicating no pressure and 1 * indicating some maximum pressure. Scaling differs depending on the * hardware and the value is not guaranteed to stay within that range. */ float pressure; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_TouchPoint, 28); /** * @} */ /** * @addtogroup Functions * @{ */ /** * PP_MakeTouchPoint() creates a PP_TouchPoint. * * @return A PP_TouchPoint structure. */ PP_INLINE struct PP_TouchPoint PP_MakeTouchPoint(void) { struct PP_TouchPoint result = { 0, {0, 0}, {0, 0}, 0, 0 }; return result; } /** * @} */ #endif /* PPAPI_C_PP_TOUCH_POINT_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/pp_var.h000066400000000000000000000204611321746453100220420ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_var.idl modified Thu Apr 10 14:52:30 2014. */ #ifndef PPAPI_C_PP_VAR_H_ #define PPAPI_C_PP_VAR_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" /** * @file * This file defines the API for handling the passing of data types between * your module and the page. */ /** * @addtogroup Enums * @{ */ /** * The PP_VarType is an enumeration of the different types that * can be contained within a PP_Var structure. */ typedef enum { /** * An undefined value. */ PP_VARTYPE_UNDEFINED = 0, /** * A NULL value. This is similar to undefined, but JavaScript differentiates * the two so it is exposed here as well. */ PP_VARTYPE_NULL = 1, /** * A boolean value, use the as_bool member of the var. */ PP_VARTYPE_BOOL = 2, /** * A 32-bit integer value. Use the as_int member of the var. */ PP_VARTYPE_INT32 = 3, /** * A double-precision floating point value. Use the as_double * member of the var. */ PP_VARTYPE_DOUBLE = 4, /** * The Var represents a string. The as_id field is used to * identify the string, which may be created and retrieved from the * PPB_Var interface. These objects are reference counted, so * AddRef() and Release() must be used properly to avoid memory leaks. */ PP_VARTYPE_STRING = 5, /** * Represents a JavaScript object. This vartype is not currently usable * from modules, although it is used internally for some tasks. These objects * are reference counted, so AddRef() and Release() must be used properly to * avoid memory leaks. */ PP_VARTYPE_OBJECT = 6, /** * Represents an array of Vars. The as_id field is used to * identify the array, which may be created and manipulated from the * PPB_VarArray interface. These objects are reference counted, * so AddRef() and Release() must be used properly to avoid memory leaks. */ PP_VARTYPE_ARRAY = 7, /** * Represents a mapping from strings to Vars. The as_id field is * used to identify the dictionary, which may be created and manipulated from * the PPB_VarDictionary interface. These objects are reference * counted, so AddRef() and Release() must be used properly to avoid memory * leaks. */ PP_VARTYPE_DICTIONARY = 8, /** * ArrayBuffer represents a JavaScript ArrayBuffer. This is the type which * represents Typed Arrays in JavaScript. Unlike JavaScript 'Array', it is * only meant to contain basic numeric types, and is always stored * contiguously. See PPB_VarArrayBuffer_Dev for functions special to * ArrayBuffer vars. These objects are reference counted, so AddRef() and * Release() must be used properly to avoid memory leaks. */ PP_VARTYPE_ARRAY_BUFFER = 9, /** * This type allows the PP_Var to wrap a PP_Resource * . This can be useful for sending or receiving some types of * PP_Resource using PPB_Messaging or * PPP_Messaging. * * These objects are reference counted, so AddRef() and Release() must be used * properly to avoid memory leaks. Under normal circumstances, the * PP_Var will implicitly hold a reference count on the * PP_Resource on your behalf. For example, if you call * VarFromResource(), it implicitly calls PPB_Core::AddRefResource() on the * PP_Resource. Likewise, PPB_Var::Release() on a Resource * PP_Var will invoke PPB_Core::ReleaseResource() when the Var * reference count goes to zero. */ PP_VARTYPE_RESOURCE = 10 } PP_VarType; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VarType, 4); /** * @} */ /** * @addtogroup Structs * @{ */ /** * The PP_VarValue union stores the data for any one of the types listed * in the PP_VarType enum. */ union PP_VarValue { /** * If type is PP_VARTYPE_BOOL, * as_bool represents the value of this PP_Var as * PP_Bool. */ PP_Bool as_bool; /** * If type is PP_VARTYPE_INT32, * as_int represents the value of this PP_Var as * int32_t. */ int32_t as_int; /** * If type is PP_VARTYPE_DOUBLE, * as_double represents the value of this PP_Var * as double. */ double as_double; /** * If type is PP_VARTYPE_STRING, * PP_VARTYPE_OBJECT, PP_VARTYPE_ARRAY, * PP_VARTYPE_DICTIONARY, PP_VARTYPE_ARRAY_BUFFER, * or PP_VARTYPE_RESOURCE, as_id represents the * value of this PP_Var as an opaque handle assigned by the * browser. This handle is guaranteed never to be 0, so a module can * initialize this ID to 0 to indicate a "NULL handle." */ int64_t as_id; }; /** * The PP_VAR struct is a variant data type and can contain any * value of one of the types named in the PP_VarType enum. This * structure is for passing data between native code which can be strongly * typed and the browser (JavaScript) which isn't strongly typed. * * JavaScript has a "number" type for holding a number, and does not * differentiate between floating point and integer numbers. The * JavaScript operations will try to optimize operations by using * integers when possible, but could end up with doubles. Therefore, * you can't assume a numeric PP_Var will be the type you expect. * Your code should be capable of handling either int32_t or double for numeric * PP_Vars sent from JavaScript. */ struct PP_Var { PP_VarType type; /** * The padding ensures value is aligned on an * 8-byte boundary relative to the start of the struct. Some compilers * align doubles on 8-byte boundaries for 32-bit x86, and some align on * 4-byte boundaries. */ int32_t padding; /** * This value represents the contents of the PP_Var. Only one of * the fields of value is valid at a time based upon * type. */ union PP_VarValue value; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Var, 16); /** * @} */ /** * @addtogroup Functions * @{ */ /** * PP_MakeUndefined() is used to wrap an undefined value into a * PP_Var struct for passing to the browser. * * @return A PP_Var structure. */ PP_INLINE struct PP_Var PP_MakeUndefined(void) { struct PP_Var result = { PP_VARTYPE_UNDEFINED, 0, {PP_FALSE} }; return result; } /** * PP_MakeNull() is used to wrap a null value into a * PP_Var struct for passing to the browser. * * @return A PP_Var structure, */ PP_INLINE struct PP_Var PP_MakeNull(void) { struct PP_Var result = { PP_VARTYPE_NULL, 0, {PP_FALSE} }; return result; } /** * PP_MakeBool() is used to wrap a boolean value into a * PP_Var struct for passing to the browser. * * @param[in] value A PP_Bool enumeration to * wrap. * * @return A PP_Var structure. */ PP_INLINE struct PP_Var PP_MakeBool(PP_Bool value) { struct PP_Var result = { PP_VARTYPE_BOOL, 0, {PP_FALSE} }; result.value.as_bool = value; return result; } /** * PP_MakeInt32() is used to wrap a 32 bit integer value * into a PP_Var struct for passing to the browser. * * @param[in] value An int32 to wrap. * * @return A PP_Var structure. */ PP_INLINE struct PP_Var PP_MakeInt32(int32_t value) { struct PP_Var result = { PP_VARTYPE_INT32, 0, {PP_FALSE} }; result.value.as_int = value; return result; } /** * PP_MakeDouble() is used to wrap a double value into a * PP_Var struct for passing to the browser. * * @param[in] value A double to wrap. * * @return A PP_Var structure. */ PP_INLINE struct PP_Var PP_MakeDouble(double value) { struct PP_Var result = { PP_VARTYPE_DOUBLE, 0, {PP_FALSE} }; result.value.as_double = value; return result; } /** * @} */ #endif /* PPAPI_C_PP_VAR_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb.h000066400000000000000000000025551321746453100213400ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb.idl modified Fri Jan 24 16:19:56 2014. */ #ifndef PPAPI_C_PPB_H_ #define PPAPI_C_PPB_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" /** * @file * This file defines a function pointer type for the * PPB_GetInterface function. */ /** * @addtogroup Typedefs * @{ */ /** * This function pointer type defines the signature for the * PPB_GetInterface function. A generic * PPB_GetInterface pointer is passed to * PPP_InitializedModule when your module is loaded. You can use * this pointer to request a pointer to a specific browser interface. Browser * interface names are ASCII strings and are generally defined in the header * file for the interface, such as PPB_AUDIO_INTERFACE found in * ppb.audio.h or * PPB_GRAPHICS_2D_INTERFACE in ppb_graphics_2d.h. * Click * here for a complete list of interface * names. * * This value will be NULL if the interface is not supported on the browser. */ typedef const void* (*PPB_GetInterface)(const char* interface_name); /** * @} */ #endif /* PPAPI_C_PPB_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_audio.h000066400000000000000000000157231321746453100225220ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_audio.idl modified Fri Jan 24 16:18:44 2014. */ #ifndef PPAPI_C_PPB_AUDIO_H_ #define PPAPI_C_PPB_AUDIO_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" #define PPB_AUDIO_INTERFACE_1_0 "PPB_Audio;1.0" #define PPB_AUDIO_INTERFACE_1_1 "PPB_Audio;1.1" #define PPB_AUDIO_INTERFACE PPB_AUDIO_INTERFACE_1_1 /** * @file * This file defines the PPB_Audio interface, which provides * realtime stereo audio streaming capabilities. */ /** * @addtogroup Typedefs * @{ */ /** * PPB_Audio_Callback defines the type of an audio callback * function used to fill the audio buffer with data. Please see the * Create() function in the PPB_Audio interface for * more details on this callback. * * @param[in] sample_buffer A buffer to fill with audio data. * @param[in] buffer_size_in_bytes The size of the buffer in bytes. * @param[in] latency How long before the audio data is to be presented. * @param[inout] user_data An opaque pointer that was passed into * PPB_Audio.Create(). */ typedef void (*PPB_Audio_Callback)(void* sample_buffer, uint32_t buffer_size_in_bytes, PP_TimeDelta latency, void* user_data); typedef void (*PPB_Audio_Callback_1_0)(void* sample_buffer, uint32_t buffer_size_in_bytes, void* user_data); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_Audio interface contains pointers to several functions * for handling audio resources. Refer to the * Audio * chapter in the Developer's Guide for information on using this interface. * Please see descriptions for each PPB_Audio and * PPB_AudioConfig function for more details. A C example using * PPB_Audio and PPB_AudioConfig follows. * * Example: * * @code * void audio_callback(void* sample_buffer, * uint32_t buffer_size_in_bytes, * void* user_data) { * ... quickly fill in the buffer with samples and return to caller ... * } * * ...Assume the application has cached the audio configuration interface in * audio_config_interface and the audio interface in * audio_interface... * * uint32_t count = audio_config_interface->RecommendSampleFrameCount( * PP_AUDIOSAMPLERATE_44100, 4096); * PP_Resource pp_audio_config = audio_config_interface->CreateStereo16Bit( * pp_instance, PP_AUDIOSAMPLERATE_44100, count); * PP_Resource pp_audio = audio_interface->Create(pp_instance, pp_audio_config, * audio_callback, NULL); * audio_interface->StartPlayback(pp_audio); * * ...audio_callback() will now be periodically invoked on a separate thread... * @endcode */ struct PPB_Audio_1_1 { /** * Create() creates an audio resource. No sound will be heard until * StartPlayback() is called. The callback is called with the buffer address * and given user data whenever the buffer needs to be filled. From within the * callback, you should not call PPB_Audio functions. The * callback will be called on a different thread than the one which created * the interface. For performance-critical applications (i.e. low-latency * audio), the callback should avoid blocking or calling functions that can * obtain locks, such as malloc. The layout and the size of the buffer passed * to the audio callback will be determined by the device configuration and is * specified in the AudioConfig documentation. * * @param[in] instance A PP_Instance identifying one instance * of a module. * @param[in] config A PP_Resource corresponding to an audio * config resource. * @param[in] audio_callback A PPB_Audio_Callback callback * function that the browser calls when it needs more samples to play. * @param[in] user_data A pointer to user data used in the callback function. * * @return A PP_Resource containing the audio resource if * successful or 0 if the configuration cannot be honored or the callback is * null. */ PP_Resource (*Create)(PP_Instance instance, PP_Resource config, PPB_Audio_Callback audio_callback, void* user_data); /** * IsAudio() determines if the provided resource is an audio resource. * * @param[in] resource A PP_Resource corresponding to a generic * resource. * * @return A PP_Bool containing containing PP_TRUE * if the given resource is an Audio resource, otherwise * PP_FALSE. */ PP_Bool (*IsAudio)(PP_Resource resource); /** * GetCurrrentConfig() returns an audio config resource for the given audio * resource. * * @param[in] config A PP_Resource corresponding to an audio * resource. * * @return A PP_Resource containing the audio config resource if * successful. */ PP_Resource (*GetCurrentConfig)(PP_Resource audio); /** * StartPlayback() starts the playback of the audio resource and begins * periodically calling the callback. * * @param[in] config A PP_Resource corresponding to an audio * resource. * * @return A PP_Bool containing PP_TRUE if * successful, otherwise PP_FALSE. Also returns * PP_TRUE (and be a no-op) if called while playback is already * in progress. */ PP_Bool (*StartPlayback)(PP_Resource audio); /** * StopPlayback() stops the playback of the audio resource. * * @param[in] config A PP_Resource corresponding to an audio * resource. * * @return A PP_Bool containing PP_TRUE if * successful, otherwise PP_FALSE. Also returns * PP_TRUE (and is a no-op) if called while playback is already * stopped. If a callback is in progress, StopPlayback() will block until the * callback completes. */ PP_Bool (*StopPlayback)(PP_Resource audio); }; typedef struct PPB_Audio_1_1 PPB_Audio; struct PPB_Audio_1_0 { PP_Resource (*Create)(PP_Instance instance, PP_Resource config, PPB_Audio_Callback_1_0 audio_callback, void* user_data); PP_Bool (*IsAudio)(PP_Resource resource); PP_Resource (*GetCurrentConfig)(PP_Resource audio); PP_Bool (*StartPlayback)(PP_Resource audio); PP_Bool (*StopPlayback)(PP_Resource audio); }; /** * @} */ #endif /* PPAPI_C_PPB_AUDIO_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_audio_buffer.h000066400000000000000000000107741321746453100240540ustar00rootroot00000000000000/* Copyright 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_audio_buffer.idl modified Tue Mar 25 18:29:27 2014. */ #ifndef PPAPI_C_PPB_AUDIO_BUFFER_H_ #define PPAPI_C_PPB_AUDIO_BUFFER_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" #define PPB_AUDIOBUFFER_INTERFACE_0_1 "PPB_AudioBuffer;0.1" #define PPB_AUDIOBUFFER_INTERFACE PPB_AUDIOBUFFER_INTERFACE_0_1 /** * @file * Defines the PPB_AudioBuffer interface. */ /** * @addtogroup Enums * @{ */ /** * PP_AudioBuffer_SampleRate is an enumeration of the different audio sample * rates. */ typedef enum { PP_AUDIOBUFFER_SAMPLERATE_UNKNOWN = 0, PP_AUDIOBUFFER_SAMPLERATE_8000 = 8000, PP_AUDIOBUFFER_SAMPLERATE_16000 = 16000, PP_AUDIOBUFFER_SAMPLERATE_22050 = 22050, PP_AUDIOBUFFER_SAMPLERATE_32000 = 32000, PP_AUDIOBUFFER_SAMPLERATE_44100 = 44100, PP_AUDIOBUFFER_SAMPLERATE_48000 = 48000, PP_AUDIOBUFFER_SAMPLERATE_96000 = 96000, PP_AUDIOBUFFER_SAMPLERATE_192000 = 192000 } PP_AudioBuffer_SampleRate; /** * PP_AudioBuffer_SampleSize is an enumeration of the different audio sample * sizes. */ typedef enum { PP_AUDIOBUFFER_SAMPLESIZE_UNKNOWN = 0, PP_AUDIOBUFFER_SAMPLESIZE_16_BITS = 2 } PP_AudioBuffer_SampleSize; /** * @} */ /** * @addtogroup Interfaces * @{ */ struct PPB_AudioBuffer_0_1 { /** * Determines if a resource is an AudioBuffer resource. * * @param[in] resource The PP_Resource to test. * * @return A PP_Bool with PP_TRUE if the given * resource is an AudioBuffer resource or PP_FALSE otherwise. */ PP_Bool (*IsAudioBuffer)(PP_Resource resource); /** * Gets the timestamp of the audio buffer. * * @param[in] buffer A PP_Resource corresponding to an audio * buffer resource. * * @return A PP_TimeDelta containing the timestamp of the audio * buffer. Given in seconds since the start of the containing audio stream. */ PP_TimeDelta (*GetTimestamp)(PP_Resource buffer); /** * Sets the timestamp of the audio buffer. * * @param[in] buffer A PP_Resource corresponding to an audio * buffer resource. * @param[in] timestamp A PP_TimeDelta containing the timestamp * of the audio buffer. Given in seconds since the start of the containing * audio stream. */ void (*SetTimestamp)(PP_Resource buffer, PP_TimeDelta timestamp); /** * Gets the sample rate of the audio buffer. * * @param[in] buffer A PP_Resource corresponding to an audio * buffer resource. * * @return The sample rate of the audio buffer. */ PP_AudioBuffer_SampleRate (*GetSampleRate)(PP_Resource buffer); /** * Gets the sample size of the audio buffer. * * @param[in] buffer A PP_Resource corresponding to an audio * buffer resource. * * @return The sample size of the audio buffer. */ PP_AudioBuffer_SampleSize (*GetSampleSize)(PP_Resource buffer); /** * Gets the number of channels in the audio buffer. * * @param[in] buffer A PP_Resource corresponding to an audio * buffer resource. * * @return The number of channels in the audio buffer. */ uint32_t (*GetNumberOfChannels)(PP_Resource buffer); /** * Gets the number of samples in the audio buffer. * * @param[in] buffer A PP_Resource corresponding to an audio * buffer resource. * * @return The number of samples in the audio buffer. * For example, at a sampling rate of 44,100 Hz in stereo audio, a buffer * containing 4410 * 2 samples would have a duration of 100 milliseconds. */ uint32_t (*GetNumberOfSamples)(PP_Resource buffer); /** * Gets the data buffer containing the audio samples. * * @param[in] buffer A PP_Resource corresponding to an audio * buffer resource. * * @return A pointer to the beginning of the data buffer. */ void* (*GetDataBuffer)(PP_Resource buffer); /** * Gets the size of the data buffer in bytes. * * @param[in] buffer A PP_Resource corresponding to an audio * buffer resource. * * @return The size of the data buffer in bytes. */ uint32_t (*GetDataBufferSize)(PP_Resource buffer); }; typedef struct PPB_AudioBuffer_0_1 PPB_AudioBuffer; /** * @} */ #endif /* PPAPI_C_PPB_AUDIO_BUFFER_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_audio_config.h000066400000000000000000000175521321746453100240510ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_audio_config.idl modified Fri Jan 24 16:19:35 2014. */ #ifndef PPAPI_C_PPB_AUDIO_CONFIG_H_ #define PPAPI_C_PPB_AUDIO_CONFIG_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_AUDIO_CONFIG_INTERFACE_1_0 "PPB_AudioConfig;1.0" #define PPB_AUDIO_CONFIG_INTERFACE_1_1 "PPB_AudioConfig;1.1" #define PPB_AUDIO_CONFIG_INTERFACE PPB_AUDIO_CONFIG_INTERFACE_1_1 /** * @file * This file defines the PPB_AudioConfig interface for establishing an * audio configuration resource within the browser. */ /** * @addtogroup Enums * @{ */ /** * This enumeration contains audio frame count constants. * PP_AUDIOMINSAMPLEFRAMECOUNT is the minimum possible frame * count. PP_AUDIOMAXSAMPLEFRAMECOUNT is the maximum possible * frame count. */ enum { PP_AUDIOMINSAMPLEFRAMECOUNT = 64, PP_AUDIOMAXSAMPLEFRAMECOUNT = 32768 }; /** * PP_AudioSampleRate is an enumeration of the different audio sampling rates. * PP_AUDIOSAMPLERATE_44100 is the sample rate used on CDs and * PP_AUDIOSAMPLERATE_48000 is the sample rate used on DVDs and * Digital Audio Tapes. */ typedef enum { PP_AUDIOSAMPLERATE_NONE = 0, PP_AUDIOSAMPLERATE_44100 = 44100, PP_AUDIOSAMPLERATE_48000 = 48000 } PP_AudioSampleRate; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_AudioSampleRate, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_AudioConfig interface contains pointers to several * functions for establishing your audio configuration within the browser. * This interface only supports 16-bit stereo output. * * Refer to the * Audio * chapter in the Developer's Guide for information on using this * interface. */ struct PPB_AudioConfig_1_1 { /** * CreateStereo16bit() creates a 16 bit audio configuration resource. The * sample_rate should be the result of calling * RecommendSampleRate and sample_frame_count should * be the result of calling RecommendSampleFrameCount. If the * sample frame count or bit rate isn't supported, this function will fail and * return a null resource. * * A single sample frame on a stereo device means one value for the left * channel and one value for the right channel. * * Buffer layout for a stereo int16 configuration: * int16_t *buffer16; * buffer16[0] is the first left channel sample. * buffer16[1] is the first right channel sample. * buffer16[2] is the second left channel sample. * buffer16[3] is the second right channel sample. * ... * buffer16[2 * (sample_frame_count - 1)] is the last left * channel sample. * buffer16[2 * (sample_frame_count - 1) + 1] is the last * right channel sample. * Data will always be in the native endian format of the platform. * * @param[in] instance A PP_Instance identifying one instance * of a module. * @param[in] sample_rate A PP_AudioSampleRate which is either * PP_AUDIOSAMPLERATE_44100 or * PP_AUDIOSAMPLERATE_48000. * @param[in] sample_frame_count A uint32_t frame count returned * from the RecommendSampleFrameCount function. * * @return A PP_Resource containing the * PPB_Audio_Config if successful or a null resource if the * sample frame count or bit rate are not supported. */ PP_Resource (*CreateStereo16Bit)(PP_Instance instance, PP_AudioSampleRate sample_rate, uint32_t sample_frame_count); /** * RecommendSampleFrameCount() returns the supported sample frame count * closest to the requested count. The sample frame count determines the * overall latency of audio. Since one "frame" is always buffered in advance, * smaller frame counts will yield lower latency, but higher CPU utilization. * * Supported sample frame counts will vary by hardware and system (consider * that the local system might be anywhere from a cell phone or a high-end * audio workstation). Sample counts less than * PP_AUDIOMINSAMPLEFRAMECOUNT and greater than * PP_AUDIOMAXSAMPLEFRAMECOUNT are never supported on any * system, but values in between aren't necessarily valid. This function * will return a supported count closest to the requested frame count. * * RecommendSampleFrameCount() result is intended for audio output devices. * * @param[in] instance * @param[in] sample_rate A PP_AudioSampleRate which is either * PP_AUDIOSAMPLERATE_44100 or * PP_AUDIOSAMPLERATE_48000. * @param[in] requested_sample_frame_count A uint_32t requested * frame count. * * @return A uint32_t containing the recommended sample frame * count if successful. */ uint32_t (*RecommendSampleFrameCount)( PP_Instance instance, PP_AudioSampleRate sample_rate, uint32_t requested_sample_frame_count); /** * IsAudioConfig() determines if the given resource is a * PPB_Audio_Config. * * @param[in] resource A PP_Resource corresponding to an audio * config resource. * * @return A PP_Bool containing PP_TRUE if the given * resource is an AudioConfig resource, otherwise * PP_FALSE. */ PP_Bool (*IsAudioConfig)(PP_Resource resource); /** * GetSampleRate() returns the sample rate for the given * PPB_Audio_Config. * * @param[in] config A PP_Resource corresponding to a * PPB_Audio_Config. * * @return A PP_AudioSampleRate containing sample rate or * PP_AUDIOSAMPLERATE_NONE if the resource is invalid. */ PP_AudioSampleRate (*GetSampleRate)(PP_Resource config); /** * GetSampleFrameCount() returns the sample frame count for the given * PPB_Audio_Config. * * @param[in] config A PP_Resource corresponding to an audio * config resource. * * @return A uint32_t containing sample frame count or * 0 if the resource is invalid. Refer to * RecommendSampleFrameCount() for more on sample frame counts. */ uint32_t (*GetSampleFrameCount)(PP_Resource config); /** * RecommendSampleRate() returns the native sample rate that the browser * is using in the backend. Applications that use the recommended sample * rate will have potentially better latency and fidelity. The return value * is intended for audio output devices. If the output sample rate cannot be * determined, this function can return PP_AUDIOSAMPLERATE_NONE. * * @param[in] instance * * @return A uint32_t containing the recommended sample frame * count if successful. */ PP_AudioSampleRate (*RecommendSampleRate)(PP_Instance instance); }; typedef struct PPB_AudioConfig_1_1 PPB_AudioConfig; struct PPB_AudioConfig_1_0 { PP_Resource (*CreateStereo16Bit)(PP_Instance instance, PP_AudioSampleRate sample_rate, uint32_t sample_frame_count); uint32_t (*RecommendSampleFrameCount)( PP_AudioSampleRate sample_rate, uint32_t requested_sample_frame_count); PP_Bool (*IsAudioConfig)(PP_Resource resource); PP_AudioSampleRate (*GetSampleRate)(PP_Resource config); uint32_t (*GetSampleFrameCount)(PP_Resource config); }; /** * @} */ #endif /* PPAPI_C_PPB_AUDIO_CONFIG_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_audio_encoder.h000066400000000000000000000222151321746453100242130ustar00rootroot00000000000000/* Copyright 2015 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_audio_encoder.idl modified Mon Sep 7 10:17:53 2015. */ #ifndef PPAPI_C_PPB_AUDIO_ENCODER_H_ #define PPAPI_C_PPB_AUDIO_ENCODER_H_ #include "ppapi/c/pp_array_output.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_codecs.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/ppb_audio_buffer.h" #define PPB_AUDIOENCODER_INTERFACE_0_1 "PPB_AudioEncoder;0.1" /* dev */ /** * @file * This file defines the PPB_AudioEncoder interface. */ /** * @addtogroup Interfaces * @{ */ /** * Audio encoder interface. * * Typical usage: * - Call Create() to create a new audio encoder resource. * - Call GetSupportedProfiles() to determine which codecs and profiles are * available. * - Call Initialize() to initialize the encoder for a supported profile. * - Call GetBuffer() to get an empty buffer and fill it in, or get an audio * buffer from another resource, e.g. PPB_MediaStreamAudioTrack. * - Call Encode() to push the audio buffer to the encoder. If an external * buffer is pushed, wait for completion to recycle the buffer. * - Call GetBitstreamBuffer() continuously (waiting for each previous call to * complete) to pull encoded buffers from the encoder. * - Call RecycleBitstreamBuffer() after consuming the data in the bitstream * buffer. * - To destroy the encoder, the plugin should release all of its references to * it. Any pending callbacks will abort before the encoder is destroyed. * * Available audio codecs vary by platform. * All: opus. */ struct PPB_AudioEncoder_0_1 { /* dev */ /** * Creates a new audio encoder resource. * * @param[in] instance A PP_Instance identifying the instance * with the audio encoder. * * @return A PP_Resource corresponding to an audio encoder if * successful or 0 otherwise. */ PP_Resource (*Create)(PP_Instance instance); /** * Determines if the given resource is an audio encoder. * * @param[in] resource A PP_Resource identifying a resource. * * @return PP_TRUE if the resource is a * PPB_AudioEncoder, PP_FALSE if the resource is * invalid or some other type. */ PP_Bool (*IsAudioEncoder)(PP_Resource resource); /** * Gets an array of supported audio encoder profiles. * These can be used to choose a profile before calling Initialize(). * * @param[in] audio_encoder A PP_Resource identifying the audio * encoder. * @param[in] output A PP_ArrayOutput to receive the supported * PP_AudioProfileDescription structs. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return If >= 0, the number of supported profiles returned, otherwise an * error code from pp_errors.h. */ int32_t (*GetSupportedProfiles)(PP_Resource audio_encoder, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); /** * Initializes an audio encoder resource. The plugin should call Initialize() * successfully before calling any of the functions below. * * @param[in] audio_encoder A PP_Resource identifying the audio * encoder. * @param[in] channels The number of audio channels to encode. * @param[in] input_sampling_rate The sampling rate of the input audio buffer. * @param[in] input_sample_size The sample size of the input audio buffer. * @param[in] output_profile A PP_AudioProfile specifying the * codec profile of the encoded output stream. * @param[in] initial_bitrate The initial bitrate for the encoder. * @param[in] acceleration A PP_HardwareAcceleration specifying * whether to use a hardware accelerated or a software implementation. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h. * Returns PP_ERROR_NOTSUPPORTED if audio encoding is not available, or the * requested codec profile is not supported. */ int32_t (*Initialize)(PP_Resource audio_encoder, uint32_t channels, PP_AudioBuffer_SampleRate input_sample_rate, PP_AudioBuffer_SampleSize input_sample_size, PP_AudioProfile output_profile, uint32_t initial_bitrate, PP_HardwareAcceleration acceleration, struct PP_CompletionCallback callback); /** * Gets the number of audio samples per channel that audio buffers must * contain in order to be processed by the encoder. This will be the number of * samples per channels contained in buffers returned by GetBuffer(). * * @param[in] audio_encoder A PP_Resource identifying the audio * encoder. * @return An int32_t containing the number of samples required, or an error * code from pp_errors.h. * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. */ int32_t (*GetNumberOfSamples)(PP_Resource audio_encoder); /** * Gets a blank audio buffer (with metadata given by the Initialize() * call) which can be filled with audio data and passed to the encoder. * * @param[in] audio_encoder A PP_Resource identifying the audio * encoder. * @param[out] audio_buffer A blank PPB_AudioBuffer resource. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h. * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. */ int32_t (*GetBuffer)(PP_Resource audio_encoder, PP_Resource* audio_buffer, struct PP_CompletionCallback callback); /** * Encodes an audio buffer. * * @param[in] audio_encoder A PP_Resource identifying the audio * encoder. * @param[in] audio_buffer The PPB_AudioBuffer to be encoded. * @param[in] callback A PP_CompletionCallback to be called upon * completion. Plugins that pass PPB_AudioBuffer resources owned * by other resources should wait for completion before reusing them. * * @return An int32_t containing an error code from pp_errors.h. * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. */ int32_t (*Encode)(PP_Resource audio_encoder, PP_Resource audio_buffer, struct PP_CompletionCallback callback); /** * Gets the next encoded bitstream buffer from the encoder. * * @param[in] audio_encoder A PP_Resource identifying the audio * encoder. * @param[out] bitstream_buffer A PP_BitstreamBuffer containing * encoded audio data. * @param[in] callback A PP_CompletionCallback to be called upon * completion. The plugin can call GetBitstreamBuffer from the callback in * order to continuously "pull" bitstream buffers from the encoder. * * @return An int32_t containing an error code from pp_errors.h. * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. * Returns PP_ERROR_INPROGRESS if a prior call to GetBitstreamBuffer() has * not completed. */ int32_t (*GetBitstreamBuffer)( PP_Resource audio_encoder, struct PP_AudioBitstreamBuffer* bitstream_buffer, struct PP_CompletionCallback callback); /** * Recycles a bitstream buffer back to the encoder. * * @param[in] audio_encoder A PP_Resource identifying the audio * encoder. * @param[in] bitstream_buffer A PP_BitstreamBuffer that is no * longer needed by the plugin. */ void (*RecycleBitstreamBuffer)( PP_Resource audio_encoder, const struct PP_AudioBitstreamBuffer* bitstream_buffer); /** * Requests a change to the encoding bitrate. This is only a request, * fulfilled on a best-effort basis. * * @param[in] audio_encoder A PP_Resource identifying the audio * encoder. * @param[in] bitrate The requested new bitrate, in bits per second. */ void (*RequestBitrateChange)(PP_Resource audio_encoder, uint32_t bitrate); /** * Closes the audio encoder, and cancels any pending encodes. Any pending * callbacks will still run, reporting PP_ERROR_ABORTED . It is * not valid to call any encoder functions after a call to this method. * Note: Destroying the audio encoder closes it implicitly, * so you are not required to call Close(). * * @param[in] audio_encoder A PP_Resource identifying the audio * encoder. */ void (*Close)(PP_Resource audio_encoder); }; /** * @} */ #endif /* PPAPI_C_PPB_AUDIO_ENCODER_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_compositor.h000066400000000000000000000116261321746453100236150ustar00rootroot00000000000000/* Copyright 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_compositor.idl modified Tue Jun 3 12:44:44 2014. */ #ifndef PPAPI_C_PPB_COMPOSITOR_H_ #define PPAPI_C_PPB_COMPOSITOR_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_COMPOSITOR_INTERFACE_0_1 "PPB_Compositor;0.1" /* dev */ /** * @file */ /** * @addtogroup Interfaces * @{ */ /** * Defines the PPB_Compositor interface. Used for setting * PPB_CompositorLayer layers to the Chromium compositor for * compositing. This allows a plugin to combine different sources of visual * data efficiently, such as PPB_ImageData images and * OpenGL textures. See also PPB_CompositorLayer for more * information. * This interface is still in development (Dev API status) and may change, * so is only supported on Dev channel and Canary currently. * * Example usage from plugin code: * * Setup: * @code * PP_Resource compositor; * compositor = compositor_if->Create(instance); * instance_if->BindGraphics(instance, compositor); * @endcode * * Setup layer stack: * @code * PP_Resource color_layer = compositor_if->AddLayer(compositor); * PP_Resource texture_layer = compositor_if->AddLayer(compositor); * @endcode * * Present one frame: * layer_if->SetColor(color_layer, 255, 255, 0, 255, PP_MakeSize(400, 400)); * PP_CompletionCallback release_callback = { * TextureReleasedCallback, 0, PP_COMPLETIONCALLBACK_FLAG_NONE, * }; * layer_if->SetTexture(texture_layer, graphics3d, texture_id, * PP_MakeSize(300, 300), release_callback); * * PP_CompletionCallback callback = { * DidFinishCommitLayersCallback, * (void*) texture_id, * PP_COMPLETIONCALLBACK_FLAG_NONE, * }; * compositor_if->CommitLayers(compositor, callback); * @endcode * * release callback * void ReleaseCallback(int32_t result, void* user_data) { * if (result == PP_OK) { * uint32_t texture_id = (uint32_t) user_data; * // reuse the texture or delete it. * } * } * * Shutdown: * @code * core->ReleaseResource(color_layer); * core->ReleaseResource(texture_layer); * core->ReleaseResource(compositor); * @endcode */ struct PPB_Compositor_0_1 { /* dev */ /** * Determines if a resource is a compositor resource. * * @param[in] resource The PP_Resource to test. * * @return A PP_Bool with PP_TRUE if the given * resource is a compositor resource or PP_FALSE otherwise. */ PP_Bool (*IsCompositor)(PP_Resource resource); /** * Creates a Compositor resource. * * @param[in] instance A PP_Instance identifying one instance * of a module. * * @return A PP_Resource containing the compositor resource if * successful or 0 otherwise. */ PP_Resource (*Create)(PP_Instance instance); /** * Creates a new PPB_CompositorLayer and adds it to the end * of the layer stack. A PP_Resource containing the layer is * returned. It is uninitialized, SetColor(), * SetTexture or SetImage should be used to * initialize it. The layer will appear above other pre-existing layers. * If ResetLayers is called or the PPB_Compositor is * released, the returned layer will be invalidated, and any further calls on * the layer will return PP_ERROR_BADRESOURCE. * * param[in] compositor A PP_Resource corresponding to * a compositor layer resource. * * @return A PP_Resource containing the compositor layer * resource if successful or 0 otherwise. */ PP_Resource (*AddLayer)(PP_Resource compositor); /** * Commits layers added by AddLayer() to the chromium compositor. * * param[in] compositor A PP_Resource corresponding to * a compositor layer resource. * @param[in] cc A PP_CompletionCallback to be called when * layers have been represented on screen. * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*CommitLayers)(PP_Resource compositor, struct PP_CompletionCallback cc); /** * Resets layers added by AddLayer(). * * param[in] compositor A PP_Resource corresponding to * a compositor layer resource. * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*ResetLayers)(PP_Resource compositor); }; /** * @} */ #endif /* PPAPI_C_PPB_COMPOSITOR_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_compositor_layer.h000066400000000000000000000243601321746453100250100ustar00rootroot00000000000000/* Copyright 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_compositor_layer.idl modified Thu Aug 14 18:06:33 2014. */ #ifndef PPAPI_C_PPB_COMPOSITOR_LAYER_H_ #define PPAPI_C_PPB_COMPOSITOR_LAYER_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #define PPB_COMPOSITORLAYER_INTERFACE_0_1 "PPB_CompositorLayer;0.1" /* dev */ #define PPB_COMPOSITORLAYER_INTERFACE_0_2 "PPB_CompositorLayer;0.2" /* dev */ /** * @file */ /** * @addtogroup Enums * @{ */ /** * This enumeration contains blend modes used for computing the result pixels * based on the source RGBA values in layers with the RGBA values that are * already in the destination framebuffer. * alpha_src, color_src: source alpha and color. * alpha_dst, color_dst: destination alpha and color (before compositing). * Below descriptions of the blend modes assume the colors are pre-multiplied. * This interface is still in development (Dev API status) and may change, * so is only supported on Dev channel and Canary currently. */ typedef enum { /** * No blending, copy source to the destination directly. */ PP_BLENDMODE_NONE, /** * Source is placed over the destination. * Resulting alpha = alpha_src + alpha_dst - alpha_src * alpha_dst * Resulting color = color_src + color_dst * (1 - alpha_src) */ PP_BLENDMODE_SRC_OVER, /** * The last blend mode. */ PP_BLENDMODE_LAST = PP_BLENDMODE_SRC_OVER } PP_BlendMode; /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * Defines the PPB_CompositorLayer interface. It is used by * PPB_Compositor. */ struct PPB_CompositorLayer_0_2 { /* dev */ /** * Determines if a resource is a compositor layer resource. * * @param[in] resource The PP_Resource to test. * * @return A PP_Bool with PP_TRUE if the given * resource is a compositor layer resource or PP_FALSE * otherwise. */ PP_Bool (*IsCompositorLayer)(PP_Resource resource); /** * Sets the color of a solid color layer. If the layer is uninitialized, * it will initialize the layer first, and then set its color. * If the layer has been initialized to another kind of layer, the layer will * not be changed, and PP_ERROR_BADARGUMENT will be returned. * * param[in] layer A PP_Resource corresponding to a compositor * layer resource. * param[in] red A float for the red color component. It will be * clamped to [0, 1]. * param[in] green A float for the green color component. It will * be clamped to [0, 1]. * param[in] blue A float for the blue color component. It will * be clamped to [0, 1]. * param[in] alpha A float for the alpha color component. It will * be clamped to [0, 1]. * param[in] size A PP_Size for the size of the layer before * transform. * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*SetColor)(PP_Resource layer, float red, float green, float blue, float alpha, const struct PP_Size* size); /** * Sets the texture of a texture layer. If the layer is uninitialized, * it will initialize the layer first, and then set its texture. * The source rect will be set to ((0, 0), (1, 1)). If the layer has been * initialized to another kind of layer, the layer will not be changed, * and PP_ERROR_BADARGUMENT will be returned. * * param[in] layer A PP_Resource corresponding to a compositor * layer resource. * param[in] context A PP_Resource corresponding to a graphics * 3d resource which owns the GL texture. * param[in] target GL texture target (GL_TEXTURE_2D, etc). * param[in] texture A GL texture object id. * param[in] size A PP_Size for the size of the layer before * transform. * param[in] cc A PP_CompletionCallback to be called when * the texture is released by Chromium compositor. * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*SetTexture)(PP_Resource layer, PP_Resource context, uint32_t target, uint32_t texture, const struct PP_Size* size, struct PP_CompletionCallback cc); /** * Sets the image of an image layer. If the layer is uninitialized, * it will initialize the layer first, and then set its image. * The layer size will be set to the image's size. The source rect will be set * to the full image. If the layer has been initialized to another kind of * layer, the layer will not be changed, and PP_ERROR_BADARGUMENT * will be returned. * * param[in] layer A PP_Resource corresponding to a compositor * layer resource. * param[in] image_data A PP_Resource corresponding to * an image data resource. * param[in] size A PP_Size for the size of the layer before * transform. If NULL, the image's size will be used. * param[in] cc A PP_CompletionCallback to be called when * the image data is released by Chromium compositor. * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*SetImage)(PP_Resource layer, PP_Resource image_data, const struct PP_Size* size, struct PP_CompletionCallback cc); /** * Sets a clip rectangle for a compositor layer. The Chromium compositor * applies a transform matrix on the layer first, and then clips the layer * with the rectangle. * * param[in] layer A PP_Resource corresponding to a compositor * layer resource. * param[in] rect The clip rectangle. The origin is top-left corner of * the plugin. * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*SetClipRect)(PP_Resource layer, const struct PP_Rect* rect); /** * Sets a transform matrix which is used to composite the layer. * * param[in] layer A PP_Resource corresponding to a compositor * layer resource. * param[in] matrix A float array with 16 elements. The matrix is * column major. The default transform matrix is an identity matrix. * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*SetTransform)(PP_Resource layer, const float matrix[16]); /** * Sets the opacity value which will be applied to the layer. The effective * value of each pixel is computed as: * * if (premult_alpha) * pixel.rgb = pixel.rgb * opacity; * pixel.a = pixel.a * opactiy; * * param[in] layer A PP_Resource corresponding to a compositor * layer resource. * param[in] opacity A float for the opacity value, The default * value is 1.0f. * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*SetOpacity)(PP_Resource layer, float opacity); /** * Sets the blend mode which is used to composite the layer. * * param[in] layer A PP_Resource corresponding to a compositor * layer resource. * param[in] mode A PP_BlendMode. The default mode is * PP_BLENDMODE_SRC_OVER. * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*SetBlendMode)(PP_Resource layer, PP_BlendMode mode); /** * Sets a source rectangle for a texture layer or an image layer. * * param[in] layer A PP_Resource corresponding to a compositor * layer resource. * param[in] rect A PP_FloatRect for an area of the source to * consider. For a texture layer, rect is in uv coordinates. For an image * layer, rect is in pixels. If the rect is beyond the dimensions of the * texture or image, PP_ERROR_BADARGUMENT will be returned. * If the layer size does not match the source rect size, bilinear scaling * will be used. * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*SetSourceRect)(PP_Resource layer, const struct PP_FloatRect* rect); /** * Sets the premultiplied alpha for an texture layer. * * param[in] layer A PP_Resource corresponding to a compositor * layer resource. * param[in] premult A PP_Bool with PP_TRUE if * pre-multiplied alpha is used. * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*SetPremultipliedAlpha)(PP_Resource layer, PP_Bool premult); }; struct PPB_CompositorLayer_0_1 { /* dev */ PP_Bool (*IsCompositorLayer)(PP_Resource resource); int32_t (*SetColor)(PP_Resource layer, float red, float green, float blue, float alpha, const struct PP_Size* size); int32_t (*SetTexture)(PP_Resource layer, PP_Resource context, uint32_t texture, const struct PP_Size* size, struct PP_CompletionCallback cc); int32_t (*SetImage)(PP_Resource layer, PP_Resource image_data, const struct PP_Size* size, struct PP_CompletionCallback cc); int32_t (*SetClipRect)(PP_Resource layer, const struct PP_Rect* rect); int32_t (*SetTransform)(PP_Resource layer, const float matrix[16]); int32_t (*SetOpacity)(PP_Resource layer, float opacity); int32_t (*SetBlendMode)(PP_Resource layer, PP_BlendMode mode); int32_t (*SetSourceRect)(PP_Resource layer, const struct PP_FloatRect* rect); int32_t (*SetPremultipliedAlpha)(PP_Resource layer, PP_Bool premult); }; /** * @} */ #endif /* PPAPI_C_PPB_COMPOSITOR_LAYER_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_console.h000066400000000000000000000041101321746453100230470ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_console.idl modified Fri Nov 16 15:28:43 2012. */ #ifndef PPAPI_C_PPB_CONSOLE_H_ #define PPAPI_C_PPB_CONSOLE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_CONSOLE_INTERFACE_1_0 "PPB_Console;1.0" #define PPB_CONSOLE_INTERFACE PPB_CONSOLE_INTERFACE_1_0 /** * @file * This file defines the PPB_Console interface. */ /** * @addtogroup Enums * @{ */ typedef enum { PP_LOGLEVEL_TIP = 0, PP_LOGLEVEL_LOG = 1, PP_LOGLEVEL_WARNING = 2, PP_LOGLEVEL_ERROR = 3 } PP_LogLevel; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_LogLevel, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ struct PPB_Console_1_0 { /** * Logs the given message to the JavaScript console associated with the * given plugin instance with the given logging level. The name of the plugin * issuing the log message will be automatically prepended to the message. * The value may be any type of Var. */ void (*Log)(PP_Instance instance, PP_LogLevel level, struct PP_Var value); /** * Logs a message to the console with the given source information rather * than using the internal PPAPI plugin name. The name must be a string var. * * The regular log function will automatically prepend the name of your * plugin to the message as the "source" of the message. Some plugins may * wish to override this. For example, if your plugin is a Python * interpreter, you would want log messages to contain the source .py file * doing the log statement rather than have "python" show up in the console. */ void (*LogWithSource)(PP_Instance instance, PP_LogLevel level, struct PP_Var source, struct PP_Var value); }; typedef struct PPB_Console_1_0 PPB_Console; /** * @} */ #endif /* PPAPI_C_PPB_CONSOLE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_core.h000066400000000000000000000076541321746453100223550ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_core.idl modified Mon Mar 19 12:02:10 2012. */ #ifndef PPAPI_C_PPB_CORE_H_ #define PPAPI_C_PPB_CORE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" #define PPB_CORE_INTERFACE_1_0 "PPB_Core;1.0" #define PPB_CORE_INTERFACE PPB_CORE_INTERFACE_1_0 /** * @file * This file defines the PPB_Core interface defined by the browser * and containing pointers to functions related to memory management, time, and * threads. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_Core interface contains pointers to functions related * to memory management, time, and threads on the browser. * */ struct PPB_Core_1_0 { /** * * AddRefResource() adds a reference to a resource. * * @param[in] config A PP_Resource corresponding to a * resource. */ void (*AddRefResource)(PP_Resource resource); /** * ReleaseResource() removes a reference from a resource. * * @param[in] config A PP_Resource corresponding to a * resource. */ void (*ReleaseResource)(PP_Resource resource); /** * GetTime() returns the "wall clock time" according to the * browser. * * @return A PP_Time containing the "wall clock time" according * to the browser. */ PP_Time (*GetTime)(void); /** * GetTimeTicks() returns the "tick time" according to the browser. * This clock is used by the browser when passing some event times to the * module (e.g. using the PP_InputEvent::time_stamp_seconds * field). It is not correlated to any actual wall clock time * (like GetTime()). Because of this, it will not run change if the user * changes their computer clock. * * @return A PP_TimeTicks containing the "tick time" according * to the browser. */ PP_TimeTicks (*GetTimeTicks)(void); /** * CallOnMainThread() schedules work to be executed on the main module thread * after the specified delay. The delay may be 0 to specify a call back as * soon as possible. * * The result parameter will just be passed as the second * argument to the callback. Many applications won't need this, but it allows * a module to emulate calls of some callbacks which do use this value. * * Note: CallOnMainThread, even when used from the main * thread with a delay of 0 milliseconds, will never directly invoke the * callback. Even in this case, the callback will be scheduled * asynchronously. * * Note: If the browser is shutting down or if the module * has no instances, then the callback function may not be called. * * @param[in] delay_in_milliseconds An int32_t delay in milliseconds. * @param[in] callback A PP_CompletionCallback callback function * that the browser will call after the specified delay. * @param[in] result An int32_t that the browser will pass to the given * PP_CompletionCallback. */ void (*CallOnMainThread)(int32_t delay_in_milliseconds, struct PP_CompletionCallback callback, int32_t result); /** * IsMainThread() returns true if the current thread is the main pepper * thread. * * This function is useful for implementing sanity checks, and deciding if * dispatching using CallOnMainThread() is required. * * @return A PP_Bool containing PP_TRUE if the * current thread is the main pepper thread, otherwise PP_FALSE. */ PP_Bool (*IsMainThread)(void); }; typedef struct PPB_Core_1_0 PPB_Core; /** * @} */ #endif /* PPAPI_C_PPB_CORE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_file_io.h000066400000000000000000000331241321746453100230220ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_file_io.idl modified Tue Oct 22 15:09:47 2013. */ #ifndef PPAPI_C_PPB_FILE_IO_H_ #define PPAPI_C_PPB_FILE_IO_H_ #include "ppapi/c/pp_array_output.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_file_info.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" #define PPB_FILEIO_INTERFACE_1_0 "PPB_FileIO;1.0" #define PPB_FILEIO_INTERFACE_1_1 "PPB_FileIO;1.1" #define PPB_FILEIO_INTERFACE PPB_FILEIO_INTERFACE_1_1 /** * @file * This file defines the API to create a file i/o object. */ /** * @addtogroup Enums * @{ */ /** * The PP_FileOpenFlags enum contains file open constants. */ typedef enum { /** Requests read access to a file. */ PP_FILEOPENFLAG_READ = 1 << 0, /** * Requests write access to a file. May be combined with * PP_FILEOPENFLAG_READ to request read and write access. */ PP_FILEOPENFLAG_WRITE = 1 << 1, /** * Requests that the file be created if it does not exist. If the file * already exists, then this flag is ignored unless * PP_FILEOPENFLAG_EXCLUSIVE was also specified, in which case * FileIO::Open() will fail. */ PP_FILEOPENFLAG_CREATE = 1 << 2, /** * Requests that the file be truncated to length 0 if it exists and is a * regular file. PP_FILEOPENFLAG_WRITE must also be specified. */ PP_FILEOPENFLAG_TRUNCATE = 1 << 3, /** * Requests that the file is created when this flag is combined with * PP_FILEOPENFLAG_CREATE. If this flag is specified, and the * file already exists, then the FileIO::Open() call will fail. */ PP_FILEOPENFLAG_EXCLUSIVE = 1 << 4, /** * Requests write access to a file, but writes will always occur at the end of * the file. Mututally exclusive with PP_FILEOPENFLAG_WRITE. * * This is only supported in version 1.2 (Chrome 29) and later. */ PP_FILEOPENFLAG_APPEND = 1 << 5 } PP_FileOpenFlags; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileOpenFlags, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_FileIO struct is used to operate on a regular file * (PP_FileType_Regular). */ struct PPB_FileIO_1_1 { /** * Create() creates a new FileIO object. * * @param[in] instance A PP_Instance identifying the instance * with the file. * * @return A PP_Resource corresponding to a FileIO if * successful or 0 if the module is invalid. */ PP_Resource (*Create)(PP_Instance instance); /** * IsFileIO() determines if the provided resource is a FileIO. * * @param[in] resource A PP_Resource corresponding to a FileIO. * * @return PP_TRUE if the resource is a * PPB_FileIO, PP_FALSE if the resource is * invalid or some type other than PPB_FileIO. */ PP_Bool (*IsFileIO)(PP_Resource resource); /** * Open() opens the specified regular file for I/O according to the given * open flags, which is a bit-mask of the PP_FileOpenFlags * values. Upon success, the corresponding file is classified as "in use" * by this FileIO object until such time as the FileIO object is closed * or destroyed. * * @param[in] file_io A PP_Resource corresponding to a * FileIO. * @param[in] file_ref A PP_Resource corresponding to a file * reference. * @param[in] open_flags A bit-mask of the PP_FileOpenFlags * values. * @param[in] callback A PP_CompletionCallback to be called upon * completion of Open(). * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*Open)(PP_Resource file_io, PP_Resource file_ref, int32_t open_flags, struct PP_CompletionCallback callback); /** * Query() queries info about the file opened by this FileIO object. The * FileIO object must be opened, and there must be no other operations * pending. * * @param[in] file_io A PP_Resource corresponding to a * FileIO. * @param[out] info The PP_FileInfo structure representing all * information about the file. * @param[in] callback A PP_CompletionCallback to be called upon * completion of Query(). info must remain valid until after the * callback runs. If you pass a blocking callback, info must * remain valid until after Query() returns. * * @return An int32_t containing an error code from pp_errors.h. * PP_ERROR_FAILED will be returned if the file isn't opened, and * PP_ERROR_INPROGRESS will be returned if there is another operation pending. */ int32_t (*Query)(PP_Resource file_io, struct PP_FileInfo* info, struct PP_CompletionCallback callback); /** * Touch() Updates time stamps for the file opened by this FileIO object. * This function will fail if the FileIO object has not been opened. The * FileIO object must be opened, and there must be no other operations * pending. * * @param[in] file_io A PP_Resource corresponding to a file * FileIO. * @param[in] last_access_time The last time the FileIO was accessed. * @param[in] last_modified_time The last time the FileIO was modified. * @param[in] callback A PP_CompletionCallback to be called upon * completion of Touch(). * * @return An int32_t containing an error code from pp_errors.h. * PP_ERROR_FAILED will be returned if the file isn't opened, and * PP_ERROR_INPROGRESS will be returned if there is another operation pending. */ int32_t (*Touch)(PP_Resource file_io, PP_Time last_access_time, PP_Time last_modified_time, struct PP_CompletionCallback callback); /** * Read() reads from an offset in the file. The size of the buffer must be * large enough to hold the specified number of bytes to read. This function * might perform a partial read, meaning all the requested bytes * might not be returned, even if the end of the file has not been reached. * The FileIO object must have been opened with read access. * * ReadToArray() is preferred to Read() when doing asynchronous operations. * * @param[in] file_io A PP_Resource corresponding to a file * FileIO. * @param[in] offset The offset into the file. * @param[in] buffer The buffer to hold the specified number of bytes read. * @param[in] bytes_to_read The number of bytes to read from * offset. * @param[in] callback A PP_CompletionCallback to be called upon * completion of Read(). buffer must remain valid until after * the callback runs. If you pass a blocking callback, buffer * must remain valid until after Read() returns. * * @return The number of bytes read or an error code from * pp_errors.h. If the return value is 0, then end-of-file was * reached. It is valid to call Read() multiple times with a completion * callback to queue up parallel reads from the file, but pending reads * cannot be interleaved with other operations. */ int32_t (*Read)(PP_Resource file_io, int64_t offset, char* buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback); /** * Write() writes to an offset in the file. This function might perform a * partial write. The FileIO object must have been opened with write access. * * @param[in] file_io A PP_Resource corresponding to a file * FileIO. * @param[in] offset The offset into the file. * @param[in] buffer The buffer to hold the specified number of bytes read. * @param[in] bytes_to_write The number of bytes to write to * offset. * @param[in] callback A PP_CompletionCallback to be called upon * completion of Write(). * * @return The number of bytes written or an error code from * pp_errors.h. If the return value is 0, then end-of-file was * reached. It is valid to call Write() multiple times with a completion * callback to queue up parallel writes to the file, but pending writes * cannot be interleaved with other operations. */ int32_t (*Write)(PP_Resource file_io, int64_t offset, const char* buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback); /** * SetLength() sets the length of the file. If the file size is extended, * then the extended area of the file is zero-filled. The FileIO object must * have been opened with write access and there must be no other operations * pending. * * @param[in] file_io A PP_Resource corresponding to a file * FileIO. * @param[in] length The length of the file to be set. * @param[in] callback A PP_CompletionCallback to be called upon * completion of SetLength(). * * @return An int32_t containing an error code from pp_errors.h. * PP_ERROR_FAILED will be returned if the file isn't opened, and * PP_ERROR_INPROGRESS will be returned if there is another operation pending. */ int32_t (*SetLength)(PP_Resource file_io, int64_t length, struct PP_CompletionCallback callback); /** * Flush() flushes changes to disk. This call can be very expensive! The * FileIO object must have been opened with write access and there must be no * other operations pending. * * @param[in] file_io A PP_Resource corresponding to a file * FileIO. * @param[in] callback A PP_CompletionCallback to be called upon * completion of Flush(). * * @return An int32_t containing an error code from pp_errors.h. * PP_ERROR_FAILED will be returned if the file isn't opened, and * PP_ERROR_INPROGRESS will be returned if there is another operation pending. */ int32_t (*Flush)(PP_Resource file_io, struct PP_CompletionCallback callback); /** * Close() cancels any IO that may be pending, and closes the FileIO object. * Any pending callbacks will still run, reporting * PP_ERROR_ABORTED if pending IO was interrupted. It is not * valid to call Open() again after a call to this method. * Note: If the FileIO object is destroyed, and it is still * open, then it will be implicitly closed, so you are not required to call * Close(). * * @param[in] file_io A PP_Resource corresponding to a file * FileIO. */ void (*Close)(PP_Resource file_io); /** * ReadToArray() reads from an offset in the file. A PP_ArrayOutput must be * provided so that output will be stored in its allocated buffer. This * function might perform a partial read. The FileIO object must have been * opened with read access. * * @param[in] file_io A PP_Resource corresponding to a file * FileIO. * @param[in] offset The offset into the file. * @param[in] max_read_length The maximum number of bytes to read from * offset. * @param[in] output A PP_ArrayOutput to hold the output data. * @param[in] callback A PP_CompletionCallback to be called upon * completion of ReadToArray(). * * @return The number of bytes read or an error code from * pp_errors.h. If the return value is 0, then end-of-file was * reached. It is valid to call ReadToArray() multiple times with a completion * callback to queue up parallel reads from the file, but pending reads * cannot be interleaved with other operations. */ int32_t (*ReadToArray)(PP_Resource file_io, int64_t offset, int32_t max_read_length, struct PP_ArrayOutput* output, struct PP_CompletionCallback callback); }; typedef struct PPB_FileIO_1_1 PPB_FileIO; struct PPB_FileIO_1_0 { PP_Resource (*Create)(PP_Instance instance); PP_Bool (*IsFileIO)(PP_Resource resource); int32_t (*Open)(PP_Resource file_io, PP_Resource file_ref, int32_t open_flags, struct PP_CompletionCallback callback); int32_t (*Query)(PP_Resource file_io, struct PP_FileInfo* info, struct PP_CompletionCallback callback); int32_t (*Touch)(PP_Resource file_io, PP_Time last_access_time, PP_Time last_modified_time, struct PP_CompletionCallback callback); int32_t (*Read)(PP_Resource file_io, int64_t offset, char* buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback); int32_t (*Write)(PP_Resource file_io, int64_t offset, const char* buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback); int32_t (*SetLength)(PP_Resource file_io, int64_t length, struct PP_CompletionCallback callback); int32_t (*Flush)(PP_Resource file_io, struct PP_CompletionCallback callback); void (*Close)(PP_Resource file_io); }; /** * @} */ #endif /* PPAPI_C_PPB_FILE_IO_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_file_ref.h000066400000000000000000000262161321746453100231730ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_file_ref.idl modified Wed Jan 29 20:50:29 2014. */ #ifndef PPAPI_C_PPB_FILE_REF_H_ #define PPAPI_C_PPB_FILE_REF_H_ #include "ppapi/c/pp_array_output.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_file_info.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" #include "ppapi/c/pp_var.h" #define PPB_FILEREF_INTERFACE_1_0 "PPB_FileRef;1.0" #define PPB_FILEREF_INTERFACE_1_1 "PPB_FileRef;1.1" #define PPB_FILEREF_INTERFACE_1_2 "PPB_FileRef;1.2" #define PPB_FILEREF_INTERFACE PPB_FILEREF_INTERFACE_1_2 /** * @file * This file defines the API to create a file reference or "weak pointer" to a * file in a file system. */ /** * @addtogroup Enums * @{ */ /** * The PP_MakeDirectoryFlags enum contains flags used to control * behavior of PPB_FileRef.MakeDirectory(). */ typedef enum { PP_MAKEDIRECTORYFLAG_NONE = 0 << 0, /** Requests that ancestor directories are created if they do not exist. */ PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS = 1 << 0, /** * Requests that the PPB_FileRef.MakeDirectory() call fails if the directory * already exists. */ PP_MAKEDIRECTORYFLAG_EXCLUSIVE = 1 << 1 } PP_MakeDirectoryFlags; /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_FileRef struct represents a "weak pointer" to a file in * a file system. This struct contains a PP_FileSystemType * identifier and a file path string. */ struct PPB_FileRef_1_2 { /** * Create() creates a weak pointer to a file in the given file system. File * paths are POSIX style. * * @param[in] resource A PP_Resource corresponding to a file * system. * @param[in] path A path to the file. Must begin with a '/' character. * * @return A PP_Resource corresponding to a file reference if * successful or 0 if the path is malformed. */ PP_Resource (*Create)(PP_Resource file_system, const char* path); /** * IsFileRef() determines if the provided resource is a file reference. * * @param[in] resource A PP_Resource corresponding to a file * reference. * * @return PP_TRUE if the resource is a * PPB_FileRef, PP_FALSE if the resource is * invalid or some type other than PPB_FileRef. */ PP_Bool (*IsFileRef)(PP_Resource resource); /** * GetFileSystemType() returns the type of the file system. * * @param[in] file_ref A PP_Resource corresponding to a file * reference. * * @return A PP_FileSystemType with the file system type if * valid or PP_FILESYSTEMTYPE_INVALID if the provided resource * is not a valid file reference. */ PP_FileSystemType (*GetFileSystemType)(PP_Resource file_ref); /** * GetName() returns the name of the file. * * @param[in] file_ref A PP_Resource corresponding to a file * reference. * * @return A PP_Var containing the name of the file. The value * returned by this function does not include any path components (such as * the name of the parent directory, for example). It is just the name of the * file. Use GetPath() to get the full file path. */ struct PP_Var (*GetName)(PP_Resource file_ref); /** * GetPath() returns the absolute path of the file. * * @param[in] file_ref A PP_Resource corresponding to a file * reference. * * @return A PP_Var containing the absolute path of the file. * This function fails if the file system type is * PP_FileSystemType_External. */ struct PP_Var (*GetPath)(PP_Resource file_ref); /** * GetParent() returns the parent directory of this file. If * file_ref points to the root of the filesystem, then the root * is returned. * * @param[in] file_ref A PP_Resource corresponding to a file * reference. * * @return A PP_Resource containing the parent directory of the * file. This function fails if the file system type is * PP_FileSystemType_External. */ PP_Resource (*GetParent)(PP_Resource file_ref); /** * MakeDirectory() makes a new directory in the file system according to the * given make_directory_flags, which is a bit-mask of the * PP_MakeDirectoryFlags values. It is not valid to make a * directory in the external file system. * * @param[in] file_ref A PP_Resource corresponding to a file * reference. * @param[in] make_directory_flags A bit-mask of the * PP_MakeDirectoryFlags values. * @param[in] callback A PP_CompletionCallback to be called upon * completion of MakeDirectory(). * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*MakeDirectory)(PP_Resource directory_ref, int32_t make_directory_flags, struct PP_CompletionCallback callback); /** * Touch() Updates time stamps for a file. You must have write access to the * file if it exists in the external filesystem. * * @param[in] file_ref A PP_Resource corresponding to a file * reference. * @param[in] last_access_time The last time the file was accessed. * @param[in] last_modified_time The last time the file was modified. * @param[in] callback A PP_CompletionCallback to be called upon * completion of Touch(). * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*Touch)(PP_Resource file_ref, PP_Time last_access_time, PP_Time last_modified_time, struct PP_CompletionCallback callback); /** * Delete() deletes a file or directory. If file_ref refers to * a directory, then the directory must be empty. It is an error to delete a * file or directory that is in use. It is not valid to delete a file in * the external file system. * * @param[in] file_ref A PP_Resource corresponding to a file * reference. * @param[in] callback A PP_CompletionCallback to be called upon * completion of Delete(). * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*Delete)(PP_Resource file_ref, struct PP_CompletionCallback callback); /** * Rename() renames a file or directory. Arguments file_ref and * new_file_ref must both refer to files in the same file * system. It is an error to rename a file or directory that is in use. It * is not valid to rename a file in the external file system. * * @param[in] file_ref A PP_Resource corresponding to a file * reference. * @param[in] new_file_ref A PP_Resource corresponding to a new * file reference. * @param[in] callback A PP_CompletionCallback to be called upon * completion of Rename(). * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*Rename)(PP_Resource file_ref, PP_Resource new_file_ref, struct PP_CompletionCallback callback); /** * Query() queries info about a file or directory. You must have access to * read this file or directory if it exists in the external filesystem. * * @param[in] file_ref A PP_Resource corresponding to a file * reference. * @param[out] info A pointer to a PP_FileInfo which will be * populated with information about the file or directory. * @param[in] callback A PP_CompletionCallback to be called upon * completion of Query(). * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*Query)(PP_Resource file_ref, struct PP_FileInfo* info, struct PP_CompletionCallback callback); /** * ReadDirectoryEntries() reads all entries in a directory. * * @param[in] file_ref A PP_Resource corresponding to a directory * reference. * @param[in] output An output array which will receive * PP_DirectoryEntry objects on success. * @param[in] callback A PP_CompletionCallback to run on * completion. * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*ReadDirectoryEntries)(PP_Resource file_ref, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); }; typedef struct PPB_FileRef_1_2 PPB_FileRef; struct PPB_FileRef_1_0 { PP_Resource (*Create)(PP_Resource file_system, const char* path); PP_Bool (*IsFileRef)(PP_Resource resource); PP_FileSystemType (*GetFileSystemType)(PP_Resource file_ref); struct PP_Var (*GetName)(PP_Resource file_ref); struct PP_Var (*GetPath)(PP_Resource file_ref); PP_Resource (*GetParent)(PP_Resource file_ref); int32_t (*MakeDirectory)(PP_Resource directory_ref, PP_Bool make_ancestors, struct PP_CompletionCallback callback); int32_t (*Touch)(PP_Resource file_ref, PP_Time last_access_time, PP_Time last_modified_time, struct PP_CompletionCallback callback); int32_t (*Delete)(PP_Resource file_ref, struct PP_CompletionCallback callback); int32_t (*Rename)(PP_Resource file_ref, PP_Resource new_file_ref, struct PP_CompletionCallback callback); }; struct PPB_FileRef_1_1 { PP_Resource (*Create)(PP_Resource file_system, const char* path); PP_Bool (*IsFileRef)(PP_Resource resource); PP_FileSystemType (*GetFileSystemType)(PP_Resource file_ref); struct PP_Var (*GetName)(PP_Resource file_ref); struct PP_Var (*GetPath)(PP_Resource file_ref); PP_Resource (*GetParent)(PP_Resource file_ref); int32_t (*MakeDirectory)(PP_Resource directory_ref, PP_Bool make_ancestors, struct PP_CompletionCallback callback); int32_t (*Touch)(PP_Resource file_ref, PP_Time last_access_time, PP_Time last_modified_time, struct PP_CompletionCallback callback); int32_t (*Delete)(PP_Resource file_ref, struct PP_CompletionCallback callback); int32_t (*Rename)(PP_Resource file_ref, PP_Resource new_file_ref, struct PP_CompletionCallback callback); int32_t (*Query)(PP_Resource file_ref, struct PP_FileInfo* info, struct PP_CompletionCallback callback); int32_t (*ReadDirectoryEntries)(PP_Resource file_ref, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); }; /** * @} */ #endif /* PPAPI_C_PPB_FILE_REF_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_file_system.h000066400000000000000000000065651321746453100237500ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_file_system.idl modified Thu Jun 13 14:30:40 2013. */ #ifndef PPAPI_C_PPB_FILE_SYSTEM_H_ #define PPAPI_C_PPB_FILE_SYSTEM_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_file_info.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_FILESYSTEM_INTERFACE_1_0 "PPB_FileSystem;1.0" #define PPB_FILESYSTEM_INTERFACE PPB_FILESYSTEM_INTERFACE_1_0 /** * @file * This file defines the API to create a file system associated with a file. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_FileSystem struct identifies the file system type * associated with a file. */ struct PPB_FileSystem_1_0 { /** Create() creates a file system object of the given type. * * @param[in] instance A PP_Instance identifying the instance * with the file. * @param[in] type A file system type as defined by * PP_FileSystemType enum (except PP_FILESYSTEMTYPE_ISOLATED, * which is currently not supported). * @return A PP_Resource corresponding to a file system if * successful. */ PP_Resource (*Create)(PP_Instance instance, PP_FileSystemType type); /** * IsFileSystem() determines if the provided resource is a file system. * * @param[in] resource A PP_Resource corresponding to a file * system. * * @return PP_TRUE if the resource is a * PPB_FileSystem, PP_FALSE if the resource is * invalid or some type other than PPB_FileSystem. */ PP_Bool (*IsFileSystem)(PP_Resource resource); /** * Open() opens the file system. A file system must be opened before running * any other operation on it. * * @param[in] file_system A PP_Resource corresponding to a file * system. * * @param[in] expected_size The expected size of the file system. Note that * this does not request quota; to do that, you must either invoke * requestQuota from JavaScript: * http://www.html5rocks.com/en/tutorials/file/filesystem/#toc-requesting-quota * or set the unlimitedStorage permission for Chrome Web Store apps: * http://code.google.com/chrome/extensions/manifest.html#permissions * * @param[in] callback A PP_CompletionCallback to be called upon * completion of Open(). * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*Open)(PP_Resource file_system, int64_t expected_size, struct PP_CompletionCallback callback); /** * GetType() returns the type of the provided file system. * * @param[in] file_system A PP_Resource corresponding to a file * system. * * @return A PP_FileSystemType with the file system type if * valid or PP_FILESYSTEMTYPE_INVALID if the provided resource * is not a valid file system. It is valid to call this function even before * Open() completes. */ PP_FileSystemType (*GetType)(PP_Resource file_system); }; typedef struct PPB_FileSystem_1_0 PPB_FileSystem; /** * @} */ #endif /* PPAPI_C_PPB_FILE_SYSTEM_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_fullscreen.h000066400000000000000000000057211321746453100235600ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_fullscreen.idl modified Wed Dec 21 19:08:34 2011. */ #ifndef PPAPI_C_PPB_FULLSCREEN_H_ #define PPAPI_C_PPB_FULLSCREEN_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #define PPB_FULLSCREEN_INTERFACE_1_0 "PPB_Fullscreen;1.0" #define PPB_FULLSCREEN_INTERFACE PPB_FULLSCREEN_INTERFACE_1_0 /** * @file * This file defines the PPB_Fullscreen interface for * handling transitions of a module instance to and from fullscreen mode. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_Fullscreen interface is implemented by the browser. * This interface provides a way of checking the current screen mode and * toggling fullscreen mode. */ struct PPB_Fullscreen_1_0 { /** * IsFullscreen() checks whether the module instance is currently in * fullscreen mode. * * @param[in] instance A PP_Instance identifying one instance * of a module. * * @return PP_TRUE if the module instance is in fullscreen mode, * PP_FALSE if the module instance is not in fullscreen mode. */ PP_Bool (*IsFullscreen)(PP_Instance instance); /** * SetFullscreen() switches the module instance to and from fullscreen * mode. * * The transition to and from fullscreen mode is asynchronous. During the * transition, IsFullscreen() will return the previous value and * no 2D or 3D device can be bound. The transition ends at DidChangeView() * when IsFullscreen() returns the new value. You might receive other * DidChangeView() calls while in transition. * * The transition to fullscreen mode can only occur while the browser is * processing a user gesture, even if PP_TRUE is returned. * * @param[in] instance A PP_Instance identifying one instance * of a module. * @param[in] fullscreen PP_TRUE to enter fullscreen mode, or * PP_FALSE to exit fullscreen mode. * * @return PP_TRUE on success or PP_FALSE on * failure. */ PP_Bool (*SetFullscreen)(PP_Instance instance, PP_Bool fullscreen); /** * GetScreenSize() gets the size of the screen in pixels. The module instance * will be resized to this size when SetFullscreen() is called to enter * fullscreen mode. * * @param[in] instance A PP_Instance identifying one instance * of a module. * @param[out] size The size of the entire screen in pixels. * * @return PP_TRUE on success or PP_FALSE on * failure. */ PP_Bool (*GetScreenSize)(PP_Instance instance, struct PP_Size* size); }; typedef struct PPB_Fullscreen_1_0 PPB_Fullscreen; /** * @} */ #endif /* PPAPI_C_PPB_FULLSCREEN_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_gamepad.h000066400000000000000000000053001321746453100230050ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_gamepad.idl modified Tue Apr 16 09:04:34 2013. */ #ifndef PPAPI_C_PPB_GAMEPAD_H_ #define PPAPI_C_PPB_GAMEPAD_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #define PPB_GAMEPAD_INTERFACE_1_0 "PPB_Gamepad;1.0" #define PPB_GAMEPAD_INTERFACE PPB_GAMEPAD_INTERFACE_1_0 /** * @file * This file defines the PPB_Gamepad interface, which * provides access to gamepad devices. */ /** * @addtogroup Structs * @{ */ /** * The data for one gamepad device. */ struct PP_GamepadSampleData { /** * Number of valid elements in the |axes| array. */ uint32_t axes_length; /** * Normalized values for the axes, indices valid up to |axes_length|-1. Axis * values range from -1..1, and are in order of "importance". */ float axes[16]; /** * Number of valid elements in the |buttons| array. */ uint32_t buttons_length; /** * Normalized values for the buttons, indices valid up to |buttons_length| * - 1. Button values range from 0..1, and are in order of importance. */ float buttons[32]; /** * Monotonically increasing value that is incremented when the data have * been updated. */ double timestamp; /** * Identifier for the type of device/manufacturer. */ uint16_t id[128]; /** * Is there a gamepad connected at this index? If this is false, no other * data in this structure is valid. */ PP_Bool connected; /* Padding to make the struct the same size between 64 and 32. */ char unused_pad_[4]; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_GamepadSampleData, 472); /** * The data for all gamepads connected to the system. */ struct PP_GamepadsSampleData { /** * Number of valid elements in the |items| array. */ uint32_t length; /* Padding to make the struct the same size between 64 and 32. */ char unused_pad_[4]; /** * Data for an individual gamepad device connected to the system. */ struct PP_GamepadSampleData items[4]; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_GamepadsSampleData, 1896); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_Gamepad interface allows retrieving data from * gamepad/joystick devices that are connected to the system. */ struct PPB_Gamepad_1_0 { /** * Samples the current state of the available gamepads. */ void (*Sample)(PP_Instance instance, struct PP_GamepadsSampleData* data); }; typedef struct PPB_Gamepad_1_0 PPB_Gamepad; /** * @} */ #endif /* PPAPI_C_PPB_GAMEPAD_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_graphics_2d.h000066400000000000000000000336761321746453100236150ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_graphics_2d.idl modified Fri Apr 26 08:49:08 2013. */ #ifndef PPAPI_C_PPB_GRAPHICS_2D_H_ #define PPAPI_C_PPB_GRAPHICS_2D_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #define PPB_GRAPHICS_2D_INTERFACE_1_0 "PPB_Graphics2D;1.0" #define PPB_GRAPHICS_2D_INTERFACE_1_1 "PPB_Graphics2D;1.1" #define PPB_GRAPHICS_2D_INTERFACE PPB_GRAPHICS_2D_INTERFACE_1_1 /** * @file * Defines the PPB_Graphics2D struct representing a 2D graphics * context within the browser. */ /** * @addtogroup Interfaces * @{ */ /** * PPB_Graphics2D defines the interface for a 2D graphics context. */ struct PPB_Graphics2D_1_1 { /** * Create() creates a 2D graphics context. The returned graphics context will * not be bound to the module instance on creation (call BindGraphics() on * the module instance to bind the returned graphics context to the module * instance). * * @param[in] instance The module instance. * @param[in] size The size of the graphic context. * @param[in] is_always_opaque Set the is_always_opaque flag to * PP_TRUE if you know that you will be painting only opaque * data to this context. This option will disable blending when compositing * the module with the web page, which might give higher performance on some * computers. * * If you set is_always_opaque, your alpha channel should always * be set to 0xFF or there may be painting artifacts. The alpha values * overwrite the destination alpha values without blending when * is_always_opaque is true. * * @return A PP_Resource containing the 2D graphics context if * successful or 0 if unsuccessful. */ PP_Resource (*Create)(PP_Instance instance, const struct PP_Size* size, PP_Bool is_always_opaque); /** * IsGraphics2D() determines if the given resource is a valid * Graphics2D. * * @param[in] resource A Graphics2D context resource. * * @return PP_TRUE if the given resource is a valid Graphics2D, * PP_FALSE if it is an invalid resource or is a resource of * another type. */ PP_Bool (*IsGraphics2D)(PP_Resource resource); /** * Describe() retrieves the configuration for the given graphics context, * filling the given values (which must not be NULL). * * @param[in] resource The 2D Graphics resource. * @param[in,out] size The size of the 2D graphics context in the browser. * @param[in,out] is_always_opaque Identifies whether only opaque data * will be painted. * * @return Returns PP_TRUE on success or PP_FALSE if * the resource is invalid. The output parameters will be set to 0 on a * PP_FALSE. */ PP_Bool (*Describe)(PP_Resource graphics_2d, struct PP_Size* size, PP_Bool* is_always_opaque); /** * PaintImageData() enqueues a paint of the given image into the context. * This function has no effect until you call Flush() As a result, what * counts is the contents of the bitmap when you call Flush(), not when * you call this function. * * The provided image will be placed at top_left from the top * left of the context's internal backing store. Then the pixels contained * in src_rect will be copied into the backing store. This * means that the rectangle being painted will be at src_rect * offset by top_left. * * The src_rect is specified in the coordinate system of the * image being painted, not the context. For the common case of copying the * entire image, you may specify an empty src_rect. * * The painted area of the source bitmap must fall entirely within the * context. Attempting to paint outside of the context will result in an * error. However, the source bitmap may fall outside the context, as long * as the src_rect subset of it falls entirely within the * context. * * There are two methods most modules will use for painting. The first * method is to generate a new ImageData and then paint it. In * this case, you'll set the location of your painting to * top_left and set src_rect to NULL. * The second is that you're generating small invalid regions out of a larger * bitmap representing your entire instance. In this case, you would set the * location of your image to (0,0) and then set src_rect to the * pixels you changed. * * @param[in] resource The 2D Graphics resource. * @param[in] image The ImageData to be painted. * @param[in] top_left A Point representing the * top_left location where the ImageData will be * painted. * @param[in] src_rect The rectangular area where the ImageData * will be painted. */ void (*PaintImageData)(PP_Resource graphics_2d, PP_Resource image_data, const struct PP_Point* top_left, const struct PP_Rect* src_rect); /** * Scroll() enqueues a scroll of the context's backing store. This * function has no effect until you call Flush(). The data within the * provided clipping rectangle will be shifted by (dx, dy) pixels. * * This function will result in some exposed region which will have undefined * contents. The module should call PaintImageData() on these exposed regions * to give the correct contents. * * The scroll can be larger than the area of the clipping rectangle, which * means the current image will be scrolled out of the rectangle. This * scenario is not an error but will result in a no-op. * * @param[in] graphics_2d The 2D Graphics resource. * @param[in] clip The clipping rectangle. * @param[in] amount The amount the area in the clipping rectangle will * shifted. */ void (*Scroll)(PP_Resource graphics_2d, const struct PP_Rect* clip_rect, const struct PP_Point* amount); /** * ReplaceContents() provides a slightly more efficient way to paint the * entire module's image. Normally, calling PaintImageData() requires that * the browser copy the pixels out of the image and into the graphics * context's backing store. This function replaces the graphics context's * backing store with the given image, avoiding the copy. * * The new image must be the exact same size as this graphics context. If the * new image uses a different image format than the browser's native bitmap * format (use PPB_ImageData.GetNativeImageDataFormat() to * retrieve the format), then a conversion will be done inside the browser * which may slow the performance a little bit. * * Note: The new image will not be painted until you call * Flush(). * * After this call, you should take care to release your references to the * image. If you paint to the image after ReplaceContents(), there is the * possibility of significant painting artifacts because the page might use * partially-rendered data when copying out of the backing store. * * In the case of an animation, you will want to allocate a new image for the * next frame. It is best if you wait until the flush callback has executed * before allocating this bitmap. This gives the browser the option of * caching the previous backing store and handing it back to you (assuming * the sizes match). In the optimal case, this means no bitmaps are allocated * during the animation, and the backing store and "front buffer" (which the * plugin is painting into) are just being swapped back and forth. * * @param[in] graphics_2d The 2D Graphics resource. * @param[in] image The ImageData to be painted. */ void (*ReplaceContents)(PP_Resource graphics_2d, PP_Resource image_data); /** * Flush() flushes any enqueued paint, scroll, and replace commands to the * backing store. This function actually executes the updates, and causes a * repaint of the webpage, assuming this graphics context is bound to a module * instance. * * Flush() runs in asynchronous mode. Specify a callback function and the * argument for that callback function. The callback function will be * executed on the calling thread when the image has been painted to the * screen. While you are waiting for a flush callback, additional calls to * Flush() will fail. * * Because the callback is executed (or thread unblocked) only when the * instance's image is actually on the screen, this function provides * a way to rate limit animations. By waiting until the image is on the * screen before painting the next frame, you can ensure you're not * flushing 2D graphics faster than the screen can be updated. * * Unbound contexts * If the context is not bound to a module instance, you will * still get a callback. The callback will execute after Flush() returns * to avoid reentrancy. The callback will not wait until anything is * painted to the screen because there will be nothing on the screen. The * timing of this callback is not guaranteed and may be deprioritized by * the browser because it is not affecting the user experience. * * Off-screen instances * If the context is bound to an instance that is currently not visible (for * example, scrolled out of view) it will behave like the "unbound context" * case. * * Detaching a context * If you detach a context from a module instance, any pending flush * callbacks will be converted into the "unbound context" case. * * Released contexts * A callback may or may not get called even if you have released all * of your references to the context. This scenario can occur if there are * internal references to the context suggesting it has not been internally * destroyed (for example, if it is still bound to an instance) or due to * other implementation details. As a result, you should be careful to * check that flush callbacks are for the context you expect and that * you're capable of handling callbacks for unreferenced contexts. * * Shutdown * If a module instance is removed when a flush is pending, the * callback will not be executed. * * @param[in] graphics_2d The 2D Graphics resource. * @param[in] callback A CompletionCallback to be called when * the image has been painted on the screen. * * @return Returns PP_OK on success or * PP_ERROR_BADRESOURCE if the graphics context is invalid, * PP_ERROR_BADARGUMENT if the callback is null and flush is * being called from the main thread of the module, or * PP_ERROR_INPROGRESS if a flush is already pending that has * not issued its callback yet. In the failure case, nothing will be updated * and no callback will be scheduled. */ int32_t (*Flush)(PP_Resource graphics_2d, struct PP_CompletionCallback callback); /** * SetScale() sets the scale factor that will be applied when painting the * graphics context onto the output device. Typically, if rendering at device * resolution is desired, the context would be created with the width and * height scaled up by the view's GetDeviceScale and SetScale called with a * scale of 1.0 / GetDeviceScale(). For example, if the view resource passed * to DidChangeView has a rectangle of (w=200, h=100) and a device scale of * 2.0, one would call Create with a size of (w=400, h=200) and then call * SetScale with 0.5. One would then treat each pixel in the context as a * single device pixel. * * @param[in] resource A Graphics2D context resource. * @param[in] scale The scale to apply when painting. * * @return Returns PP_TRUE on success or PP_FALSE if * the resource is invalid or the scale factor is 0 or less. */ PP_Bool (*SetScale)(PP_Resource resource, float scale); /*** * GetScale() gets the scale factor that will be applied when painting the * graphics context onto the output device. * * @param[in] resource A Graphics2D context resource. * * @return Returns the scale factor for the graphics context. If the resource * is not a valid Graphics2D context, this will return 0.0. */ float (*GetScale)(PP_Resource resource); }; typedef struct PPB_Graphics2D_1_1 PPB_Graphics2D; struct PPB_Graphics2D_1_0 { PP_Resource (*Create)(PP_Instance instance, const struct PP_Size* size, PP_Bool is_always_opaque); PP_Bool (*IsGraphics2D)(PP_Resource resource); PP_Bool (*Describe)(PP_Resource graphics_2d, struct PP_Size* size, PP_Bool* is_always_opaque); void (*PaintImageData)(PP_Resource graphics_2d, PP_Resource image_data, const struct PP_Point* top_left, const struct PP_Rect* src_rect); void (*Scroll)(PP_Resource graphics_2d, const struct PP_Rect* clip_rect, const struct PP_Point* amount); void (*ReplaceContents)(PP_Resource graphics_2d, PP_Resource image_data); int32_t (*Flush)(PP_Resource graphics_2d, struct PP_CompletionCallback callback); }; /** * @} */ #endif /* PPAPI_C_PPB_GRAPHICS_2D_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_graphics_3d.h000066400000000000000000000312221321746453100235770ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_graphics_3d.idl modified Fri Aug 30 08:36:16 2013. */ #ifndef PPAPI_C_PPB_GRAPHICS_3D_H_ #define PPAPI_C_PPB_GRAPHICS_3D_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_GRAPHICS_3D_INTERFACE_1_0 "PPB_Graphics3D;1.0" #define PPB_GRAPHICS_3D_INTERFACE PPB_GRAPHICS_3D_INTERFACE_1_0 /** * @file * Defines the PPB_Graphics3D struct representing a 3D graphics * context within the browser. */ /* Add 3D graphics enums */ #include "ppapi/c/pp_graphics_3d.h" /** * @addtogroup Interfaces * @{ */ /** * PPB_Graphics3D defines the interface for a 3D graphics context. * Example usage from plugin code: * * Setup: * @code * PP_Resource context; * int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, 800, * PP_GRAPHICS3DATTRIB_HEIGHT, 800, * PP_GRAPHICS3DATTRIB_NONE}; * context = g3d->Create(instance, 0, attribs); * inst->BindGraphics(instance, context); * @endcode * * Present one frame: * @code * PP_CompletionCallback callback = { * DidFinishSwappingBuffers, 0, PP_COMPLETIONCALLBACK_FLAG_NONE, * }; * gles2->Clear(context, GL_COLOR_BUFFER_BIT); * g3d->SwapBuffers(context, callback); * @endcode * * Shutdown: * @code * core->ReleaseResource(context); * @endcode */ struct PPB_Graphics3D_1_0 { /** * GetAttribMaxValue() retrieves the maximum supported value for the * given attribute. This function may be used to check if a particular * attribute value is supported before attempting to create a context. * * @param[in] instance The module instance. * @param[in] attribute The attribute for which maximum value is queried. * Attributes that can be queried for include: * - PP_GRAPHICS3DATTRIB_ALPHA_SIZE * - PP_GRAPHICS3DATTRIB_BLUE_SIZE * - PP_GRAPHICS3DATTRIB_GREEN_SIZE * - PP_GRAPHICS3DATTRIB_RED_SIZE * - PP_GRAPHICS3DATTRIB_DEPTH_SIZE * - PP_GRAPHICS3DATTRIB_STENCIL_SIZE * - PP_GRAPHICS3DATTRIB_SAMPLES * - PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS * - PP_GRAPHICS3DATTRIB_WIDTH * - PP_GRAPHICS3DATTRIB_HEIGHT * @param[out] value The maximum supported value for attribute * * @return Returns PP_TRUE on success or the following on error: * - PP_ERROR_BADRESOURCE if instance is invalid * - PP_ERROR_BADARGUMENT if attribute is invalid * or value is 0 */ int32_t (*GetAttribMaxValue)(PP_Resource instance, int32_t attribute, int32_t* value); /** * Create() creates and initializes a 3D rendering context. * The returned context is off-screen to start with. It must be attached to * a plugin instance using PPB_Instance::BindGraphics to draw * on the web page. * * @param[in] instance The module instance. * * @param[in] share_context The 3D context with which the created context * would share resources. If share_context is not 0, then all * shareable data, as defined by the client API (note that for OpenGL and * OpenGL ES, shareable data excludes texture objects named 0) will be shared * by share_context, all other contexts share_context * already shares with, and the newly created context. An arbitrary number of * PPB_Graphics3D can share data in this fashion. * * @param[in] attrib_list specifies a list of attributes for the context. * It is a list of attribute name-value pairs in which each attribute is * immediately followed by the corresponding desired value. The list is * terminated with PP_GRAPHICS3DATTRIB_NONE. * The attrib_list may be 0 or empty (first attribute is * PP_GRAPHICS3DATTRIB_NONE). If an attribute is not * specified in attrib_list, then the default value is used * (it is said to be specified implicitly). * Attributes for the context are chosen according to an attribute-specific * criteria. Attributes can be classified into two categories: * - AtLeast: The attribute value in the returned context meets or exceeds * the value specified in attrib_list. * - Exact: The attribute value in the returned context is equal to * the value specified in attrib_list. * * Attributes that can be specified in attrib_list include: * - PP_GRAPHICS3DATTRIB_ALPHA_SIZE: * Category: AtLeast Default: 0. * - PP_GRAPHICS3DATTRIB_BLUE_SIZE: * Category: AtLeast Default: 0. * - PP_GRAPHICS3DATTRIB_GREEN_SIZE: * Category: AtLeast Default: 0. * - PP_GRAPHICS3DATTRIB_RED_SIZE: * Category: AtLeast Default: 0. * - PP_GRAPHICS3DATTRIB_DEPTH_SIZE: * Category: AtLeast Default: 0. * - PP_GRAPHICS3DATTRIB_STENCIL_SIZE: * Category: AtLeast Default: 0. * - PP_GRAPHICS3DATTRIB_SAMPLES: * Category: AtLeast Default: 0. * - PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS: * Category: AtLeast Default: 0. * - PP_GRAPHICS3DATTRIB_WIDTH: * Category: Exact Default: 0. * - PP_GRAPHICS3DATTRIB_HEIGHT: * Category: Exact Default: 0. * - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR: * Category: Exact Default: Implementation defined. * * @return A PP_Resource containing the 3D graphics context if * successful or 0 if unsuccessful. */ PP_Resource (*Create)(PP_Instance instance, PP_Resource share_context, const int32_t attrib_list[]); /** * IsGraphics3D() determines if the given resource is a valid * Graphics3D context. * * @param[in] resource A Graphics3D context resource. * * @return PP_TRUE if the given resource is a valid Graphics3D, * PP_FALSE if it is an invalid resource or is a resource of * another type. */ PP_Bool (*IsGraphics3D)(PP_Resource resource); /** * GetAttribs() retrieves the value for each attribute in * attrib_list. * * @param[in] context The 3D graphics context. * @param[in,out] attrib_list The list of attributes that are queried. * attrib_list has the same structure as described for * PPB_Graphics3D::Create. It is both input and output * structure for this function. All attributes specified in * PPB_Graphics3D::Create can be queried for. * * @return Returns PP_OK on success or: * - PP_ERROR_BADRESOURCE if context is invalid * - PP_ERROR_BADARGUMENT if attrib_list is 0 or any attribute * in the attrib_list is not a valid attribute. * * Example usage: To get the values for rgb bits in the * color buffer, this function must be called as following: * @code * int attrib_list[] = {PP_GRAPHICS3DATTRIB_RED_SIZE, 0, * PP_GRAPHICS3DATTRIB_GREEN_SIZE, 0, * PP_GRAPHICS3DATTRIB_BLUE_SIZE, 0, * PP_GRAPHICS3DATTRIB_NONE}; * GetAttribs(context, attrib_list); * int red_bits = attrib_list[1]; * int green_bits = attrib_list[3]; * int blue_bits = attrib_list[5]; * @endcode */ int32_t (*GetAttribs)(PP_Resource context, int32_t attrib_list[]); /** * SetAttribs() sets the values for each attribute in * attrib_list. * * @param[in] context The 3D graphics context. * @param[in] attrib_list The list of attributes whose values need to be set. * attrib_list has the same structure as described for * PPB_Graphics3D::Create. * Attributes that can be specified are: * - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR * * @return Returns PP_OK on success or: * - PP_ERROR_BADRESOURCE if context is invalid. * - PP_ERROR_BADARGUMENT if attrib_list is 0 or * any attribute in the attrib_list is not a valid attribute. */ int32_t (*SetAttribs)(PP_Resource context, const int32_t attrib_list[]); /** * GetError() returns the current state of the given 3D context. * * The recoverable error conditions that have no side effect are * detected and returned immediately by all functions in this interface. * In addition the implementation may get into a fatal state while * processing a command. In this case the application must destroy the * context and reinitialize client API state and objects to continue * rendering. * * Note that the same error code is also returned in the SwapBuffers callback. * It is recommended to handle error in the SwapBuffers callback because * GetError is synchronous. This function may be useful in rare cases where * drawing a frame is expensive and you want to verify the result of * ResizeBuffers before attempting to draw a frame. * * @param[in] The 3D graphics context. * @return Returns: * - PP_OK if no error * - PP_ERROR_NOMEMORY * - PP_ERROR_CONTEXT_LOST */ int32_t (*GetError)(PP_Resource context); /** * ResizeBuffers() resizes the backing surface for context. * * If the surface could not be resized due to insufficient resources, * PP_ERROR_NOMEMORY error is returned on the next * SwapBuffers callback. * * @param[in] context The 3D graphics context. * @param[in] width The width of the backing surface. * @param[in] height The height of the backing surface. * @return Returns PP_OK on success or: * - PP_ERROR_BADRESOURCE if context is invalid. * - PP_ERROR_BADARGUMENT if the value specified for * width or height is less than zero. */ int32_t (*ResizeBuffers)(PP_Resource context, int32_t width, int32_t height); /** * SwapBuffers() makes the contents of the color buffer available for * compositing. This function has no effect on off-screen surfaces - ones not * bound to any plugin instance. The contents of ancillary buffers are always * undefined after calling SwapBuffers. The contents of the color * buffer are undefined if the value of the * PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR attribute of context is not * PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED. * * SwapBuffers runs in asynchronous mode. Specify a callback * function and the argument for that callback function. The callback function * will be executed on the calling thread after the color buffer has been * composited with rest of the html page. While you are waiting for a * SwapBuffers callback, additional calls to SwapBuffers will fail. * * Because the callback is executed (or thread unblocked) only when the * plugin's current state is actually on the screen, this function provides a * way to rate limit animations. By waiting until the image is on the screen * before painting the next frame, you can ensure you're not generating * updates faster than the screen can be updated. * * SwapBuffers performs an implicit flush operation on context. * If the context gets into an unrecoverable error condition while * processing a command, the error code will be returned as the argument * for the callback. The callback may return the following error codes: * - PP_ERROR_NOMEMORY * - PP_ERROR_CONTEXT_LOST * Note that the same error code may also be obtained by calling GetError. * * @param[in] context The 3D graphics context. * @param[in] callback The callback that will executed when * SwapBuffers completes. * * @return Returns PP_OK on success or: * - PP_ERROR_BADRESOURCE if context is invalid. * - PP_ERROR_BADARGUMENT if callback is invalid. * */ int32_t (*SwapBuffers)(PP_Resource context, struct PP_CompletionCallback callback); }; typedef struct PPB_Graphics3D_1_0 PPB_Graphics3D; /** * @} */ #endif /* PPAPI_C_PPB_GRAPHICS_3D_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_host_resolver.h000066400000000000000000000127061321746453100243150ustar00rootroot00000000000000/* Copyright 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_host_resolver.idl modified Sat Jun 22 11:11:38 2013. */ #ifndef PPAPI_C_PPB_HOST_RESOLVER_H_ #define PPAPI_C_PPB_HOST_RESOLVER_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/ppb_net_address.h" #define PPB_HOSTRESOLVER_INTERFACE_1_0 "PPB_HostResolver;1.0" #define PPB_HOSTRESOLVER_INTERFACE PPB_HOSTRESOLVER_INTERFACE_1_0 /** * @file * This file defines the PPB_HostResolver interface. */ /** * @addtogroup Enums * @{ */ /** * PP_HostResolver_Flag is an enumeration of flags which can be * OR-ed and passed to the host resolver. Currently there is only one flag * defined. */ typedef enum { /** * Hint to request the canonical name of the host, which can be retrieved by * GetCanonicalName(). */ PP_HOSTRESOLVER_FLAG_CANONNAME = 1 << 0 } PP_HostResolver_Flag; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_HostResolver_Flag, 4); /** * @} */ /** * @addtogroup Structs * @{ */ /** * PP_HostResolver_Hint represents hints for host resolution. */ struct PP_HostResolver_Hint { /** * Network address family. */ PP_NetAddress_Family family; /** * Combination of flags from PP_HostResolver_Flag. */ int32_t flags; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_HostResolver_Hint, 8); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_HostResolver interface supports host name * resolution. * * Permissions: In order to run Resolve(), apps permission * socket with subrule resolve-host is required. * For more details about network communication permissions, please see: * http://developer.chrome.com/apps/app_network.html */ struct PPB_HostResolver_1_0 { /** * Creates a host resolver resource. * * @param[in] instance A PP_Instance identifying one instance of * a module. * * @return A PP_Resource corresponding to a host reslover or 0 * on failure. */ PP_Resource (*Create)(PP_Instance instance); /** * Determines if a given resource is a host resolver. * * @param[in] resource A PP_Resource to check. * * @return PP_TRUE if the input is a * PPB_HostResolver resource; PP_FALSE otherwise. */ PP_Bool (*IsHostResolver)(PP_Resource resource); /** * Requests resolution of a host name. If the call completes successfully, the * results can be retrieved by GetCanonicalName(), * GetNetAddressCount() and GetNetAddress(). * * @param[in] host_resolver A PP_Resource corresponding to a host * resolver. * @param[in] host The host name (or IP address literal) to resolve. * @param[in] port The port number to be set in the resulting network * addresses. * @param[in] hint A PP_HostResolver_Hint structure providing * hints for host resolution. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h. * PP_ERROR_NOACCESS will be returned if the caller doesn't have * required permissions. PP_ERROR_NAME_NOT_RESOLVED will be * returned if the host name couldn't be resolved. */ int32_t (*Resolve)(PP_Resource host_resolver, const char* host, uint16_t port, const struct PP_HostResolver_Hint* hint, struct PP_CompletionCallback callback); /** * Gets the canonical name of the host. * * @param[in] host_resolver A PP_Resource corresponding to a host * resolver. * * @return A string PP_Var on success, which is an empty string * if PP_HOSTRESOLVER_FLAG_CANONNAME is not set in the hint flags * when calling Resolve(); an undefined PP_Var if * there is a pending Resolve() call or the previous * Resolve() call failed. */ struct PP_Var (*GetCanonicalName)(PP_Resource host_resolver); /** * Gets the number of network addresses. * * @param[in] host_resolver A PP_Resource corresponding to a host * resolver. * * @return The number of available network addresses on success; 0 if there is * a pending Resolve() call or the previous * Resolve() call failed. */ uint32_t (*GetNetAddressCount)(PP_Resource host_resolver); /** * Gets a network address. * * @param[in] host_resolver A PP_Resource corresponding to a host * resolver. * @param[in] index An index indicating which address to return. * * @return A PPB_NetAddress resource on success; 0 if there is a * pending Resolve() call or the previous Resolve() * call failed, or the specified index is out of range. */ PP_Resource (*GetNetAddress)(PP_Resource host_resolver, uint32_t index); }; typedef struct PPB_HostResolver_1_0 PPB_HostResolver; /** * @} */ #endif /* PPAPI_C_PPB_HOST_RESOLVER_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_image_data.h000066400000000000000000000161271321746453100234730ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_image_data.idl modified Tue Nov 13 08:48:25 2012. */ #ifndef PPAPI_C_PPB_IMAGE_DATA_H_ #define PPAPI_C_PPB_IMAGE_DATA_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #define PPB_IMAGEDATA_INTERFACE_1_0 "PPB_ImageData;1.0" #define PPB_IMAGEDATA_INTERFACE PPB_IMAGEDATA_INTERFACE_1_0 /** * @file * This file defines the PPB_ImageData struct for determining how * a browser handles image data. */ /** * @addtogroup Enums * @{ */ /** * PP_ImageDataFormat is an enumeration of the different types of * image data formats. * * The third part of each enumeration value describes the memory layout from * the lowest address to the highest. For example, BGRA means the B component * is stored in the lowest address, no matter what endianness the platform is * using. * * The PREMUL suffix implies pre-multiplied alpha is used. In this mode, the * red, green and blue color components of the pixel data supplied to an image * data should be pre-multiplied by their alpha value. For example: starting * with floating point color components, here is how to convert them to 8-bit * premultiplied components for image data: * * ...components of a pixel, floats ranging from 0 to 1... * float red = 1.0f; * float green = 0.50f; * float blue = 0.0f; * float alpha = 0.75f; * ...components for image data are 8-bit values ranging from 0 to 255... * uint8_t image_data_red_premul = (uint8_t)(red * alpha * 255.0f); * * uint8_t image_data_green_premul = (uint8_t)(green * alpha * 255.0f); * * uint8_t image_data_blue_premul = (uint8_t)(blue * alpha * 255.0f); * * uint8_t image_data_alpha_premul = (uint8_t)(alpha * 255.0f); * * Note: The resulting pre-multiplied red, green and blue * components should not be greater than the alpha value. */ typedef enum { PP_IMAGEDATAFORMAT_BGRA_PREMUL, PP_IMAGEDATAFORMAT_RGBA_PREMUL } PP_ImageDataFormat; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_ImageDataFormat, 4); /** * @} */ /** * @addtogroup Structs * @{ */ /** * The PP_ImageDataDesc structure represents a description of * image data. */ struct PP_ImageDataDesc { /** * This value represents one of the image data types in the * PP_ImageDataFormat enum. */ PP_ImageDataFormat format; /** This value represents the size of the bitmap in pixels. */ struct PP_Size size; /** * This value represents the row width in bytes. This may be different than * width * 4 since there may be padding at the end of the lines. */ int32_t stride; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_ImageDataDesc, 16); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_ImageData interface contains pointers to several * functions for determining the browser's treatment of image data. */ struct PPB_ImageData_1_0 { /** * GetNativeImageDataFormat() returns the browser's preferred format for * image data. The browser uses this format internally for painting. Other * formats may require internal conversions to paint or may have additional * restrictions depending on the function. * * @return A PP_ImageDataFormat containing the preferred format. */ PP_ImageDataFormat (*GetNativeImageDataFormat)(void); /** * IsImageDataFormatSupported() determines if the given image data format is * supported by the browser. Note: PP_IMAGEDATAFORMAT_BGRA_PREMUL * and PP_IMAGEDATAFORMAT_RGBA_PREMUL formats are always * supported. Other image formats do not make this guarantee, and should be * checked first with IsImageDataFormatSupported() before using. * * @param[in] format The image data format. * * @return A PP_Bool with PP_TRUE if the given * image data format is supported by the browser. */ PP_Bool (*IsImageDataFormatSupported)(PP_ImageDataFormat format); /** * Create() allocates an image data resource with the given format and size. * * For security reasons, if uninitialized, the bitmap will not contain random * memory, but may contain data from a previous image produced by the same * module if the bitmap was cached and re-used. * * @param[in] instance A PP_Instance identifying one instance * of a module. * @param[in] format The desired image data format. * @param[in] size A pointer to a PP_Size containing the image * size. * @param[in] init_to_zero A PP_Bool to determine transparency * at creation. * Set the init_to_zero flag if you want the bitmap initialized * to transparent during the creation process. If this flag is not set, the * current contents of the bitmap will be undefined, and the module should * be sure to set all the pixels. * * @return A PP_Resource with a nonzero ID on success or zero on * failure. Failure means the instance, image size, or format was invalid. */ PP_Resource (*Create)(PP_Instance instance, PP_ImageDataFormat format, const struct PP_Size* size, PP_Bool init_to_zero); /** * IsImageData() determines if a given resource is image data. * * @param[in] image_data A PP_Resource corresponding to image * data. * * @return A PP_Bool with PP_TRUE if the given * resource is an image data or PP_FALSE if the resource is * invalid or some type other than image data. */ PP_Bool (*IsImageData)(PP_Resource image_data); /** * Describe() computes the description of the * image data. * * @param[in] image_data A PP_Resource corresponding to image * data. * @param[in,out] desc A pointer to a PP_ImageDataDesc * containing the description. * * @return A PP_Bool with PP_TRUE on success or * PP_FALSE if the resource is not an image data. On * PP_FALSE, the desc structure will be filled * with 0. */ PP_Bool (*Describe)(PP_Resource image_data, struct PP_ImageDataDesc* desc); /** * Map() maps an image data into the module address space. * * @param[in] image_data A PP_Resource corresponding to image * data. * * @return A pointer to the beginning of the data. */ void* (*Map)(PP_Resource image_data); /** * Unmap is a pointer to a function that unmaps an image data from the module * address space. * * @param[in] image_data A PP_Resource corresponding to image * data. */ void (*Unmap)(PP_Resource image_data); }; typedef struct PPB_ImageData_1_0 PPB_ImageData; /** * @} */ #endif /* PPAPI_C_PPB_IMAGE_DATA_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_input_event.h000066400000000000000000001205771321746453100237650ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_input_event.idl modified Thu Apr 3 14:52:10 2014. */ #ifndef PPAPI_C_PPB_INPUT_EVENT_H_ #define PPAPI_C_PPB_INPUT_EVENT_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" #include "ppapi/c/pp_touch_point.h" #include "ppapi/c/pp_var.h" #define PPB_INPUT_EVENT_INTERFACE_1_0 "PPB_InputEvent;1.0" #define PPB_INPUT_EVENT_INTERFACE PPB_INPUT_EVENT_INTERFACE_1_0 #define PPB_MOUSE_INPUT_EVENT_INTERFACE_1_0 "PPB_MouseInputEvent;1.0" #define PPB_MOUSE_INPUT_EVENT_INTERFACE_1_1 "PPB_MouseInputEvent;1.1" #define PPB_MOUSE_INPUT_EVENT_INTERFACE PPB_MOUSE_INPUT_EVENT_INTERFACE_1_1 #define PPB_WHEEL_INPUT_EVENT_INTERFACE_1_0 "PPB_WheelInputEvent;1.0" #define PPB_WHEEL_INPUT_EVENT_INTERFACE PPB_WHEEL_INPUT_EVENT_INTERFACE_1_0 #define PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_0 "PPB_KeyboardInputEvent;1.0" #define PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_2 "PPB_KeyboardInputEvent;1.2" #define PPB_KEYBOARD_INPUT_EVENT_INTERFACE \ PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_2 #define PPB_TOUCH_INPUT_EVENT_INTERFACE_1_0 "PPB_TouchInputEvent;1.0" #define PPB_TOUCH_INPUT_EVENT_INTERFACE PPB_TOUCH_INPUT_EVENT_INTERFACE_1_0 #define PPB_IME_INPUT_EVENT_INTERFACE_1_0 "PPB_IMEInputEvent;1.0" #define PPB_IME_INPUT_EVENT_INTERFACE PPB_IME_INPUT_EVENT_INTERFACE_1_0 /** * @file * This file defines the Input Event interfaces. */ /** * @addtogroup Enums * @{ */ /** * This enumeration contains the types of input events. */ typedef enum { PP_INPUTEVENT_TYPE_UNDEFINED = -1, /** * Notification that a mouse button was pressed. * * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class. */ PP_INPUTEVENT_TYPE_MOUSEDOWN = 0, /** * Notification that a mouse button was released. * * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class. */ PP_INPUTEVENT_TYPE_MOUSEUP = 1, /** * Notification that a mouse button was moved when it is over the instance * or dragged out of it. * * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class. */ PP_INPUTEVENT_TYPE_MOUSEMOVE = 2, /** * Notification that the mouse entered the instance's bounds. * * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class. */ PP_INPUTEVENT_TYPE_MOUSEENTER = 3, /** * Notification that a mouse left the instance's bounds. * * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class. */ PP_INPUTEVENT_TYPE_MOUSELEAVE = 4, /** * Notification that the scroll wheel was used. * * Register for this event using the PP_INPUTEVENT_CLASS_WHEEL class. */ PP_INPUTEVENT_TYPE_WHEEL = 5, /** * Notification that a key transitioned from "up" to "down". * * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class. */ /* * TODO(brettw) differentiate from KEYDOWN. */ PP_INPUTEVENT_TYPE_RAWKEYDOWN = 6, /** * Notification that a key was pressed. This does not necessarily correspond * to a character depending on the key and language. Use the * PP_INPUTEVENT_TYPE_CHAR for character input. * * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class. */ PP_INPUTEVENT_TYPE_KEYDOWN = 7, /** * Notification that a key was released. * * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class. */ PP_INPUTEVENT_TYPE_KEYUP = 8, /** * Notification that a character was typed. Use this for text input. Key * down events may generate 0, 1, or more than one character event depending * on the key, locale, and operating system. * * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class. */ PP_INPUTEVENT_TYPE_CHAR = 9, /** * Notification that a context menu should be shown. * * This message will be sent when the user right-clicks or performs another * OS-specific mouse command that should open a context menu. When this event * is delivered depends on the system, on some systems (Mac) it will * delivered after the mouse down event, and on others (Windows) it will be * delivered after the mouse up event. * * You will always get the normal mouse events. For example, you may see * MOUSEDOWN,CONTEXTMENU,MOUSEUP or MOUSEDOWN,MOUSEUP,CONTEXTMENU. * * The return value from the event handler determines if the context menu * event will be passed to the page when you are using filtered input events * (via RequestFilteringInputEvents()). In non-filtering mode the event will * never be propagated and no context menu will be displayed. If you are * handling mouse events in filtering mode, you may want to return true from * this event even if you do not support a context menu to suppress the * default one. * * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class. */ PP_INPUTEVENT_TYPE_CONTEXTMENU = 10, /** * Notification that an input method composition process has just started. * * Register for this event using the PP_INPUTEVENT_CLASS_IME class. */ PP_INPUTEVENT_TYPE_IME_COMPOSITION_START = 11, /** * Notification that the input method composition string is updated. * * Register for this event using the PP_INPUTEVENT_CLASS_IME class. */ PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE = 12, /** * Notification that an input method composition process has completed. * * Register for this event using the PP_INPUTEVENT_CLASS_IME class. */ PP_INPUTEVENT_TYPE_IME_COMPOSITION_END = 13, /** * Notification that an input method committed a string. * * Register for this event using the PP_INPUTEVENT_CLASS_IME class. */ PP_INPUTEVENT_TYPE_IME_TEXT = 14, /** * Notification that a finger was placed on a touch-enabled device. * * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class. */ PP_INPUTEVENT_TYPE_TOUCHSTART = 15, /** * Notification that a finger was moved on a touch-enabled device. * * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class. */ PP_INPUTEVENT_TYPE_TOUCHMOVE = 16, /** * Notification that a finger was released on a touch-enabled device. * * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class. */ PP_INPUTEVENT_TYPE_TOUCHEND = 17, /** * Notification that a touch event was canceled. * * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class. */ PP_INPUTEVENT_TYPE_TOUCHCANCEL = 18 } PP_InputEvent_Type; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Type, 4); /** * This enumeration contains event modifier constants. Each modifier is one * bit. Retrieve the modifiers from an input event using the GetEventModifiers * function on PPB_InputEvent. */ typedef enum { PP_INPUTEVENT_MODIFIER_SHIFTKEY = 1 << 0, PP_INPUTEVENT_MODIFIER_CONTROLKEY = 1 << 1, PP_INPUTEVENT_MODIFIER_ALTKEY = 1 << 2, PP_INPUTEVENT_MODIFIER_METAKEY = 1 << 3, PP_INPUTEVENT_MODIFIER_ISKEYPAD = 1 << 4, PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT = 1 << 5, PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN = 1 << 6, PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN = 1 << 7, PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN = 1 << 8, PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY = 1 << 9, PP_INPUTEVENT_MODIFIER_NUMLOCKKEY = 1 << 10, PP_INPUTEVENT_MODIFIER_ISLEFT = 1 << 11, PP_INPUTEVENT_MODIFIER_ISRIGHT = 1 << 12 } PP_InputEvent_Modifier; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Modifier, 4); /** * This enumeration contains constants representing each mouse button. To get * the mouse button for a mouse down or up event, use GetMouseButton on * PPB_InputEvent. */ typedef enum { PP_INPUTEVENT_MOUSEBUTTON_NONE = -1, PP_INPUTEVENT_MOUSEBUTTON_LEFT = 0, PP_INPUTEVENT_MOUSEBUTTON_MIDDLE = 1, PP_INPUTEVENT_MOUSEBUTTON_RIGHT = 2 } PP_InputEvent_MouseButton; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_MouseButton, 4); typedef enum { /** * Request mouse input events. * * Normally you will request mouse events by calling RequestInputEvents(). * The only use case for filtered events (via RequestFilteringInputEvents()) * is for instances that have irregular outlines and you want to perform hit * testing, which is very uncommon. Requesting non-filtered mouse events will * lead to higher performance. */ PP_INPUTEVENT_CLASS_MOUSE = 1 << 0, /** * Requests keyboard events. Often you will want to request filtered mode * (via RequestFilteringInputEvents) for keyboard events so you can pass on * events (by returning false) that you don't handle. For example, if you * don't request filtered mode and the user pressed "Page Down" when your * instance has focus, the page won't scroll which will be a poor experience. * * A small number of tab and window management commands like Alt-F4 are never * sent to the page. You can not request these keyboard commands since it * would allow pages to trap users on a page. */ PP_INPUTEVENT_CLASS_KEYBOARD = 1 << 1, /** * Identifies scroll wheel input event. Wheel events must be requested in * filtering mode via RequestFilteringInputEvents(). This is because many * wheel commands should be forwarded to the page. * * Most instances will not need this event. Consuming wheel events by * returning true from your filtered event handler will prevent the user from * scrolling the page when the mouse is over the instance which can be very * annoying. * * If you handle wheel events (for example, you have a document viewer which * the user can scroll), the recommended behavior is to return false only if * the wheel event actually causes your document to scroll. When the user * reaches the end of the document, return false to indicating that the event * was not handled. This will then forward the event to the containing page * for scrolling, producing the nested scrolling behavior users expect from * frames in a page. */ PP_INPUTEVENT_CLASS_WHEEL = 1 << 2, /** * Identifies touch input events. * * Request touch events only if you intend to handle them. If the browser * knows you do not need to handle touch events, it can handle them at a * higher level and achieve higher performance. If the plugin does not * register for touch-events, then it will receive synthetic mouse events that * are generated from the touch events (e.g. mouse-down for touch-start, * mouse-move for touch-move (with left-button down), and mouse-up for * touch-end. If the plugin does register for touch events, then the synthetic * mouse events are not created. */ PP_INPUTEVENT_CLASS_TOUCH = 1 << 3, /** * Identifies IME composition input events. * * Request this input event class if you allow on-the-spot IME input. */ PP_INPUTEVENT_CLASS_IME = 1 << 4 } PP_InputEvent_Class; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Class, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_InputEvent interface contains pointers to several * functions related to generic input events on the browser. */ struct PPB_InputEvent_1_0 { /** * RequestInputEvent() requests that input events corresponding to the given * input events are delivered to the instance. * * It's recommended that you use RequestFilteringInputEvents() for keyboard * events instead of this function so that you don't interfere with normal * browser accelerators. * * By default, no input events are delivered. Call this function with the * classes of events you are interested in to have them be delivered to * the instance. Calling this function will override any previous setting for * each specified class of input events (for example, if you previously * called RequestFilteringInputEvents(), this function will set those events * to non-filtering mode). * * Input events may have high overhead, so you should only request input * events that your plugin will actually handle. For example, the browser may * do optimizations for scroll or touch events that can be processed * substantially faster if it knows there are no non-default receivers for * that message. Requesting that such messages be delivered, even if they are * processed very quickly, may have a noticeable effect on the performance of * the page. * * Note that synthetic mouse events will be generated from touch events if * (and only if) you do not request touch events. * * When requesting input events through this function, the events will be * delivered and not bubbled to the default handlers. * * Example: * @code * RequestInputEvents(instance, PP_INPUTEVENT_CLASS_MOUSE); * RequestFilteringInputEvents(instance, * PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); * @endcode * * @param instance The PP_Instance of the instance requesting * the given events. * * @param event_classes A combination of flags from * PP_InputEvent_Class that identifies the classes of events the * instance is requesting. The flags are combined by logically ORing their * values. * * @return PP_OK if the operation succeeded, * PP_ERROR_BADARGUMENT if instance is invalid, or * PP_ERROR_NOTSUPPORTED if one of the event class bits were * illegal. In the case of an invalid bit, all valid bits will be applied * and only the illegal bits will be ignored. The most common cause of a * PP_ERROR_NOTSUPPORTED return value is requesting keyboard * events, these must use RequestFilteringInputEvents(). */ int32_t (*RequestInputEvents)(PP_Instance instance, uint32_t event_classes); /** * RequestFilteringInputEvents() requests that input events corresponding to * the given input events are delivered to the instance for filtering. * * By default, no input events are delivered. In most cases you would * register to receive events by calling RequestInputEvents(). In some cases, * however, you may wish to filter events such that they can be bubbled up * to the default handlers. In this case, register for those classes of * events using this function instead of RequestInputEvents(). * * Filtering input events requires significantly more overhead than just * delivering them to the instance. As such, you should only request * filtering in those cases where it's absolutely necessary. The reason is * that it requires the browser to stop and block for the instance to handle * the input event, rather than sending the input event asynchronously. This * can have significant overhead. * * Example: * @code * RequestInputEvents(instance, PP_INPUTEVENT_CLASS_MOUSE); * RequestFilteringInputEvents(instance, * PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); * @endcode * * @return PP_OK if the operation succeeded, * PP_ERROR_BADARGUMENT if instance is invalid, or * PP_ERROR_NOTSUPPORTED if one of the event class bits were * illegal. In the case of an invalid bit, all valid bits will be applied * and only the illegal bits will be ignored. */ int32_t (*RequestFilteringInputEvents)(PP_Instance instance, uint32_t event_classes); /** * ClearInputEventRequest() requests that input events corresponding to the * given input classes no longer be delivered to the instance. * * By default, no input events are delivered. If you have previously * requested input events via RequestInputEvents() or * RequestFilteringInputEvents(), this function will unregister handling * for the given instance. This will allow greater browser performance for * those events. * * Note that you may still get some input events after clearing the flag if * they were dispatched before the request was cleared. For example, if * there are 3 mouse move events waiting to be delivered, and you clear the * mouse event class during the processing of the first one, you'll still * receive the next two. You just won't get more events generated. * * @param instance The PP_Instance of the instance requesting * to no longer receive the given events. * * @param event_classes A combination of flags from * PP_InputEvent_Class that identify the classes of events the * instance is no longer interested in. */ void (*ClearInputEventRequest)(PP_Instance instance, uint32_t event_classes); /** * IsInputEvent() returns true if the given resource is a valid input event * resource. * * @param[in] resource A PP_Resource corresponding to a generic * resource. * * @return PP_TRUE if the given resource is a valid input event * resource. */ PP_Bool (*IsInputEvent)(PP_Resource resource); /** * GetType() returns the type of input event for the given input event * resource. * * @param[in] resource A PP_Resource corresponding to an input * event. * * @return A PP_InputEvent_Type if its a valid input event or * PP_INPUTEVENT_TYPE_UNDEFINED if the resource is invalid. */ PP_InputEvent_Type (*GetType)(PP_Resource event); /** * GetTimeStamp() Returns the time that the event was generated. This will be * before the current time since processing and dispatching the event has * some overhead. Use this value to compare the times the user generated two * events without being sensitive to variable processing time. * * @param[in] resource A PP_Resource corresponding to the event. * * @return The return value is in time ticks, which is a monotonically * increasing clock not related to the wall clock time. It will not change * if the user changes their clock or daylight savings time starts, so can * be reliably used to compare events. This means, however, that you can't * correlate event times to a particular time of day on the system clock. */ PP_TimeTicks (*GetTimeStamp)(PP_Resource event); /** * GetModifiers() returns a bitfield indicating which modifiers were down * at the time of the event. This is a combination of the flags in the * PP_InputEvent_Modifier enum. * * @param[in] resource A PP_Resource corresponding to an input * event. * * @return The modifiers associated with the event, or 0 if the given * resource is not a valid event resource. */ uint32_t (*GetModifiers)(PP_Resource event); }; typedef struct PPB_InputEvent_1_0 PPB_InputEvent; /** * The PPB_MouseInputEvent interface contains pointers to several * functions related to mouse input events. */ struct PPB_MouseInputEvent_1_1 { /** * Create() creates a mouse input event with the given parameters. Normally * you will get a mouse event passed through the * HandleInputEvent and will not need to create them, but some * applications may want to create their own for internal use. The type must * be one of the mouse event types. * * @param[in] instance The instance for which this event occurred. * * @param[in] type A PP_InputEvent_Type identifying the type of * input event. * * @param[in] time_stamp A PP_TimeTicks indicating the time * when the event occurred. * * @param[in] modifiers A bit field combination of the * PP_InputEvent_Modifier flags. * * @param[in] mouse_button The button that changed for mouse down or up * events. This value will be PP_EVENT_MOUSEBUTTON_NONE for * mouse move, enter, and leave events. * * @param[in] mouse_position A Point containing the x and y * position of the mouse when the event occurred. * * @param[in] mouse_movement The change in position of the mouse. * * @return A PP_Resource containing the new mouse input event. */ PP_Resource (*Create)(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, PP_InputEvent_MouseButton mouse_button, const struct PP_Point* mouse_position, int32_t click_count, const struct PP_Point* mouse_movement); /** * IsMouseInputEvent() determines if a resource is a mouse event. * * @param[in] resource A PP_Resource corresponding to an event. * * @return PP_TRUE if the given resource is a valid mouse input * event, otherwise PP_FALSE. */ PP_Bool (*IsMouseInputEvent)(PP_Resource resource); /** * GetButton() returns the mouse button that generated a mouse down or up * event. * * @param[in] mouse_event A PP_Resource corresponding to a * mouse event. * * @return The mouse button associated with mouse down and up events. This * value will be PP_EVENT_MOUSEBUTTON_NONE for mouse move, * enter, and leave events, and for all non-mouse events. */ PP_InputEvent_MouseButton (*GetButton)(PP_Resource mouse_event); /** * GetPosition() returns the pixel location of a mouse input event. When * the mouse is locked, it returns the last known mouse position just as * mouse lock was entered. * * @param[in] mouse_event A PP_Resource corresponding to a * mouse event. * * @return The point associated with the mouse event, relative to the upper- * left of the instance receiving the event. These values can be negative for * mouse drags. The return value will be (0, 0) for non-mouse events. */ struct PP_Point (*GetPosition)(PP_Resource mouse_event); /* * TODO(brettw) figure out exactly what this means. */ int32_t (*GetClickCount)(PP_Resource mouse_event); /** * Returns the change in position of the mouse. When the mouse is locked, * although the mouse position doesn't actually change, this function * still provides movement information, which indicates what the change in * position would be had the mouse not been locked. * * @param[in] mouse_event A PP_Resource corresponding to a * mouse event. * * @return The change in position of the mouse, relative to the previous * position. */ struct PP_Point (*GetMovement)(PP_Resource mouse_event); }; typedef struct PPB_MouseInputEvent_1_1 PPB_MouseInputEvent; struct PPB_MouseInputEvent_1_0 { PP_Resource (*Create)(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, PP_InputEvent_MouseButton mouse_button, const struct PP_Point* mouse_position, int32_t click_count); PP_Bool (*IsMouseInputEvent)(PP_Resource resource); PP_InputEvent_MouseButton (*GetButton)(PP_Resource mouse_event); struct PP_Point (*GetPosition)(PP_Resource mouse_event); int32_t (*GetClickCount)(PP_Resource mouse_event); }; /** * The PPB_WheelIputEvent interface contains pointers to several * functions related to wheel input events. */ struct PPB_WheelInputEvent_1_0 { /** * Create() creates a wheel input event with the given parameters. Normally * you will get a wheel event passed through the * HandleInputEvent and will not need to create them, but some * applications may want to create their own for internal use. * * @param[in] instance The instance for which this event occurred. * * @param[in] time_stamp A PP_TimeTicks indicating the time * when the event occurred. * * @param[in] modifiers A bit field combination of the * PP_InputEvent_Modifier flags. * * @param[in] wheel_delta The scroll wheel's horizontal and vertical scroll * amounts. * * @param[in] wheel_ticks The number of "clicks" of the scroll wheel that * have produced the event. * * @param[in] scroll_by_page When true, the user is requesting to scroll * by pages. When false, the user is requesting to scroll by lines. * * @return A PP_Resource containing the new wheel input event. */ PP_Resource (*Create)(PP_Instance instance, PP_TimeTicks time_stamp, uint32_t modifiers, const struct PP_FloatPoint* wheel_delta, const struct PP_FloatPoint* wheel_ticks, PP_Bool scroll_by_page); /** * IsWheelInputEvent() determines if a resource is a wheel event. * * @param[in] wheel_event A PP_Resource corresponding to an * event. * * @return PP_TRUE if the given resource is a valid wheel input * event. */ PP_Bool (*IsWheelInputEvent)(PP_Resource resource); /** * GetDelta() returns the amount vertically and horizontally the user has * requested to scroll by with their mouse wheel. A scroll down or to the * right (where the content moves up or left) is represented as positive * values, and a scroll up or to the left (where the content moves down or * right) is represented as negative values. * * This amount is system dependent and will take into account the user's * preferred scroll sensitivity and potentially also nonlinear acceleration * based on the speed of the scrolling. * * Devices will be of varying resolution. Some mice with large detents will * only generate integer scroll amounts. But fractional values are also * possible, for example, on some trackpads and newer mice that don't have * "clicks". * * @param[in] wheel_event A PP_Resource corresponding to a wheel * event. * * @return The vertical and horizontal scroll values. The units are either in * pixels (when scroll_by_page is false) or pages (when scroll_by_page is * true). For example, y = -3 means scroll up 3 pixels when scroll_by_page * is false, and scroll up 3 pages when scroll_by_page is true. */ struct PP_FloatPoint (*GetDelta)(PP_Resource wheel_event); /** * GetTicks() returns the number of "clicks" of the scroll wheel * that have produced the event. The value may have system-specific * acceleration applied to it, depending on the device. The positive and * negative meanings are the same as for GetDelta(). * * If you are scrolling, you probably want to use the delta values. These * tick events can be useful if you aren't doing actual scrolling and don't * want or pixel values. An example may be cycling between different items in * a game. * * @param[in] wheel_event A PP_Resource corresponding to a wheel * event. * * @return The number of "clicks" of the scroll wheel. You may receive * fractional values for the wheel ticks if the mouse wheel is high * resolution or doesn't have "clicks". If your program wants discrete * events (as in the "picking items" example) you should accumulate * fractional click values from multiple messages until the total value * reaches positive or negative one. This should represent a similar amount * of scrolling as for a mouse that has a discrete mouse wheel. */ struct PP_FloatPoint (*GetTicks)(PP_Resource wheel_event); /** * GetScrollByPage() indicates if the scroll delta x/y indicates pages or * lines to scroll by. * * @param[in] wheel_event A PP_Resource corresponding to a wheel * event. * * @return PP_TRUE if the event is a wheel event and the user is * scrolling by pages. PP_FALSE if not or if the resource is not * a wheel event. */ PP_Bool (*GetScrollByPage)(PP_Resource wheel_event); }; typedef struct PPB_WheelInputEvent_1_0 PPB_WheelInputEvent; /** * The PPB_KeyboardInputEvent interface contains pointers to * several functions related to keyboard input events. */ struct PPB_KeyboardInputEvent_1_2 { /** * Creates a keyboard input event with the given parameters. Normally you * will get a keyboard event passed through the HandleInputEvent and will not * need to create them, but some applications may want to create their own * for internal use. The type must be one of the keyboard event types. * * @param[in] instance The instance for which this event occurred. * * @param[in] type A PP_InputEvent_Type identifying the type of * input event. * * @param[in] time_stamp A PP_TimeTicks indicating the time * when the event occurred. * * @param[in] modifiers A bit field combination of the * PP_InputEvent_Modifier flags. * * @param[in] key_code This value reflects the DOM KeyboardEvent * keyCode field, which is the Windows-style Virtual Key * code of the key. * * @param[in] character_text This value represents the typed character as a * UTF-8 string. * * @param[in] code This value represents the DOM3 |code| string that * corresponds to the physical key being pressed. * * @return A PP_Resource containing the new keyboard input * event. */ PP_Resource (*Create)(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, uint32_t key_code, struct PP_Var character_text, struct PP_Var code); /** * IsKeyboardInputEvent() determines if a resource is a keyboard event. * * @param[in] resource A PP_Resource corresponding to an event. * * @return PP_TRUE if the given resource is a valid input event. */ PP_Bool (*IsKeyboardInputEvent)(PP_Resource resource); /** * GetKeyCode() returns the DOM keyCode field for the keyboard event. * Chrome populates this with the Windows-style Virtual Key code of the key. * * @param[in] key_event A PP_Resource corresponding to a * keyboard event. * * @return The DOM keyCode field for the keyboard event. */ uint32_t (*GetKeyCode)(PP_Resource key_event); /** * GetCharacterText() returns the typed character as a UTF-8 string for the * given character event. * * @param[in] character_event A PP_Resource corresponding to a * keyboard event. * * @return A string var representing a single typed character for character * input events. For non-character input events the return value will be an * undefined var. */ struct PP_Var (*GetCharacterText)(PP_Resource character_event); /** * GetCode() returns the DOM |code| field for this keyboard event, as * defined in the DOM3 Events spec: * http://www.w3.org/TR/DOM-Level-3-Events/ * * @param[in] key_event The key event for which to return the key code. * * @return The string that contains the DOM |code| for the keyboard event. */ struct PP_Var (*GetCode)(PP_Resource key_event); }; typedef struct PPB_KeyboardInputEvent_1_2 PPB_KeyboardInputEvent; struct PPB_KeyboardInputEvent_1_0 { PP_Resource (*Create)(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, uint32_t key_code, struct PP_Var character_text); PP_Bool (*IsKeyboardInputEvent)(PP_Resource resource); uint32_t (*GetKeyCode)(PP_Resource key_event); struct PP_Var (*GetCharacterText)(PP_Resource character_event); }; /** * @} */ /** * @addtogroup Enums * @{ */ typedef enum { /** * The list of all TouchPoints which are currently down. */ PP_TOUCHLIST_TYPE_TOUCHES = 0, /** * The list of all TouchPoints whose state has changed since the last * TouchInputEvent. */ PP_TOUCHLIST_TYPE_CHANGEDTOUCHES = 1, /** * The list of all TouchPoints which are targeting this plugin. This is a * subset of Touches. */ PP_TOUCHLIST_TYPE_TARGETTOUCHES = 2 } PP_TouchListType; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TouchListType, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_TouchInputEvent interface contains pointers to several * functions related to touch events. */ struct PPB_TouchInputEvent_1_0 { /** * Creates a touch input event with the given parameters. Normally you * will get a touch event passed through the HandleInputEvent and will not * need to create them, but some applications may want to create their own * for internal use. The type must be one of the touch event types. * This newly created touch input event does not have any touch point in any * of the touch-point lists. AddTouchPoint should be called to * add the touch-points. * * @param[in] instance The instance for which this event occurred. * * @param[in] type A PP_InputEvent_Type identifying the type of * input event. * * @param[in] time_stamp A PP_TimeTicks indicating the time * when the event occurred. * * @param[in] modifiers A bit field combination of the * PP_InputEvent_Modifier flags. * * @return A PP_Resource containing the new touch input event. */ PP_Resource (*Create)(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers); /** * Adds a touch point to the touch event in the specified touch-list. * * @param[in] touch_event A PP_Resource corresponding to a touch * event. * * @param[in] list The list to add the touch point to. * * @param[in] point The point to add to the list. */ void (*AddTouchPoint)(PP_Resource touch_event, PP_TouchListType list, const struct PP_TouchPoint* point); /** * IsTouchInputEvent() determines if a resource is a touch event. * * @param[in] resource A PP_Resource corresponding to an event. * * @return PP_TRUE if the given resource is a valid touch input * event, otherwise PP_FALSE. */ PP_Bool (*IsTouchInputEvent)(PP_Resource resource); /** * Returns the number of touch-points in the specified list. * * @param[in] resource A PP_Resource corresponding to a touch * event. * * @param[in] list The list. * * @return The number of touch-points in the specified list. */ uint32_t (*GetTouchCount)(PP_Resource resource, PP_TouchListType list); /** * Returns the touch-point at the specified index from the specified list. * * @param[in] resource A PP_Resource corresponding to a touch * event. * * @param[in] list The list. * * @param[in] index The index. * * @return A PP_TouchPoint representing the touch-point. */ struct PP_TouchPoint (*GetTouchByIndex)(PP_Resource resource, PP_TouchListType list, uint32_t index); /** * Returns the touch-point with the specified touch-id in the specified list. * * @param[in] resource A PP_Resource corresponding to a touch * event. * * @param[in] list The list. * * @param[in] touch_id The id of the touch-point. * * @return A PP_TouchPoint representing the touch-point. */ struct PP_TouchPoint (*GetTouchById)(PP_Resource resource, PP_TouchListType list, uint32_t touch_id); }; typedef struct PPB_TouchInputEvent_1_0 PPB_TouchInputEvent; struct PPB_IMEInputEvent_1_0 { /** * Create() creates an IME input event with the given parameters. Normally * you will get an IME event passed through the HandleInputEvent * and will not need to create them, but some applications may want to create * their own for internal use. * * @param[in] instance The instance for which this event occurred. * * @param[in] type A PP_InputEvent_Type identifying the type of * input event. The type must be one of the IME event types. * * @param[in] time_stamp A PP_TimeTicks indicating the time * when the event occurred. * * @param[in] text The string returned by GetText. * * @param[in] segment_number The number returned by * GetSegmentNumber. * * @param[in] segment_offsets The array of numbers returned by * GetSegmentOffset. If segment_number is zero, * the number of elements of the array should be zero. If * segment_number is non-zero, the length of the array must be * segment_number + 1. * * @param[in] target_segment The number returned by * GetTargetSegment. * * @param[in] selection_start The start index returned by * GetSelection. * * @param[in] selection_end The end index returned by * GetSelection. * * @return A PP_Resource containing the new IME input event. */ PP_Resource (*Create)(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, struct PP_Var text, uint32_t segment_number, const uint32_t segment_offsets[], int32_t target_segment, uint32_t selection_start, uint32_t selection_end); /** * IsIMEInputEvent() determines if a resource is an IME event. * * @param[in] resource A PP_Resource corresponding to an event. * * @return PP_TRUE if the given resource is a valid input event. */ PP_Bool (*IsIMEInputEvent)(PP_Resource resource); /** * GetText() returns the composition text as a UTF-8 string for the given IME * event. * * @param[in] ime_event A PP_Resource corresponding to an IME * event. * * @return A string var representing the composition text. For non-IME input * events the return value will be an undefined var. */ struct PP_Var (*GetText)(PP_Resource ime_event); /** * GetSegmentNumber() returns the number of segments in the composition text. * * @param[in] ime_event A PP_Resource corresponding to an IME * event. * * @return The number of segments. For events other than COMPOSITION_UPDATE, * returns 0. */ uint32_t (*GetSegmentNumber)(PP_Resource ime_event); /** * GetSegmentOffset() returns the position of the index-th segmentation point * in the composition text. The position is given by a byte-offset (not a * character-offset) of the string returned by GetText(). It always satisfies * 0=GetSegmentOffset(0) < ... < GetSegmentOffset(i) < GetSegmentOffset(i+1) * < ... < GetSegmentOffset(GetSegmentNumber())=(byte-length of GetText()). * Note that [GetSegmentOffset(i), GetSegmentOffset(i+1)) represents the range * of the i-th segment, and hence GetSegmentNumber() can be a valid argument * to this function instead of an off-by-1 error. * * @param[in] ime_event A PP_Resource corresponding to an IME * event. * * @param[in] index An integer indicating a segment. * * @return The byte-offset of the segmentation point. If the event is not * COMPOSITION_UPDATE or index is out of range, returns 0. */ uint32_t (*GetSegmentOffset)(PP_Resource ime_event, uint32_t index); /** * GetTargetSegment() returns the index of the current target segment of * composition. * * @param[in] ime_event A PP_Resource corresponding to an IME * event. * * @return An integer indicating the index of the target segment. When there * is no active target segment, or the event is not COMPOSITION_UPDATE, * returns -1. */ int32_t (*GetTargetSegment)(PP_Resource ime_event); /** * GetSelection() returns the range selected by caret in the composition text. * * @param[in] ime_event A PP_Resource corresponding to an IME * event. * * @param[out] start The start position of the current selection. * * @param[out] end The end position of the current selection. */ void (*GetSelection)(PP_Resource ime_event, uint32_t* start, uint32_t* end); }; typedef struct PPB_IMEInputEvent_1_0 PPB_IMEInputEvent; /** * @} */ #endif /* PPAPI_C_PPB_INPUT_EVENT_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_instance.h000066400000000000000000000057641321746453100232310ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_instance.idl modified Fri Dec 07 12:57:46 2012. */ #ifndef PPAPI_C_PPB_INSTANCE_H_ #define PPAPI_C_PPB_INSTANCE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_INSTANCE_INTERFACE_1_0 "PPB_Instance;1.0" #define PPB_INSTANCE_INTERFACE PPB_INSTANCE_INTERFACE_1_0 /** * @file * This file defines the PPB_Instance interface implemented by the * browser and containing pointers to functions related to * the module instance on a web page. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_Instance interface contains pointers to functions * related to the module instance on a web page. */ struct PPB_Instance_1_0 { /** * BindGraphics() binds the given graphics as the current display surface. * The contents of this device is what will be displayed in the instance's * area on the web page. The device must be a 2D or a 3D device. * * You can pass a NULL resource as the device parameter to * unbind all devices from the given instance. The instance will then appear * transparent. Re-binding the same device will return PP_TRUE * and will do nothing. * * Any previously-bound device will be released. It is an error to bind * a device when it is already bound to another instance. If you want * to move a device between instances, first unbind it from the old one, and * then rebind it to the new one. * * Binding a device will invalidate that portion of the web page to flush the * contents of the new device to the screen. * * @param[in] instance A PP_Instance identifying one instance of a module. * @param[in] device A PP_Resource corresponding to a graphics device. * * @return PP_Bool containing PP_TRUE if bind was * successful or PP_FALSE if the device was not the correct * type. On success, a reference to the device will be held by the * instance, so the caller can release its reference if it chooses. */ PP_Bool (*BindGraphics)(PP_Instance instance, PP_Resource device); /** * IsFullFrame() determines if the instance is full-frame. Such an instance * represents the entire document in a frame rather than an embedded * resource. This can happen if the user does a top-level navigation or the * page specifies an iframe to a resource with a MIME type registered by the * module. * * @param[in] instance A PP_Instance identifying one instance * of a module. * * @return A PP_Bool containing PP_TRUE if the * instance is full-frame. */ PP_Bool (*IsFullFrame)(PP_Instance instance); }; typedef struct PPB_Instance_1_0 PPB_Instance; /** * @} */ #endif /* PPAPI_C_PPB_INSTANCE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_media_stream_audio_track.h000066400000000000000000000175471321746453100264260ustar00rootroot00000000000000/* Copyright 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_media_stream_audio_track.idl modified Wed May 28 09:36:15 2014. */ #ifndef PPAPI_C_PPB_MEDIA_STREAM_AUDIO_TRACK_H_ #define PPAPI_C_PPB_MEDIA_STREAM_AUDIO_TRACK_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_MEDIASTREAMAUDIOTRACK_INTERFACE_0_1 "PPB_MediaStreamAudioTrack;0.1" #define PPB_MEDIASTREAMAUDIOTRACK_INTERFACE \ PPB_MEDIASTREAMAUDIOTRACK_INTERFACE_0_1 /** * @file * Defines the PPB_MediaStreamAudioTrack interface. Used for * receiving audio samples from a MediaStream audio track in the browser. */ /** * @addtogroup Enums * @{ */ /** * This enumeration contains audio track attributes which are used by * Configure(). */ typedef enum { /** * Attribute list terminator. */ PP_MEDIASTREAMAUDIOTRACK_ATTRIB_NONE = 0, /** * The maximum number of buffers to hold audio samples. * Note: this is only used as advisory; the browser may allocate more or fewer * based on available resources. How many buffers depends on usage - * request at least 2 to make sure latency doesn't cause lost samples. If * the plugin expects to hold on to more than one buffer at a time (e.g. to do * multi-buffer processing), it should request that many more. */ PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERS = 1, /** * The sample rate of audio data in buffers. The attribute value is a * PP_AudioBuffer_SampleRate. */ PP_MEDIASTREAMAUDIOTRACK_ATTRIB_SAMPLE_RATE = 2, /** * The sample size of audio data in buffers in bytes. The attribute value is a * PP_AudioBuffer_SampleSize. */ PP_MEDIASTREAMAUDIOTRACK_ATTRIB_SAMPLE_SIZE = 3, /** * The number of channels in audio buffers. * * Supported values: 1, 2 */ PP_MEDIASTREAMAUDIOTRACK_ATTRIB_CHANNELS = 4, /** * The duration of an audio buffer in milliseconds. * * Valid range: 10 to 10000 */ PP_MEDIASTREAMAUDIOTRACK_ATTRIB_DURATION = 5 } PP_MediaStreamAudioTrack_Attrib; /** * @} */ /** * @addtogroup Interfaces * @{ */ struct PPB_MediaStreamAudioTrack_0_1 { /** * Determines if a resource is a MediaStream audio track resource. * * @param[in] resource The PP_Resource to test. * * @return A PP_Bool with PP_TRUE if the given * resource is a Mediastream audio track resource or PP_FALSE * otherwise. */ PP_Bool (*IsMediaStreamAudioTrack)(PP_Resource resource); /** * Configures underlying buffers for incoming audio samples. * If the application doesn't want to drop samples, then the * PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERS should be * chosen such that inter-buffer processing time variability won't overrun all * the input buffers. If all buffers are filled, then samples will be * dropped. The application can detect this by examining the timestamp on * returned buffers. If Configure() is not called, default * settings will be used. Calls to Configure while the plugin holds * buffers will fail. * Example usage from plugin code: * @code * int32_t attribs[] = { * PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERS, 4, * PP_MEDIASTREAMAUDIOTRACK_ATTRIB_DURATION, 10, * PP_MEDIASTREAMAUDIOTRACK_ATTRIB_NONE}; * track_if->Configure(track, attribs, callback); * @endcode * * @param[in] audio_track A PP_Resource corresponding to an audio * resource. * @param[in] attrib_list A list of attribute name-value pairs in which each * attribute is immediately followed by the corresponding desired value. * The list is terminated by * PP_MEDIASTREAMAUDIOTRACK_ATTRIB_NONE. * @param[in] callback A PP_CompletionCallback to be called upon * completion of Configure(). * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*Configure)(PP_Resource audio_track, const int32_t attrib_list[], struct PP_CompletionCallback callback); /** * Gets attribute value for a given attribute name. * * @param[in] audio_track A PP_Resource corresponding to an audio * resource. * @param[in] attrib A PP_MediaStreamAudioTrack_Attrib for * querying. * @param[out] value A int32_t for storing the attribute value on success. * Otherwise, the value will not be changed. * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*GetAttrib)(PP_Resource audio_track, PP_MediaStreamAudioTrack_Attrib attrib, int32_t* value); /** * Returns the track ID of the underlying MediaStream audio track. * * @param[in] audio_track The PP_Resource to check. * * @return A PP_Var containing the MediaStream track ID as * a string. */ struct PP_Var (*GetId)(PP_Resource audio_track); /** * Checks whether the underlying MediaStream track has ended. * Calls to GetBuffer while the track has ended are safe to make and will * complete, but will fail. * * @param[in] audio_track The PP_Resource to check. * * @return A PP_Bool with PP_TRUE if the given * MediaStream track has ended or PP_FALSE otherwise. */ PP_Bool (*HasEnded)(PP_Resource audio_track); /** * Gets the next audio buffer from the MediaStream track. * If internal processing is slower than the incoming buffer rate, new buffers * will be dropped from the incoming stream. Once all buffers are full, * audio samples will be dropped until RecycleBuffer() is called * to free a slot for another buffer. * If there are no audio data in the input buffer, * PP_OK_COMPLETIONPENDING will be returned immediately and the * callback will be called, when a new buffer of audio samples * is received or an error happens. * * @param[in] audio_track A PP_Resource corresponding to an audio * resource. * @param[out] buffer A PP_Resource corresponding to * an AudioBuffer resource. * @param[in] callback A PP_CompletionCallback to be called upon * completion of GetBuffer(). * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*GetBuffer)(PP_Resource audio_track, PP_Resource* buffer, struct PP_CompletionCallback callback); /** * Recycles a buffer returned by GetBuffer(), so the track can * reuse the buffer. And the buffer will become invalid. The caller should * release all references it holds to buffer and not use it * anymore. * * @param[in] audio_track A PP_Resource corresponding to an audio * resource. * @param[in] buffer A PP_Resource corresponding to * an AudioBuffer resource returned by GetBuffer(). * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*RecycleBuffer)(PP_Resource audio_track, PP_Resource buffer); /** * Closes the MediaStream audio track and disconnects it from the audio * source. After calling Close(), no new buffers will be * received. * * @param[in] audio_track A PP_Resource corresponding to a * MediaStream audio track resource. */ void (*Close)(PP_Resource audio_track); }; typedef struct PPB_MediaStreamAudioTrack_0_1 PPB_MediaStreamAudioTrack; /** * @} */ #endif /* PPAPI_C_PPB_MEDIA_STREAM_AUDIO_TRACK_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_media_stream_video_track.h000066400000000000000000000257371321746453100264330ustar00rootroot00000000000000/* Copyright 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_media_stream_video_track.idl modified Mon Apr 7 15:25:56 2014. */ #ifndef PPAPI_C_PPB_MEDIA_STREAM_VIDEO_TRACK_H_ #define PPAPI_C_PPB_MEDIA_STREAM_VIDEO_TRACK_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_MEDIASTREAMVIDEOTRACK_INTERFACE_0_1 "PPB_MediaStreamVideoTrack;0.1" #define PPB_MEDIASTREAMVIDEOTRACK_INTERFACE_1_0 \ "PPB_MediaStreamVideoTrack;1.0" /* dev */ #define PPB_MEDIASTREAMVIDEOTRACK_INTERFACE \ PPB_MEDIASTREAMVIDEOTRACK_INTERFACE_0_1 /** * @file * Defines the PPB_MediaStreamVideoTrack interface. Used for * receiving video frames from a MediaStream video track in the browser. */ /** * @addtogroup Enums * @{ */ /** * This enumeration contains video track attributes which are used by * Configure(). */ typedef enum { /** * Attribute list terminator. */ PP_MEDIASTREAMVIDEOTRACK_ATTRIB_NONE = 0, /** * The maximum number of frames to hold in the input buffer. * Note: this is only used as advisory; the browser may allocate more or fewer * based on available resources. How many frames to buffer depends on usage - * request at least 2 to make sure latency doesn't cause lost frames. If * the plugin expects to hold on to more than one frame at a time (e.g. to do * multi-frame processing), it should request that many more. * If this attribute is not specified or value 0 is specified for this * attribute, the default value will be used. */ PP_MEDIASTREAMVIDEOTRACK_ATTRIB_BUFFERED_FRAMES = 1, /** * The width of video frames in pixels. It should be a multiple of 4. * If the specified size is different from the video source (webcam), * frames will be scaled to specified size. * If this attribute is not specified or value 0 is specified, the original * frame size of the video track will be used. * * Maximum value: 4096 (4K resolution). */ PP_MEDIASTREAMVIDEOTRACK_ATTRIB_WIDTH = 2, /** * The height of video frames in pixels. It should be a multiple of 4. * If the specified size is different from the video source (webcam), * frames will be scaled to specified size. * If this attribute is not specified or value 0 is specified, the original * frame size of the video track will be used. * * Maximum value: 4096 (4K resolution). */ PP_MEDIASTREAMVIDEOTRACK_ATTRIB_HEIGHT = 3, /** * The format of video frames. The attribute value is * a PP_VideoFrame_Format. If the specified format is different * from the video source (webcam), frames will be converted to specified * format. * If this attribute is not specified or value * PP_VIDEOFRAME_FORMAT_UNKNOWN is specified, the orignal frame * format of the video track will be used. */ PP_MEDIASTREAMVIDEOTRACK_ATTRIB_FORMAT = 4 } PP_MediaStreamVideoTrack_Attrib; /** * @} */ /** * @addtogroup Interfaces * @{ */ struct PPB_MediaStreamVideoTrack_1_0 { /* dev */ /** * Creates a PPB_MediaStreamVideoTrack resource for video output. Call this * when you will be creating frames and putting them to the track. * * @param[in] instance A PP_Instance identifying one instance of * a module. * * @return A PP_Resource corresponding to a * PPB_MediaStreamVideoTrack resource if successful, 0 if failed. */ PP_Resource (*Create)(PP_Instance instance); /** * Determines if a resource is a MediaStream video track resource. * * @param[in] resource The PP_Resource to test. * * @return A PP_Bool with PP_TRUE if the given * resource is a Mediastream video track resource or PP_FALSE * otherwise. */ PP_Bool (*IsMediaStreamVideoTrack)(PP_Resource resource); /** * Configures underlying frame buffers for incoming frames. * If the application doesn't want to drop frames, then the * PP_MEDIASTREAMVIDEOTRACK_ATTRIB_BUFFERED_FRAMES should be * chosen such that inter-frame processing time variability won't overrun the * input buffer. If the buffer is overfilled, then frames will be dropped. * The application can detect this by examining the timestamp on returned * frames. If some attributes are not specified, default values will be used * for those unspecified attributes. If Configure() is not * called, default settings will be used. * Example usage from plugin code: * @code * int32_t attribs[] = { * PP_MEDIASTREAMVIDEOTRACK_ATTRIB_BUFFERED_FRAMES, 4, * PP_MEDIASTREAMVIDEOTRACK_ATTRIB_NONE}; * track_if->Configure(track, attribs, callback); * @endcode * * @param[in] video_track A PP_Resource corresponding to a video * resource. * @param[in] attrib_list A list of attribute name-value pairs in which each * attribute is immediately followed by the corresponding desired value. * The list is terminated by * PP_MEDIASTREAMVIDEOTRACK_ATTRIB_NONE. * @param[in] callback PP_CompletionCallback to be called upon * completion of Configure(). * * @return An int32_t containing a result code from pp_errors.h. * Returns PP_ERROR_INPROGRESS if there is a pending call of * Configure() or GetFrame(), or the plugin * holds some frames which are not recycled with RecycleFrame(). * If an error is returned, all attributes and the underlying buffer will not * be changed. */ int32_t (*Configure)(PP_Resource video_track, const int32_t attrib_list[], struct PP_CompletionCallback callback); /** * Gets attribute value for a given attribute name. * * @param[in] video_track A PP_Resource corresponding to a video * resource. * @param[in] attrib A PP_MediaStreamVideoTrack_Attrib for * querying. * @param[out] value A int32_t for storing the attribute value on success. * Otherwise, the value will not be changed. * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*GetAttrib)(PP_Resource video_track, PP_MediaStreamVideoTrack_Attrib attrib, int32_t* value); /** * Returns the track ID of the underlying MediaStream video track. * * @param[in] video_track The PP_Resource to check. * * @return A PP_Var containing the MediaStream track ID as * a string. */ struct PP_Var (*GetId)(PP_Resource video_track); /** * Checks whether the underlying MediaStream track has ended. * Calls to GetFrame while the track has ended are safe to make and will * complete, but will fail. * * @param[in] video_track The PP_Resource to check. * * @return A PP_Bool with PP_TRUE if the given * MediaStream track has ended or PP_FALSE otherwise. */ PP_Bool (*HasEnded)(PP_Resource video_track); /** * Gets the next video frame from the MediaStream track. * If internal processing is slower than the incoming frame rate, new frames * will be dropped from the incoming stream. Once the input buffer is full, * frames will be dropped until RecycleFrame() is called to free * a spot for another frame to be buffered. * If there are no frames in the input buffer, * PP_OK_COMPLETIONPENDING will be returned immediately and the * callback will be called when a new frame is received or an * error happens. * * @param[in] video_track A PP_Resource corresponding to a video * resource. * @param[out] frame A PP_Resource corresponding to a VideoFrame * resource. * @param[in] callback A PP_CompletionCallback to be called upon * completion of GetFrame(). * * @return An int32_t containing a result code from pp_errors.h. * Returns PP_ERROR_NOMEMORY if max_buffered_frames frames buffer * was not allocated successfully. */ int32_t (*GetFrame)(PP_Resource video_track, PP_Resource* frame, struct PP_CompletionCallback callback); /** * Recycles a frame returned by GetFrame(), so the track can * reuse the underlying buffer of this frame. And the frame will become * invalid. The caller should release all references it holds to * frame and not use it anymore. * * @param[in] video_track A PP_Resource corresponding to a video * resource. * @param[in] frame A PP_Resource corresponding to a VideoFrame * resource returned by GetFrame(). * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*RecycleFrame)(PP_Resource video_track, PP_Resource frame); /** * Closes the MediaStream video track and disconnects it from video source. * After calling Close(), no new frames will be received. * * @param[in] video_track A PP_Resource corresponding to a * MediaStream video track resource. */ void (*Close)(PP_Resource video_track); /** * Gets a free frame for output. The frame is allocated by * Configure(). The caller should fill it with frame data, and * then use |PutFrame()| to send the frame back. */ int32_t (*GetEmptyFrame)(PP_Resource video_track, PP_Resource* frame, struct PP_CompletionCallback callback); /** * Sends a frame returned by |GetEmptyFrame()| to the output track. * After this function, the |frame| should not be used anymore and the * caller should release the reference that it holds. */ int32_t (*PutFrame)(PP_Resource video_track, PP_Resource frame); }; struct PPB_MediaStreamVideoTrack_0_1 { PP_Bool (*IsMediaStreamVideoTrack)(PP_Resource resource); int32_t (*Configure)(PP_Resource video_track, const int32_t attrib_list[], struct PP_CompletionCallback callback); int32_t (*GetAttrib)(PP_Resource video_track, PP_MediaStreamVideoTrack_Attrib attrib, int32_t* value); struct PP_Var (*GetId)(PP_Resource video_track); PP_Bool (*HasEnded)(PP_Resource video_track); int32_t (*GetFrame)(PP_Resource video_track, PP_Resource* frame, struct PP_CompletionCallback callback); int32_t (*RecycleFrame)(PP_Resource video_track, PP_Resource frame); void (*Close)(PP_Resource video_track); }; typedef struct PPB_MediaStreamVideoTrack_0_1 PPB_MediaStreamVideoTrack; /** * @} */ #endif /* PPAPI_C_PPB_MEDIA_STREAM_VIDEO_TRACK_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_message_loop.h000066400000000000000000000310671321746453100240750ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_message_loop.idl modified Thu May 9 14:59:57 2013. */ #ifndef PPAPI_C_PPB_MESSAGE_LOOP_H_ #define PPAPI_C_PPB_MESSAGE_LOOP_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_MESSAGELOOP_INTERFACE_1_0 "PPB_MessageLoop;1.0" #define PPB_MESSAGELOOP_INTERFACE PPB_MESSAGELOOP_INTERFACE_1_0 /** * @file * Defines the PPB_MessageLoop interface. */ /** * @addtogroup Interfaces * @{ */ /** * A message loop allows PPAPI calls to be issued on a thread. You may not * issue any API calls on a thread without creating a message loop. It also * allows you to post work to the message loop for a thread. * * To process work posted to the message loop, as well as completion callbacks * for asynchronous operations, you must run the message loop via Run(). * * Note the system manages the lifetime of the instance (and all associated * resources). If the instance is deleted from the page, background threads may * suddenly see their PP_Resource handles become invalid. In this case, calls * will fail with PP_ERROR_BADRESOURCE. If you need to access data associated * with your instance, you will probably want to create some kind of threadsafe * proxy object that can handle asynchronous destruction of the instance object. * * Typical usage: * On the main thread: * - Create the thread yourself (using pthreads). * - Create the message loop resource. * - Pass the message loop resource to your thread's main function. * - Call PostWork() on the message loop to run functions on the thread. * * From the background thread's main function: * - Call AttachToCurrentThread() with the message loop resource. * - Call Run() with the message loop resource. * * Your callbacks should look like this: * @code * void DoMyWork(void* user_data, int32_t status) { * if (status != PP_OK) { * Cleanup(); // e.g. free user_data. * return; * } * ... do your work... * } * @endcode * For a C++ example, see ppapi/utility/threading/simple_thread.h * * (You can also create the message loop resource on the background thread, * but then the main thread will have no reference to it should you want to * call PostWork()). * * * THREAD HANDLING * * The main thread has an implicitly created message loop. The main thread is * the thread where PPP_InitializeModule and PPP_Instance functions are called. * You can retrieve a reference to this message loop by calling * GetForMainThread() or, if your code is on the main thread, GetCurrent() will * also work. * * Some special threads created by the system can not have message loops. In * particular, the background thread created for audio processing has this * requirement because it's intended to be highly responsive to keep up with * the realtime requirements of audio processing. You can not make PPAPI calls * from these threads. * * Once you associate a message loop with a thread, you don't have to keep a * reference to it. The system will hold a reference to the message loop for as * long as the thread is running. The current message loop can be retrieved * using the GetCurrent() function. * * It is legal to create threads in your plugin without message loops, but * PPAPI calls will fail unless explicitly noted in the documentation. * * You can create a message loop object on a thread and never actually run the * message loop. This will allow you to call blocking PPAPI calls (via * PP_BlockUntilComplete()). If you make any asynchronous calls, the callbacks * from those calls will be queued in the message loop and never run. The same * thing will happen if work is scheduled after the message loop exits and * the message loop is not run again. * * * DESTRUCTION AND ERROR HANDLING * * Often, your application will associate memory with completion callbacks. For * example, the C++ CompletionCallbackFactory has a small amount of * heap-allocated memory for each callback. This memory will be leaked if the * callback is never run. To avoid this memory leak, you need to be careful * about error handling and shutdown. * * There are a number of cases where posted callbacks will never be run: * * - You tear down the thread (via pthreads) without "destroying" the message * loop (via PostQuit with should_destroy = PP_TRUE). In this case, any * tasks in the message queue will be lost. * * - You create a message loop, post callbacks to it, and never run it. * * - You quit the message loop via PostQuit with should_destroy set to * PP_FALSE. In this case, the system will assume the message loop will be * run again later and keep your tasks. * * To do proper shutdown, call PostQuit with should_destroy = PP_TRUE. This * will prohibit future work from being posted, and will allow the message loop * to run until all pending tasks are run. * * If you post a callback to a message loop that's been destroyed, or to an * invalid message loop, PostWork will return an error and will not run the * callback. This is true even for callbacks with the "required" flag set, * since the system may not even know what thread to issue the error callback * on. * * Therefore, you should check for errors from PostWork and destroy any * associated memory to avoid leaks. If you're using the C++ * CompletionCallbackFactory, use the following pattern: * @code * pp::CompletionCallback callback = factory_.NewOptionalCallback(...); * int32_t result = message_loop.PostWork(callback); * if (result != PP_OK) * callback.Run(result); * @endcode * This will run the callback with an error value, and assumes that the * implementation of your callback checks the "result" argument and returns * immediately on error. */ struct PPB_MessageLoop_1_0 { /** * Creates a message loop resource. * * This may be called from any thread. After your thread starts but before * issuing any other PPAPI calls on it, you must associate it with a message * loop by calling AttachToCurrentThread. */ PP_Resource (*Create)(PP_Instance instance); /** * Returns a resource identifying the message loop for the main thread. The * main thread always has a message loop created by the system. */ PP_Resource (*GetForMainThread)(void); /** * Returns a reference to the PPB_MessageLoop object attached to the current * thread. If there is no attached message loop, the return value will be 0. */ PP_Resource (*GetCurrent)(void); /** * Sets the given message loop resource as being the associated message loop * for the currently running thread. * * You must call this function exactly once on a thread before making any * PPAPI calls. A message loop can only be attached to one thread, and the * message loop can not be changed later. The message loop will be attached * as long as the thread is running or until you quit with should_destroy * set to PP_TRUE. * * If this function fails, attempting to run the message loop will fail. * Note that you can still post work to the message loop: it will get queued * up should the message loop eventually be successfully attached and run. * * @return * - PP_OK: The message loop was successfully attached to the thread and is * ready to use. * - PP_ERROR_BADRESOURCE: The given message loop resource is invalid. * - PP_ERROR_INPROGRESS: The current thread already has a message loop * attached. This will always be the case for the main thread, which has * an implicit system-created message loop attached. * - PP_ERROR_WRONG_THREAD: The current thread type can not have a message * loop attached to it. See the interface level discussion about these * special threads, which include realtime audio threads. */ int32_t (*AttachToCurrentThread)(PP_Resource message_loop); /** * Runs the thread message loop. Running the message loop is required for you * to get issued completion callbacks on the thread. * * The message loop identified by the argument must have been previously * successfully attached to the current thread. * * You may not run nested message loops. Since the main thread has an * implicit message loop that the system runs, you may not call Run on the * main thread. * * @return * - PP_OK: The message loop was successfully run. Note that on * success, the message loop will only exit when you call PostQuit(). * - PP_ERROR_BADRESOURCE: The given message loop resource is invalid. * - PP_ERROR_WRONG_THREAD: You are attempting to run a message loop that * has not been successfully attached to the current thread. Call * AttachToCurrentThread(). * - PP_ERROR_INPROGRESS: You are attempting to call Run in a nested * fashion (Run is already on the stack). This will occur if you attempt * to call run on the main thread's message loop (see above). */ int32_t (*Run)(PP_Resource message_loop); /** * Schedules work to run on the given message loop. This may be called from * any thread. Posted work will be executed in the order it was posted when * the message loop is Run(). * * @param message_loop The message loop resource. * * @param callback The completion callback to execute from the message loop. * * @param delay_ms The number of milliseconds to delay execution of the given * completion callback. Passing 0 means it will get queued normally and * executed in order. * * * The completion callback will be called with PP_OK as the "result" parameter * if it is run normally. It is good practice to check for PP_OK and return * early otherwise. * * The "required" flag on the completion callback is ignored. If there is an * error posting your callback, the error will be returned from PostWork and * the callback will never be run (because there is no appropriate place to * run your callback with an error without causing unexpected threading * problems). If you associate memory with the completion callback (for * example, you're using the C++ CompletionCallbackFactory), you will need to * free this or manually run the callback. See "Destruction and error * handling" above. * * * You can call this function before the message loop has started and the * work will get queued until the message loop is run. You can also post * work after the message loop has exited as long as should_destroy was * PP_FALSE. It will be queued until the next invocation of Run(). * * @return * - PP_OK: The work was posted to the message loop's queue. As described * above, this does not mean that the work has been or will be executed * (if you never run the message loop after posting). * - PP_ERROR_BADRESOURCE: The given message loop resource is invalid. * - PP_ERROR_BADARGUMENT: The function pointer for the completion callback * is null (this will be the case if you pass PP_BlockUntilComplete()). * - PP_ERROR_FAILED: The message loop has been destroyed. */ int32_t (*PostWork)(PP_Resource message_loop, struct PP_CompletionCallback callback, int64_t delay_ms); /** * Posts a quit message to the given message loop's work queue. Work posted * before that point will be processed before quitting. * * This may be called on the message loop registered for the current thread, * or it may be called on the message loop registered for another thread. It * is an error to attempt to PostQuit() the main thread loop. * * @param should_destroy Marks the message loop as being in a destroyed state * and prevents further posting of messages. * * If you quit a message loop without setting should_destroy, it will still * be attached to the thread and you can still run it again by calling Run() * again. If you destroy it, it will be detached from the current thread. * * @return * - PP_OK: The request to quit was successfully posted. * - PP_ERROR_BADRESOURCE: The message loop was invalid. * - PP_ERROR_WRONG_THREAD: You are attempting to quit the main thread. * The main thread's message loop is managed by the system and can't be * quit. */ int32_t (*PostQuit)(PP_Resource message_loop, PP_Bool should_destroy); }; typedef struct PPB_MessageLoop_1_0 PPB_MessageLoop; /** * @} */ #endif /* PPAPI_C_PPB_MESSAGE_LOOP_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_messaging.h000066400000000000000000000153011321746453100233660ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_messaging.idl modified Wed Sep 24 10:48:37 2014. */ #ifndef PPAPI_C_PPB_MESSAGING_H_ #define PPAPI_C_PPB_MESSAGING_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/ppp_message_handler.h" #define PPB_MESSAGING_INTERFACE_1_0 "PPB_Messaging;1.0" #define PPB_MESSAGING_INTERFACE_1_2 "PPB_Messaging;1.2" #define PPB_MESSAGING_INTERFACE PPB_MESSAGING_INTERFACE_1_2 /** * @file * This file defines the PPB_Messaging interface implemented * by the browser for sending messages to DOM elements associated with a * specific module instance. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_Messaging interface is implemented by the browser * and is related to sending messages to JavaScript message event listeners on * the DOM element associated with specific module instance. */ struct PPB_Messaging_1_2 { /** * PostMessage() asynchronously invokes any listeners for message events on * the DOM element for the given module instance. A call to PostMessage() * will not block while the message is processed. * * @param[in] instance A PP_Instance identifying one instance * of a module. * @param[in] message A PP_Var containing the data to be sent to * JavaScript. * message can be any PP_Var type except * PP_VARTYPE_OBJECT. Array/Dictionary types are supported from * Chrome M29 onward. All var types are copied when passing them to * JavaScript. * * When passing array or dictionary PP_Vars, the entire reference * graph will be converted and transferred. If the reference graph has cycles, * the message will not be sent and an error will be logged to the console. * * Listeners for message events in JavaScript code will receive an object * conforming to the HTML 5 MessageEvent interface. * Specifically, the value of message will be contained as a property called * data in the received MessageEvent. * * This messaging system is similar to the system used for listening for * messages from Web Workers. Refer to * http://www.whatwg.org/specs/web-workers/current-work/ for * further information. * * Example: * * @code * * * * * * * @endcode * * The module instance then invokes PostMessage() as follows: * * @code * * char hello_world[] = "Hello world!"; * PP_Var hello_var = ppb_var_interface->VarFromUtf8(instance, * hello_world, * sizeof(hello_world)); * ppb_messaging_interface->PostMessage(instance, hello_var); // Copies var. * ppb_var_interface->Release(hello_var); * * @endcode * * The browser will pop-up an alert saying "Hello world!" */ void (*PostMessage)(PP_Instance instance, struct PP_Var message); /** * Registers a handler for receiving messages from JavaScript. If a handler * is registered this way, it will replace PPP_Messaging, and all messages * sent from JavaScript via postMessage and postMessageAndAwaitResponse will * be dispatched to handler. * * The function calls will be dispatched via message_loop. This * means that the functions will be invoked on the thread to which * message_loop is attached, when message_loop is * run. It is illegal to pass the main thread message loop; * RegisterMessageHandler will return PP_ERROR_WRONG_THREAD in that case. * If you quit message_loop before calling Unregister(), * the browser will not be able to call functions in the plugin's message * handler any more. That could mean missing some messages or could cause a * leak if you depend on Destroy() to free hander data. So you should, * whenever possible, Unregister() the handler prior to quitting its event * loop. * * Attempting to register a message handler when one is already registered * will cause the current MessageHandler to be unregistered and replaced. In * that case, no messages will be sent to the "default" message handler * (PPP_Messaging). Messages will stop arriving at the prior message handler * and will begin to be dispatched at the new message handler. * * @param[in] instance A PP_Instance identifying one instance * of a module. * @param[in] user_data A pointer the plugin may choose to use when handling * calls to functions within PPP_MessageHandler. The browser will pass this * same pointer when invoking functions within PPP_MessageHandler. * @param[in] handler The plugin-provided set of functions for handling * messages. * @param[in] message_loop Represents the message loop on which * PPP_MessageHandler functions should be invoked. * @return PP_OK on success, or an error from pp_errors.h. */ int32_t (*RegisterMessageHandler)( PP_Instance instance, void* user_data, const struct PPP_MessageHandler_0_2* handler, PP_Resource message_loop); /** * Unregisters the current message handler for instance if one * is registered. After this call, the message handler (if one was * registered) will have "Destroy" called on it and will receive no further * messages after that point. After that point, all messages sent from * JavaScript using postMessage() will be dispatched to PPP_Messaging (if * the plugin supports PPP_MESSAGING_INTERFACE). Attempts to call * postMessageAndAwaitResponse() from JavaScript will fail. * * Attempting to unregister a message handler when none is registered has no * effect. * * @param[in] instance A PP_Instance identifying one instance * of a module. */ void (*UnregisterMessageHandler)(PP_Instance instance); }; typedef struct PPB_Messaging_1_2 PPB_Messaging; struct PPB_Messaging_1_0 { void (*PostMessage)(PP_Instance instance, struct PP_Var message); }; /** * @} */ #endif /* PPAPI_C_PPB_MESSAGING_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_mouse_cursor.h000066400000000000000000000111701321746453100241360ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_mouse_cursor.idl modified Thu Mar 28 10:11:32 2013. */ #ifndef PPAPI_C_PPB_MOUSE_CURSOR_H_ #define PPAPI_C_PPB_MOUSE_CURSOR_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_MOUSECURSOR_INTERFACE_1_0 "PPB_MouseCursor;1.0" #define PPB_MOUSECURSOR_INTERFACE PPB_MOUSECURSOR_INTERFACE_1_0 /** * @file * This file defines the PPB_MouseCursor interface for setting * the mouse cursor. */ /** * @addtogroup Enums * @{ */ /** * The PP_MouseCursor_Type enumeration lists the available stock * cursor types. */ enum PP_MouseCursor_Type { PP_MOUSECURSOR_TYPE_CUSTOM = -1, PP_MOUSECURSOR_TYPE_POINTER = 0, PP_MOUSECURSOR_TYPE_CROSS = 1, PP_MOUSECURSOR_TYPE_HAND = 2, PP_MOUSECURSOR_TYPE_IBEAM = 3, PP_MOUSECURSOR_TYPE_WAIT = 4, PP_MOUSECURSOR_TYPE_HELP = 5, PP_MOUSECURSOR_TYPE_EASTRESIZE = 6, PP_MOUSECURSOR_TYPE_NORTHRESIZE = 7, PP_MOUSECURSOR_TYPE_NORTHEASTRESIZE = 8, PP_MOUSECURSOR_TYPE_NORTHWESTRESIZE = 9, PP_MOUSECURSOR_TYPE_SOUTHRESIZE = 10, PP_MOUSECURSOR_TYPE_SOUTHEASTRESIZE = 11, PP_MOUSECURSOR_TYPE_SOUTHWESTRESIZE = 12, PP_MOUSECURSOR_TYPE_WESTRESIZE = 13, PP_MOUSECURSOR_TYPE_NORTHSOUTHRESIZE = 14, PP_MOUSECURSOR_TYPE_EASTWESTRESIZE = 15, PP_MOUSECURSOR_TYPE_NORTHEASTSOUTHWESTRESIZE = 16, PP_MOUSECURSOR_TYPE_NORTHWESTSOUTHEASTRESIZE = 17, PP_MOUSECURSOR_TYPE_COLUMNRESIZE = 18, PP_MOUSECURSOR_TYPE_ROWRESIZE = 19, PP_MOUSECURSOR_TYPE_MIDDLEPANNING = 20, PP_MOUSECURSOR_TYPE_EASTPANNING = 21, PP_MOUSECURSOR_TYPE_NORTHPANNING = 22, PP_MOUSECURSOR_TYPE_NORTHEASTPANNING = 23, PP_MOUSECURSOR_TYPE_NORTHWESTPANNING = 24, PP_MOUSECURSOR_TYPE_SOUTHPANNING = 25, PP_MOUSECURSOR_TYPE_SOUTHEASTPANNING = 26, PP_MOUSECURSOR_TYPE_SOUTHWESTPANNING = 27, PP_MOUSECURSOR_TYPE_WESTPANNING = 28, PP_MOUSECURSOR_TYPE_MOVE = 29, PP_MOUSECURSOR_TYPE_VERTICALTEXT = 30, PP_MOUSECURSOR_TYPE_CELL = 31, PP_MOUSECURSOR_TYPE_CONTEXTMENU = 32, PP_MOUSECURSOR_TYPE_ALIAS = 33, PP_MOUSECURSOR_TYPE_PROGRESS = 34, PP_MOUSECURSOR_TYPE_NODROP = 35, PP_MOUSECURSOR_TYPE_COPY = 36, PP_MOUSECURSOR_TYPE_NONE = 37, PP_MOUSECURSOR_TYPE_NOTALLOWED = 38, PP_MOUSECURSOR_TYPE_ZOOMIN = 39, PP_MOUSECURSOR_TYPE_ZOOMOUT = 40, PP_MOUSECURSOR_TYPE_GRAB = 41, PP_MOUSECURSOR_TYPE_GRABBING = 42 }; PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_MouseCursor_Type, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_MouseCursor allows setting the mouse cursor. */ struct PPB_MouseCursor_1_0 { /** * Sets the given mouse cursor. The mouse cursor will be in effect whenever * the mouse is over the given instance until it is set again by another * call. Note that you can hide the mouse cursor by setting it to the * PP_MOUSECURSOR_TYPE_NONE type. * * This function allows setting both system defined mouse cursors and * custom cursors. To set a system-defined cursor, pass the type you want * and set the custom image to 0 and the hot spot to NULL. To set a custom * cursor, set the type to PP_MOUSECURSOR_TYPE_CUSTOM and * specify your image and hot spot. * * @param[in] instance A PP_Instance identifying the instance * that the mouse cursor will affect. * * @param[in] type A PP_MouseCursor_Type identifying the type of * mouse cursor to show. * * @param[in] image A PPB_ImageData resource identifying the * custom image to set when the type is * PP_MOUSECURSOR_TYPE_CUSTOM. The image must be less than 32 * pixels in each direction and must be of the system's native image format. * When you are specifying a predefined cursor, this parameter must be 0. * * @param[in] hot_spot When setting a custom cursor, this identifies the * pixel position within the given image of the "hot spot" of the cursor. * When specifying a stock cursor, this parameter is ignored. * * @return PP_TRUE on success, or PP_FALSE if the instance or cursor type * is invalid, or if the image is too large. */ PP_Bool (*SetCursor)(PP_Instance instance, enum PP_MouseCursor_Type type, PP_Resource image, const struct PP_Point* hot_spot); }; typedef struct PPB_MouseCursor_1_0 PPB_MouseCursor; /** * @} */ #endif /* PPAPI_C_PPB_MOUSE_CURSOR_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_mouse_lock.h000066400000000000000000000055301321746453100235540ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_mouse_lock.idl modified Mon Dec 17 16:09:50 2012. */ #ifndef PPAPI_C_PPB_MOUSE_LOCK_H_ #define PPAPI_C_PPB_MOUSE_LOCK_H_ #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #define PPB_MOUSELOCK_INTERFACE_1_0 "PPB_MouseLock;1.0" #define PPB_MOUSELOCK_INTERFACE PPB_MOUSELOCK_INTERFACE_1_0 /** * @file * This file defines the PPB_MouseLock interface for * locking the target of mouse events to a specific module instance. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_MouseLock interface is implemented by the browser. * This interface provides a way of locking the target of mouse events to a * single module instance and removing the cursor from view. This mode is * useful for certain classes of applications, especially first-person * perspective 3D applications and 3D modeling software. */ struct PPB_MouseLock_1_0 { /** * LockMouse() requests the mouse to be locked. * * While the mouse is locked, the cursor is implicitly hidden from the user. * Any movement of the mouse will generate a * PP_INPUTEVENT_TYPE_MOUSEMOVE event. The * GetPosition() function in the PPB_MouseInputEvent * interface reports the last known mouse position just as mouse lock was * entered. The GetMovement() function provides relative movement * information indicating what the change in position of the mouse would be * had it not been locked. * * The browser may revoke the mouse lock for reasons including (but not * limited to) the user pressing the ESC key, the user activating another * program using a reserved keystroke (e.g. ALT+TAB), or some other system * event. * * @param[in] instance A PP_Instance identifying one instance * of a module. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*LockMouse)(PP_Instance instance, struct PP_CompletionCallback callback); /** * UnlockMouse() causes the mouse to be unlocked, allowing it to track user * movement again. This is an asynchronous operation. The module instance * will be notified using the PPP_MouseLock interface when it * has lost the mouse lock. * * @param[in] instance A PP_Instance identifying one instance * of a module. */ void (*UnlockMouse)(PP_Instance instance); }; typedef struct PPB_MouseLock_1_0 PPB_MouseLock; /** * @} */ #endif /* PPAPI_C_PPB_MOUSE_LOCK_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_net_address.h000066400000000000000000000131731321746453100237110ustar00rootroot00000000000000/* Copyright 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_net_address.idl modified Sat Jun 22 10:14:31 2013. */ #ifndef PPAPI_C_PPB_NET_ADDRESS_H_ #define PPAPI_C_PPB_NET_ADDRESS_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_NETADDRESS_INTERFACE_1_0 "PPB_NetAddress;1.0" #define PPB_NETADDRESS_INTERFACE PPB_NETADDRESS_INTERFACE_1_0 /** * @file * This file defines the PPB_NetAddress interface. */ /** * @addtogroup Enums * @{ */ /** * Network address family types. */ typedef enum { /** * The address family is unspecified. */ PP_NETADDRESS_FAMILY_UNSPECIFIED = 0, /** * The Internet Protocol version 4 (IPv4) address family. */ PP_NETADDRESS_FAMILY_IPV4 = 1, /** * The Internet Protocol version 6 (IPv6) address family. */ PP_NETADDRESS_FAMILY_IPV6 = 2 } PP_NetAddress_Family; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_NetAddress_Family, 4); /** * @} */ /** * @addtogroup Structs * @{ */ /** * All members are expressed in network byte order. */ struct PP_NetAddress_IPv4 { /** * Port number. */ uint16_t port; /** * IPv4 address. */ uint8_t addr[4]; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_NetAddress_IPv4, 6); /** * All members are expressed in network byte order. */ struct PP_NetAddress_IPv6 { /** * Port number. */ uint16_t port; /** * IPv6 address. */ uint8_t addr[16]; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_NetAddress_IPv6, 18); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_NetAddress interface provides operations on network * addresses. */ struct PPB_NetAddress_1_0 { /** * Creates a PPB_NetAddress resource with the specified IPv4 * address. * * @param[in] instance A PP_Instance identifying one instance of * a module. * @param[in] ipv4_addr An IPv4 address. * * @return A PP_Resource representing the same address as * ipv4_addr or 0 on failure. */ PP_Resource (*CreateFromIPv4Address)( PP_Instance instance, const struct PP_NetAddress_IPv4* ipv4_addr); /** * Creates a PPB_NetAddress resource with the specified IPv6 * address. * * @param[in] instance A PP_Instance identifying one instance of * a module. * @param[in] ipv6_addr An IPv6 address. * * @return A PP_Resource representing the same address as * ipv6_addr or 0 on failure. */ PP_Resource (*CreateFromIPv6Address)( PP_Instance instance, const struct PP_NetAddress_IPv6* ipv6_addr); /** * Determines if a given resource is a network address. * * @param[in] resource A PP_Resource to check. * * @return PP_TRUE if the input is a PPB_NetAddress * resource; PP_FALSE otherwise. */ PP_Bool (*IsNetAddress)(PP_Resource resource); /** * Gets the address family. * * @param[in] addr A PP_Resource corresponding to a network * address. * * @return The address family on success; * PP_NETADDRESS_FAMILY_UNSPECIFIED on failure. */ PP_NetAddress_Family (*GetFamily)(PP_Resource addr); /** * Returns a human-readable description of the network address. The * description is in the form of host [ ":" port ] and conforms to * http://tools.ietf.org/html/rfc3986#section-3.2 for IPv4 and IPv6 addresses * (e.g., "192.168.0.1", "192.168.0.1:99", or "[::1]:80"). * * @param[in] addr A PP_Resource corresponding to a network * address. * @param[in] include_port Whether to include the port number in the * description. * * @return A string PP_Var on success; an undefined * PP_Var on failure. */ struct PP_Var (*DescribeAsString)(PP_Resource addr, PP_Bool include_port); /** * Fills a PP_NetAddress_IPv4 structure if the network address is * of PP_NETADDRESS_FAMILY_IPV4 address family. * Note that passing a network address of * PP_NETADDRESS_FAMILY_IPV6 address family will fail even if the * address is an IPv4-mapped IPv6 address. * * @param[in] addr A PP_Resource corresponding to a network * address. * @param[out] ipv4_addr A PP_NetAddress_IPv4 structure to store * the result. * * @return A PP_Bool value indicating whether the operation * succeeded. */ PP_Bool (*DescribeAsIPv4Address)(PP_Resource addr, struct PP_NetAddress_IPv4* ipv4_addr); /** * Fills a PP_NetAddress_IPv6 structure if the network address is * of PP_NETADDRESS_FAMILY_IPV6 address family. * Note that passing a network address of * PP_NETADDRESS_FAMILY_IPV4 address family will fail - this * method doesn't map it to an IPv6 address. * * @param[in] addr A PP_Resource corresponding to a network * address. * @param[out] ipv6_addr A PP_NetAddress_IPv6 structure to store * the result. * * @return A PP_Bool value indicating whether the operation * succeeded. */ PP_Bool (*DescribeAsIPv6Address)(PP_Resource addr, struct PP_NetAddress_IPv6* ipv6_addr); }; typedef struct PPB_NetAddress_1_0 PPB_NetAddress; /** * @} */ #endif /* PPAPI_C_PPB_NET_ADDRESS_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_network_list.h000066400000000000000000000121561321746453100241420ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_network_list.idl modified Mon Sep 9 11:16:26 2013. */ #ifndef PPAPI_C_PPB_NETWORK_LIST_H_ #define PPAPI_C_PPB_NETWORK_LIST_H_ #include "ppapi/c/pp_array_output.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_NETWORKLIST_INTERFACE_1_0 "PPB_NetworkList;1.0" #define PPB_NETWORKLIST_INTERFACE PPB_NETWORKLIST_INTERFACE_1_0 /** * @file * This file defines the PPB_NetworkList interface. */ /** * @addtogroup Enums * @{ */ /** * Type of a network interface. */ typedef enum { /** * Type of the network interface is not known. */ PP_NETWORKLIST_TYPE_UNKNOWN = 0, /** * Wired Ethernet network. */ PP_NETWORKLIST_TYPE_ETHERNET = 1, /** * Wireless Wi-Fi network. */ PP_NETWORKLIST_TYPE_WIFI = 2, /** * Cellular network (e.g. LTE). */ PP_NETWORKLIST_TYPE_CELLULAR = 3 } PP_NetworkList_Type; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_NetworkList_Type, 4); /** * State of a network interface. */ typedef enum { /** * Network interface is down. */ PP_NETWORKLIST_STATE_DOWN = 0, /** * Network interface is up. */ PP_NETWORKLIST_STATE_UP = 1 } PP_NetworkList_State; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_NetworkList_State, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_NetworkList is used to represent a list of * network interfaces and their configuration. The content of the list * is immutable. The current networks configuration can be received * using the PPB_NetworkMonitor interface. */ struct PPB_NetworkList_1_0 { /** * Determines if the specified resource is a * NetworkList object. * * @param[in] resource A PP_Resource resource. * * @return Returns PP_TRUE if resource is * a PPB_NetworkList, PP_FALSE * otherwise. */ PP_Bool (*IsNetworkList)(PP_Resource resource); /** * Gets number of interfaces in the list. * * @param[in] resource A PP_Resource corresponding to a * network list. * * @return Returns number of available network interfaces or 0 if * the list has never been updated. */ uint32_t (*GetCount)(PP_Resource resource); /** * Gets name of a network interface. * * @param[in] resource A PP_Resource corresponding to a * network list. * @param[in] index Index of the network interface. * * @return Returns name for the network interface with the specified * index. */ struct PP_Var (*GetName)(PP_Resource resource, uint32_t index); /** * Gets type of a network interface. * * @param[in] resource A PP_Resource corresponding to a * network list. * @param[in] index Index of the network interface. * * @return Returns type of the network interface with the specified * index. */ PP_NetworkList_Type (*GetType)(PP_Resource resource, uint32_t index); /** * Gets state of a network interface. * * @param[in] resource A PP_Resource corresponding to a * network list. * @param[in] index Index of the network interface. * * @return Returns current state of the network interface with the * specified index. */ PP_NetworkList_State (*GetState)(PP_Resource resource, uint32_t index); /** * Gets list of IP addresses for a network interface. * * @param[in] resource A PP_Resource corresponding to a * network list. * @param[in] index Index of the network interface. * @param[in] output An output array which will receive * PPB_NetAddress resources on success. Please note that the * ref count of those resources has already been increased by 1 for the * caller. * * @return An error code from pp_errors.h. */ int32_t (*GetIpAddresses)(PP_Resource resource, uint32_t index, struct PP_ArrayOutput output); /** * Gets display name of a network interface. * * @param[in] resource A PP_Resource corresponding to a * network list. * @param[in] index Index of the network interface. * * @return Returns display name for the network interface with the * specified index. */ struct PP_Var (*GetDisplayName)(PP_Resource resource, uint32_t index); /** * Gets MTU (Maximum Transmission Unit) of a network interface. * * @param[in] resource A PP_Resource corresponding to a * network list. * @param[in] index Index of the network interface. * * @return Returns MTU for the network interface with the specified * index or 0 if MTU is unknown. */ uint32_t (*GetMTU)(PP_Resource resource, uint32_t index); }; typedef struct PPB_NetworkList_1_0 PPB_NetworkList; /** * @} */ #endif /* PPAPI_C_PPB_NETWORK_LIST_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_network_monitor.h000066400000000000000000000057601321746453100246610ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_network_monitor.idl modified Thu Sep 19 16:42:34 2013. */ #ifndef PPAPI_C_PPB_NETWORK_MONITOR_H_ #define PPAPI_C_PPB_NETWORK_MONITOR_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_NETWORKMONITOR_INTERFACE_1_0 "PPB_NetworkMonitor;1.0" #define PPB_NETWORKMONITOR_INTERFACE PPB_NETWORKMONITOR_INTERFACE_1_0 /** * @file * This file defines the PPB_NetworkMonitor interface. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_NetworkMonitor allows to get network interfaces * configuration and monitor network configuration changes. * * Permissions: Apps permission socket with subrule * network-state is required for UpdateNetworkList(). * For more details about network communication permissions, please see: * http://developer.chrome.com/apps/app_network.html */ struct PPB_NetworkMonitor_1_0 { /** * Creates a Network Monitor resource. * * @param[in] instance A PP_Instance identifying one instance of * a module. * * @return A PP_Resource corresponding to a network monitor or 0 * on failure. */ PP_Resource (*Create)(PP_Instance instance); /** * Gets current network configuration. When called for the first time, * completes as soon as the current network configuration is received from * the browser. Each consequent call will wait for network list changes, * returning a new PPB_NetworkList resource every time. * * @param[in] network_monitor A PP_Resource corresponding to a * network monitor. * @param[out] network_list The PPB_NetworkList resource with the * current state of network interfaces. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h. * PP_ERROR_NOACCESS will be returned if the caller doesn't have * required permissions. */ int32_t (*UpdateNetworkList)(PP_Resource network_monitor, PP_Resource* network_list, struct PP_CompletionCallback callback); /** * Determines if the specified resource is a * NetworkMonitor object. * * @param[in] resource A PP_Resource resource. * * @return Returns PP_TRUE if resource is a * PPB_NetworkMonitor, PP_FALSE otherwise. */ PP_Bool (*IsNetworkMonitor)(PP_Resource resource); }; typedef struct PPB_NetworkMonitor_1_0 PPB_NetworkMonitor; /** * @} */ #endif /* PPAPI_C_PPB_NETWORK_MONITOR_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_network_proxy.h000066400000000000000000000046761321746453100243600ustar00rootroot00000000000000/* Copyright 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_network_proxy.idl modified Fri Jun 21 09:37:20 2013. */ #ifndef PPAPI_C_PPB_NETWORK_PROXY_H_ #define PPAPI_C_PPB_NETWORK_PROXY_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_NETWORKPROXY_INTERFACE_1_0 "PPB_NetworkProxy;1.0" #define PPB_NETWORKPROXY_INTERFACE PPB_NETWORKPROXY_INTERFACE_1_0 /** * @file * This file defines the PPB_NetworkProxy interface. */ /** * @addtogroup Interfaces * @{ */ /** * This interface provides a way to determine the appropriate proxy settings * for a given URL. * * Permissions: Apps permission socket with subrule * resolve-proxy is required for using this API. * For more details about network communication permissions, please see: * http://developer.chrome.com/apps/app_network.html */ struct PPB_NetworkProxy_1_0 { /** * Retrieves the proxy that will be used for the given URL. The result will * be a string in PAC format. For more details about PAC format, please see * http://en.wikipedia.org/wiki/Proxy_auto-config * * @param[in] instance A PP_Instance identifying one instance * of a module. * * @param[in] url A string PP_Var containing a URL. * * @param[out] proxy_string A PP_Var that GetProxyForURL will * set upon successful completion. If the call fails, proxy_string * will be unchanged. Otherwise, it will be set to a string * PP_Var containing the appropriate PAC string for url. * If set, proxy_string will have a reference count of 1 which * the plugin must manage. * * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*GetProxyForURL)(PP_Instance instance, struct PP_Var url, struct PP_Var* proxy_string, struct PP_CompletionCallback callback); }; typedef struct PPB_NetworkProxy_1_0 PPB_NetworkProxy; /** * @} */ #endif /* PPAPI_C_PPB_NETWORK_PROXY_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_opengles2.h000066400000000000000000001463071321746453100233220ustar00rootroot00000000000000/* Copyright 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_opengles2.idl modified Fri Sep 5 14:52:51 2014. */ #ifndef PPAPI_C_PPB_OPENGLES2_H_ #define PPAPI_C_PPB_OPENGLES2_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_OPENGLES2_INTERFACE_1_0 "PPB_OpenGLES2;1.0" #define PPB_OPENGLES2_INTERFACE PPB_OPENGLES2_INTERFACE_1_0 #define PPB_OPENGLES2_INSTANCEDARRAYS_INTERFACE_1_0 \ "PPB_OpenGLES2InstancedArrays;1.0" #define PPB_OPENGLES2_INSTANCEDARRAYS_INTERFACE \ PPB_OPENGLES2_INSTANCEDARRAYS_INTERFACE_1_0 #define PPB_OPENGLES2_FRAMEBUFFERBLIT_INTERFACE_1_0 \ "PPB_OpenGLES2FramebufferBlit;1.0" #define PPB_OPENGLES2_FRAMEBUFFERBLIT_INTERFACE \ PPB_OPENGLES2_FRAMEBUFFERBLIT_INTERFACE_1_0 #define PPB_OPENGLES2_FRAMEBUFFERMULTISAMPLE_INTERFACE_1_0 \ "PPB_OpenGLES2FramebufferMultisample;1.0" #define PPB_OPENGLES2_FRAMEBUFFERMULTISAMPLE_INTERFACE \ PPB_OPENGLES2_FRAMEBUFFERMULTISAMPLE_INTERFACE_1_0 #define PPB_OPENGLES2_CHROMIUMENABLEFEATURE_INTERFACE_1_0 \ "PPB_OpenGLES2ChromiumEnableFeature;1.0" #define PPB_OPENGLES2_CHROMIUMENABLEFEATURE_INTERFACE \ PPB_OPENGLES2_CHROMIUMENABLEFEATURE_INTERFACE_1_0 #define PPB_OPENGLES2_CHROMIUMMAPSUB_INTERFACE_1_0 \ "PPB_OpenGLES2ChromiumMapSub;1.0" #define PPB_OPENGLES2_CHROMIUMMAPSUB_INTERFACE \ PPB_OPENGLES2_CHROMIUMMAPSUB_INTERFACE_1_0 #define PPB_OPENGLES2_QUERY_INTERFACE_1_0 "PPB_OpenGLES2Query;1.0" #define PPB_OPENGLES2_QUERY_INTERFACE PPB_OPENGLES2_QUERY_INTERFACE_1_0 #define PPB_OPENGLES2_VERTEXARRAYOBJECT_INTERFACE_1_0 \ "PPB_OpenGLES2VertexArrayObject;1.0" #define PPB_OPENGLES2_VERTEXARRAYOBJECT_INTERFACE \ PPB_OPENGLES2_VERTEXARRAYOBJECT_INTERFACE_1_0 /** * @file * This file is auto-generated from * gpu/command_buffer/build_gles2_cmd_buffer.py * It's formatted by clang-format using chromium coding style: * clang-format -i -style=chromium filename * DO NOT EDIT! */ #include "ppapi/c/pp_resource.h" #ifndef __gl2_h_ typedef void GLvoid; typedef int GLsizei; typedef unsigned short GLushort; typedef short GLshort; typedef unsigned char GLubyte; typedef unsigned int GLenum; typedef int GLint; typedef unsigned char GLboolean; typedef unsigned int GLbitfield; typedef float GLfloat; typedef float GLclampf; typedef signed char GLbyte; typedef unsigned int GLuint; typedef int GLfixed; typedef int GLclampx; #ifdef _WIN64 typedef long long int GLintptr; typedef long long int GLsizeiptr; #else typedef long int GLintptr; typedef long int GLsizeiptr; #endif // _WIN64 #endif // __gl2_h_ /** * @addtogroup Interfaces * @{ */ struct PPB_OpenGLES2_1_0 { void (*ActiveTexture)(PP_Resource context, GLenum texture); void (*AttachShader)(PP_Resource context, GLuint program, GLuint shader); void (*BindAttribLocation)(PP_Resource context, GLuint program, GLuint index, const char* name); void (*BindBuffer)(PP_Resource context, GLenum target, GLuint buffer); void (*BindFramebuffer)(PP_Resource context, GLenum target, GLuint framebuffer); void (*BindRenderbuffer)(PP_Resource context, GLenum target, GLuint renderbuffer); void (*BindTexture)(PP_Resource context, GLenum target, GLuint texture); void (*BlendColor)(PP_Resource context, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); void (*BlendEquation)(PP_Resource context, GLenum mode); void (*BlendEquationSeparate)(PP_Resource context, GLenum modeRGB, GLenum modeAlpha); void (*BlendFunc)(PP_Resource context, GLenum sfactor, GLenum dfactor); void (*BlendFuncSeparate)(PP_Resource context, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); void (*BufferData)(PP_Resource context, GLenum target, GLsizeiptr size, const void* data, GLenum usage); void (*BufferSubData)(PP_Resource context, GLenum target, GLintptr offset, GLsizeiptr size, const void* data); GLenum (*CheckFramebufferStatus)(PP_Resource context, GLenum target); void (*Clear)(PP_Resource context, GLbitfield mask); void (*ClearColor)(PP_Resource context, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); void (*ClearDepthf)(PP_Resource context, GLclampf depth); void (*ClearStencil)(PP_Resource context, GLint s); void (*ColorMask)(PP_Resource context, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); void (*CompileShader)(PP_Resource context, GLuint shader); void (*CompressedTexImage2D)(PP_Resource context, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); void (*CompressedTexSubImage2D)(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); void (*CopyTexImage2D)(PP_Resource context, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); void (*CopyTexSubImage2D)(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); GLuint (*CreateProgram)(PP_Resource context); GLuint (*CreateShader)(PP_Resource context, GLenum type); void (*CullFace)(PP_Resource context, GLenum mode); void (*DeleteBuffers)(PP_Resource context, GLsizei n, const GLuint* buffers); void (*DeleteFramebuffers)(PP_Resource context, GLsizei n, const GLuint* framebuffers); void (*DeleteProgram)(PP_Resource context, GLuint program); void (*DeleteRenderbuffers)(PP_Resource context, GLsizei n, const GLuint* renderbuffers); void (*DeleteShader)(PP_Resource context, GLuint shader); void (*DeleteTextures)(PP_Resource context, GLsizei n, const GLuint* textures); void (*DepthFunc)(PP_Resource context, GLenum func); void (*DepthMask)(PP_Resource context, GLboolean flag); void (*DepthRangef)(PP_Resource context, GLclampf zNear, GLclampf zFar); void (*DetachShader)(PP_Resource context, GLuint program, GLuint shader); void (*Disable)(PP_Resource context, GLenum cap); void (*DisableVertexAttribArray)(PP_Resource context, GLuint index); void (*DrawArrays)(PP_Resource context, GLenum mode, GLint first, GLsizei count); void (*DrawElements)(PP_Resource context, GLenum mode, GLsizei count, GLenum type, const void* indices); void (*Enable)(PP_Resource context, GLenum cap); void (*EnableVertexAttribArray)(PP_Resource context, GLuint index); void (*Finish)(PP_Resource context); void (*Flush)(PP_Resource context); void (*FramebufferRenderbuffer)(PP_Resource context, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); void (*FramebufferTexture2D)(PP_Resource context, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); void (*FrontFace)(PP_Resource context, GLenum mode); void (*GenBuffers)(PP_Resource context, GLsizei n, GLuint* buffers); void (*GenerateMipmap)(PP_Resource context, GLenum target); void (*GenFramebuffers)(PP_Resource context, GLsizei n, GLuint* framebuffers); void (*GenRenderbuffers)(PP_Resource context, GLsizei n, GLuint* renderbuffers); void (*GenTextures)(PP_Resource context, GLsizei n, GLuint* textures); void (*GetActiveAttrib)(PP_Resource context, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); void (*GetActiveUniform)(PP_Resource context, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); void (*GetAttachedShaders)(PP_Resource context, GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); GLint (*GetAttribLocation)(PP_Resource context, GLuint program, const char* name); void (*GetBooleanv)(PP_Resource context, GLenum pname, GLboolean* params); void (*GetBufferParameteriv)(PP_Resource context, GLenum target, GLenum pname, GLint* params); GLenum (*GetError)(PP_Resource context); void (*GetFloatv)(PP_Resource context, GLenum pname, GLfloat* params); void (*GetFramebufferAttachmentParameteriv)(PP_Resource context, GLenum target, GLenum attachment, GLenum pname, GLint* params); void (*GetIntegerv)(PP_Resource context, GLenum pname, GLint* params); void (*GetProgramiv)(PP_Resource context, GLuint program, GLenum pname, GLint* params); void (*GetProgramInfoLog)(PP_Resource context, GLuint program, GLsizei bufsize, GLsizei* length, char* infolog); void (*GetRenderbufferParameteriv)(PP_Resource context, GLenum target, GLenum pname, GLint* params); void (*GetShaderiv)(PP_Resource context, GLuint shader, GLenum pname, GLint* params); void (*GetShaderInfoLog)(PP_Resource context, GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog); void (*GetShaderPrecisionFormat)(PP_Resource context, GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); void (*GetShaderSource)(PP_Resource context, GLuint shader, GLsizei bufsize, GLsizei* length, char* source); const GLubyte* (*GetString)(PP_Resource context, GLenum name); void (*GetTexParameterfv)(PP_Resource context, GLenum target, GLenum pname, GLfloat* params); void (*GetTexParameteriv)(PP_Resource context, GLenum target, GLenum pname, GLint* params); void (*GetUniformfv)(PP_Resource context, GLuint program, GLint location, GLfloat* params); void (*GetUniformiv)(PP_Resource context, GLuint program, GLint location, GLint* params); GLint (*GetUniformLocation)(PP_Resource context, GLuint program, const char* name); void (*GetVertexAttribfv)(PP_Resource context, GLuint index, GLenum pname, GLfloat* params); void (*GetVertexAttribiv)(PP_Resource context, GLuint index, GLenum pname, GLint* params); void (*GetVertexAttribPointerv)(PP_Resource context, GLuint index, GLenum pname, void** pointer); void (*Hint)(PP_Resource context, GLenum target, GLenum mode); GLboolean (*IsBuffer)(PP_Resource context, GLuint buffer); GLboolean (*IsEnabled)(PP_Resource context, GLenum cap); GLboolean (*IsFramebuffer)(PP_Resource context, GLuint framebuffer); GLboolean (*IsProgram)(PP_Resource context, GLuint program); GLboolean (*IsRenderbuffer)(PP_Resource context, GLuint renderbuffer); GLboolean (*IsShader)(PP_Resource context, GLuint shader); GLboolean (*IsTexture)(PP_Resource context, GLuint texture); void (*LineWidth)(PP_Resource context, GLfloat width); void (*LinkProgram)(PP_Resource context, GLuint program); void (*PixelStorei)(PP_Resource context, GLenum pname, GLint param); void (*PolygonOffset)(PP_Resource context, GLfloat factor, GLfloat units); void (*ReadPixels)(PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels); void (*ReleaseShaderCompiler)(PP_Resource context); void (*RenderbufferStorage)(PP_Resource context, GLenum target, GLenum internalformat, GLsizei width, GLsizei height); void (*SampleCoverage)(PP_Resource context, GLclampf value, GLboolean invert); void (*Scissor)(PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height); void (*ShaderBinary)(PP_Resource context, GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length); void (*ShaderSource)(PP_Resource context, GLuint shader, GLsizei count, const char** str, const GLint* length); void (*StencilFunc)(PP_Resource context, GLenum func, GLint ref, GLuint mask); void (*StencilFuncSeparate)(PP_Resource context, GLenum face, GLenum func, GLint ref, GLuint mask); void (*StencilMask)(PP_Resource context, GLuint mask); void (*StencilMaskSeparate)(PP_Resource context, GLenum face, GLuint mask); void (*StencilOp)(PP_Resource context, GLenum fail, GLenum zfail, GLenum zpass); void (*StencilOpSeparate)(PP_Resource context, GLenum face, GLenum fail, GLenum zfail, GLenum zpass); void (*TexImage2D)(PP_Resource context, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels); void (*TexParameterf)(PP_Resource context, GLenum target, GLenum pname, GLfloat param); void (*TexParameterfv)(PP_Resource context, GLenum target, GLenum pname, const GLfloat* params); void (*TexParameteri)(PP_Resource context, GLenum target, GLenum pname, GLint param); void (*TexParameteriv)(PP_Resource context, GLenum target, GLenum pname, const GLint* params); void (*TexSubImage2D)(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels); void (*Uniform1f)(PP_Resource context, GLint location, GLfloat x); void (*Uniform1fv)(PP_Resource context, GLint location, GLsizei count, const GLfloat* v); void (*Uniform1i)(PP_Resource context, GLint location, GLint x); void (*Uniform1iv)(PP_Resource context, GLint location, GLsizei count, const GLint* v); void (*Uniform2f)(PP_Resource context, GLint location, GLfloat x, GLfloat y); void (*Uniform2fv)(PP_Resource context, GLint location, GLsizei count, const GLfloat* v); void (*Uniform2i)(PP_Resource context, GLint location, GLint x, GLint y); void (*Uniform2iv)(PP_Resource context, GLint location, GLsizei count, const GLint* v); void (*Uniform3f)(PP_Resource context, GLint location, GLfloat x, GLfloat y, GLfloat z); void (*Uniform3fv)(PP_Resource context, GLint location, GLsizei count, const GLfloat* v); void (*Uniform3i)(PP_Resource context, GLint location, GLint x, GLint y, GLint z); void (*Uniform3iv)(PP_Resource context, GLint location, GLsizei count, const GLint* v); void (*Uniform4f)(PP_Resource context, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); void (*Uniform4fv)(PP_Resource context, GLint location, GLsizei count, const GLfloat* v); void (*Uniform4i)(PP_Resource context, GLint location, GLint x, GLint y, GLint z, GLint w); void (*Uniform4iv)(PP_Resource context, GLint location, GLsizei count, const GLint* v); void (*UniformMatrix2fv)(PP_Resource context, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); void (*UniformMatrix3fv)(PP_Resource context, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); void (*UniformMatrix4fv)(PP_Resource context, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); void (*UseProgram)(PP_Resource context, GLuint program); void (*ValidateProgram)(PP_Resource context, GLuint program); void (*VertexAttrib1f)(PP_Resource context, GLuint indx, GLfloat x); void (*VertexAttrib1fv)(PP_Resource context, GLuint indx, const GLfloat* values); void (*VertexAttrib2f)(PP_Resource context, GLuint indx, GLfloat x, GLfloat y); void (*VertexAttrib2fv)(PP_Resource context, GLuint indx, const GLfloat* values); void (*VertexAttrib3f)(PP_Resource context, GLuint indx, GLfloat x, GLfloat y, GLfloat z); void (*VertexAttrib3fv)(PP_Resource context, GLuint indx, const GLfloat* values); void (*VertexAttrib4f)(PP_Resource context, GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); void (*VertexAttrib4fv)(PP_Resource context, GLuint indx, const GLfloat* values); void (*VertexAttribPointer)(PP_Resource context, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr); void (*Viewport)(PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height); }; struct PPB_OpenGLES2 { void (*ActiveTexture)(PP_Resource context, GLenum texture); void (*AttachShader)(PP_Resource context, GLuint program, GLuint shader); void (*BindAttribLocation)(PP_Resource context, GLuint program, GLuint index, const char* name); void (*BindBuffer)(PP_Resource context, GLenum target, GLuint buffer); void (*BindFramebuffer)(PP_Resource context, GLenum target, GLuint framebuffer); void (*BindRenderbuffer)(PP_Resource context, GLenum target, GLuint renderbuffer); void (*BindTexture)(PP_Resource context, GLenum target, GLuint texture); void (*BlendColor)(PP_Resource context, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); void (*BlendEquation)(PP_Resource context, GLenum mode); void (*BlendEquationSeparate)(PP_Resource context, GLenum modeRGB, GLenum modeAlpha); void (*BlendFunc)(PP_Resource context, GLenum sfactor, GLenum dfactor); void (*BlendFuncSeparate)(PP_Resource context, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); void (*BufferData)(PP_Resource context, GLenum target, GLsizeiptr size, const void* data, GLenum usage); void (*BufferSubData)(PP_Resource context, GLenum target, GLintptr offset, GLsizeiptr size, const void* data); GLenum (*CheckFramebufferStatus)(PP_Resource context, GLenum target); void (*Clear)(PP_Resource context, GLbitfield mask); void (*ClearColor)(PP_Resource context, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); void (*ClearDepthf)(PP_Resource context, GLclampf depth); void (*ClearStencil)(PP_Resource context, GLint s); void (*ColorMask)(PP_Resource context, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); void (*CompileShader)(PP_Resource context, GLuint shader); void (*CompressedTexImage2D)(PP_Resource context, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); void (*CompressedTexSubImage2D)(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); void (*CopyTexImage2D)(PP_Resource context, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); void (*CopyTexSubImage2D)(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); GLuint (*CreateProgram)(PP_Resource context); GLuint (*CreateShader)(PP_Resource context, GLenum type); void (*CullFace)(PP_Resource context, GLenum mode); void (*DeleteBuffers)(PP_Resource context, GLsizei n, const GLuint* buffers); void (*DeleteFramebuffers)(PP_Resource context, GLsizei n, const GLuint* framebuffers); void (*DeleteProgram)(PP_Resource context, GLuint program); void (*DeleteRenderbuffers)(PP_Resource context, GLsizei n, const GLuint* renderbuffers); void (*DeleteShader)(PP_Resource context, GLuint shader); void (*DeleteTextures)(PP_Resource context, GLsizei n, const GLuint* textures); void (*DepthFunc)(PP_Resource context, GLenum func); void (*DepthMask)(PP_Resource context, GLboolean flag); void (*DepthRangef)(PP_Resource context, GLclampf zNear, GLclampf zFar); void (*DetachShader)(PP_Resource context, GLuint program, GLuint shader); void (*Disable)(PP_Resource context, GLenum cap); void (*DisableVertexAttribArray)(PP_Resource context, GLuint index); void (*DrawArrays)(PP_Resource context, GLenum mode, GLint first, GLsizei count); void (*DrawElements)(PP_Resource context, GLenum mode, GLsizei count, GLenum type, const void* indices); void (*Enable)(PP_Resource context, GLenum cap); void (*EnableVertexAttribArray)(PP_Resource context, GLuint index); void (*Finish)(PP_Resource context); void (*Flush)(PP_Resource context); void (*FramebufferRenderbuffer)(PP_Resource context, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); void (*FramebufferTexture2D)(PP_Resource context, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); void (*FrontFace)(PP_Resource context, GLenum mode); void (*GenBuffers)(PP_Resource context, GLsizei n, GLuint* buffers); void (*GenerateMipmap)(PP_Resource context, GLenum target); void (*GenFramebuffers)(PP_Resource context, GLsizei n, GLuint* framebuffers); void (*GenRenderbuffers)(PP_Resource context, GLsizei n, GLuint* renderbuffers); void (*GenTextures)(PP_Resource context, GLsizei n, GLuint* textures); void (*GetActiveAttrib)(PP_Resource context, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); void (*GetActiveUniform)(PP_Resource context, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); void (*GetAttachedShaders)(PP_Resource context, GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); GLint (*GetAttribLocation)(PP_Resource context, GLuint program, const char* name); void (*GetBooleanv)(PP_Resource context, GLenum pname, GLboolean* params); void (*GetBufferParameteriv)(PP_Resource context, GLenum target, GLenum pname, GLint* params); GLenum (*GetError)(PP_Resource context); void (*GetFloatv)(PP_Resource context, GLenum pname, GLfloat* params); void (*GetFramebufferAttachmentParameteriv)(PP_Resource context, GLenum target, GLenum attachment, GLenum pname, GLint* params); void (*GetIntegerv)(PP_Resource context, GLenum pname, GLint* params); void (*GetProgramiv)(PP_Resource context, GLuint program, GLenum pname, GLint* params); void (*GetProgramInfoLog)(PP_Resource context, GLuint program, GLsizei bufsize, GLsizei* length, char* infolog); void (*GetRenderbufferParameteriv)(PP_Resource context, GLenum target, GLenum pname, GLint* params); void (*GetShaderiv)(PP_Resource context, GLuint shader, GLenum pname, GLint* params); void (*GetShaderInfoLog)(PP_Resource context, GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog); void (*GetShaderPrecisionFormat)(PP_Resource context, GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); void (*GetShaderSource)(PP_Resource context, GLuint shader, GLsizei bufsize, GLsizei* length, char* source); const GLubyte* (*GetString)(PP_Resource context, GLenum name); void (*GetTexParameterfv)(PP_Resource context, GLenum target, GLenum pname, GLfloat* params); void (*GetTexParameteriv)(PP_Resource context, GLenum target, GLenum pname, GLint* params); void (*GetUniformfv)(PP_Resource context, GLuint program, GLint location, GLfloat* params); void (*GetUniformiv)(PP_Resource context, GLuint program, GLint location, GLint* params); GLint (*GetUniformLocation)(PP_Resource context, GLuint program, const char* name); void (*GetVertexAttribfv)(PP_Resource context, GLuint index, GLenum pname, GLfloat* params); void (*GetVertexAttribiv)(PP_Resource context, GLuint index, GLenum pname, GLint* params); void (*GetVertexAttribPointerv)(PP_Resource context, GLuint index, GLenum pname, void** pointer); void (*Hint)(PP_Resource context, GLenum target, GLenum mode); GLboolean (*IsBuffer)(PP_Resource context, GLuint buffer); GLboolean (*IsEnabled)(PP_Resource context, GLenum cap); GLboolean (*IsFramebuffer)(PP_Resource context, GLuint framebuffer); GLboolean (*IsProgram)(PP_Resource context, GLuint program); GLboolean (*IsRenderbuffer)(PP_Resource context, GLuint renderbuffer); GLboolean (*IsShader)(PP_Resource context, GLuint shader); GLboolean (*IsTexture)(PP_Resource context, GLuint texture); void (*LineWidth)(PP_Resource context, GLfloat width); void (*LinkProgram)(PP_Resource context, GLuint program); void (*PixelStorei)(PP_Resource context, GLenum pname, GLint param); void (*PolygonOffset)(PP_Resource context, GLfloat factor, GLfloat units); void (*ReadPixels)(PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels); void (*ReleaseShaderCompiler)(PP_Resource context); void (*RenderbufferStorage)(PP_Resource context, GLenum target, GLenum internalformat, GLsizei width, GLsizei height); void (*SampleCoverage)(PP_Resource context, GLclampf value, GLboolean invert); void (*Scissor)(PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height); void (*ShaderBinary)(PP_Resource context, GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length); void (*ShaderSource)(PP_Resource context, GLuint shader, GLsizei count, const char** str, const GLint* length); void (*StencilFunc)(PP_Resource context, GLenum func, GLint ref, GLuint mask); void (*StencilFuncSeparate)(PP_Resource context, GLenum face, GLenum func, GLint ref, GLuint mask); void (*StencilMask)(PP_Resource context, GLuint mask); void (*StencilMaskSeparate)(PP_Resource context, GLenum face, GLuint mask); void (*StencilOp)(PP_Resource context, GLenum fail, GLenum zfail, GLenum zpass); void (*StencilOpSeparate)(PP_Resource context, GLenum face, GLenum fail, GLenum zfail, GLenum zpass); void (*TexImage2D)(PP_Resource context, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels); void (*TexParameterf)(PP_Resource context, GLenum target, GLenum pname, GLfloat param); void (*TexParameterfv)(PP_Resource context, GLenum target, GLenum pname, const GLfloat* params); void (*TexParameteri)(PP_Resource context, GLenum target, GLenum pname, GLint param); void (*TexParameteriv)(PP_Resource context, GLenum target, GLenum pname, const GLint* params); void (*TexSubImage2D)(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels); void (*Uniform1f)(PP_Resource context, GLint location, GLfloat x); void (*Uniform1fv)(PP_Resource context, GLint location, GLsizei count, const GLfloat* v); void (*Uniform1i)(PP_Resource context, GLint location, GLint x); void (*Uniform1iv)(PP_Resource context, GLint location, GLsizei count, const GLint* v); void (*Uniform2f)(PP_Resource context, GLint location, GLfloat x, GLfloat y); void (*Uniform2fv)(PP_Resource context, GLint location, GLsizei count, const GLfloat* v); void (*Uniform2i)(PP_Resource context, GLint location, GLint x, GLint y); void (*Uniform2iv)(PP_Resource context, GLint location, GLsizei count, const GLint* v); void (*Uniform3f)(PP_Resource context, GLint location, GLfloat x, GLfloat y, GLfloat z); void (*Uniform3fv)(PP_Resource context, GLint location, GLsizei count, const GLfloat* v); void (*Uniform3i)(PP_Resource context, GLint location, GLint x, GLint y, GLint z); void (*Uniform3iv)(PP_Resource context, GLint location, GLsizei count, const GLint* v); void (*Uniform4f)(PP_Resource context, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); void (*Uniform4fv)(PP_Resource context, GLint location, GLsizei count, const GLfloat* v); void (*Uniform4i)(PP_Resource context, GLint location, GLint x, GLint y, GLint z, GLint w); void (*Uniform4iv)(PP_Resource context, GLint location, GLsizei count, const GLint* v); void (*UniformMatrix2fv)(PP_Resource context, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); void (*UniformMatrix3fv)(PP_Resource context, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); void (*UniformMatrix4fv)(PP_Resource context, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); void (*UseProgram)(PP_Resource context, GLuint program); void (*ValidateProgram)(PP_Resource context, GLuint program); void (*VertexAttrib1f)(PP_Resource context, GLuint indx, GLfloat x); void (*VertexAttrib1fv)(PP_Resource context, GLuint indx, const GLfloat* values); void (*VertexAttrib2f)(PP_Resource context, GLuint indx, GLfloat x, GLfloat y); void (*VertexAttrib2fv)(PP_Resource context, GLuint indx, const GLfloat* values); void (*VertexAttrib3f)(PP_Resource context, GLuint indx, GLfloat x, GLfloat y, GLfloat z); void (*VertexAttrib3fv)(PP_Resource context, GLuint indx, const GLfloat* values); void (*VertexAttrib4f)(PP_Resource context, GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); void (*VertexAttrib4fv)(PP_Resource context, GLuint indx, const GLfloat* values); void (*VertexAttribPointer)(PP_Resource context, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr); void (*Viewport)(PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height); }; struct PPB_OpenGLES2InstancedArrays_1_0 { void (*DrawArraysInstancedANGLE)(PP_Resource context, GLenum mode, GLint first, GLsizei count, GLsizei primcount); void (*DrawElementsInstancedANGLE)(PP_Resource context, GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount); void (*VertexAttribDivisorANGLE)(PP_Resource context, GLuint index, GLuint divisor); }; struct PPB_OpenGLES2InstancedArrays { void (*DrawArraysInstancedANGLE)(PP_Resource context, GLenum mode, GLint first, GLsizei count, GLsizei primcount); void (*DrawElementsInstancedANGLE)(PP_Resource context, GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount); void (*VertexAttribDivisorANGLE)(PP_Resource context, GLuint index, GLuint divisor); }; struct PPB_OpenGLES2FramebufferBlit_1_0 { void (*BlitFramebufferEXT)(PP_Resource context, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); }; struct PPB_OpenGLES2FramebufferBlit { void (*BlitFramebufferEXT)(PP_Resource context, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); }; struct PPB_OpenGLES2FramebufferMultisample_1_0 { void (*RenderbufferStorageMultisampleEXT)(PP_Resource context, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); }; struct PPB_OpenGLES2FramebufferMultisample { void (*RenderbufferStorageMultisampleEXT)(PP_Resource context, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); }; struct PPB_OpenGLES2ChromiumEnableFeature_1_0 { GLboolean (*EnableFeatureCHROMIUM)(PP_Resource context, const char* feature); }; struct PPB_OpenGLES2ChromiumEnableFeature { GLboolean (*EnableFeatureCHROMIUM)(PP_Resource context, const char* feature); }; struct PPB_OpenGLES2ChromiumMapSub_1_0 { void* (*MapBufferSubDataCHROMIUM)(PP_Resource context, GLuint target, GLintptr offset, GLsizeiptr size, GLenum access); void (*UnmapBufferSubDataCHROMIUM)(PP_Resource context, const void* mem); void* (*MapTexSubImage2DCHROMIUM)(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLenum access); void (*UnmapTexSubImage2DCHROMIUM)(PP_Resource context, const void* mem); }; struct PPB_OpenGLES2ChromiumMapSub { void* (*MapBufferSubDataCHROMIUM)(PP_Resource context, GLuint target, GLintptr offset, GLsizeiptr size, GLenum access); void (*UnmapBufferSubDataCHROMIUM)(PP_Resource context, const void* mem); void* (*MapTexSubImage2DCHROMIUM)(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLenum access); void (*UnmapTexSubImage2DCHROMIUM)(PP_Resource context, const void* mem); }; struct PPB_OpenGLES2Query_1_0 { void (*GenQueriesEXT)(PP_Resource context, GLsizei n, GLuint* queries); void (*DeleteQueriesEXT)(PP_Resource context, GLsizei n, const GLuint* queries); GLboolean (*IsQueryEXT)(PP_Resource context, GLuint id); void (*BeginQueryEXT)(PP_Resource context, GLenum target, GLuint id); void (*EndQueryEXT)(PP_Resource context, GLenum target); void (*GetQueryivEXT)(PP_Resource context, GLenum target, GLenum pname, GLint* params); void (*GetQueryObjectuivEXT)(PP_Resource context, GLuint id, GLenum pname, GLuint* params); }; struct PPB_OpenGLES2Query { void (*GenQueriesEXT)(PP_Resource context, GLsizei n, GLuint* queries); void (*DeleteQueriesEXT)(PP_Resource context, GLsizei n, const GLuint* queries); GLboolean (*IsQueryEXT)(PP_Resource context, GLuint id); void (*BeginQueryEXT)(PP_Resource context, GLenum target, GLuint id); void (*EndQueryEXT)(PP_Resource context, GLenum target); void (*GetQueryivEXT)(PP_Resource context, GLenum target, GLenum pname, GLint* params); void (*GetQueryObjectuivEXT)(PP_Resource context, GLuint id, GLenum pname, GLuint* params); }; struct PPB_OpenGLES2VertexArrayObject_1_0 { void (*GenVertexArraysOES)(PP_Resource context, GLsizei n, GLuint* arrays); void (*DeleteVertexArraysOES)(PP_Resource context, GLsizei n, const GLuint* arrays); GLboolean (*IsVertexArrayOES)(PP_Resource context, GLuint array); void (*BindVertexArrayOES)(PP_Resource context, GLuint array); }; struct PPB_OpenGLES2VertexArrayObject { void (*GenVertexArraysOES)(PP_Resource context, GLsizei n, GLuint* arrays); void (*DeleteVertexArraysOES)(PP_Resource context, GLsizei n, const GLuint* arrays); GLboolean (*IsVertexArrayOES)(PP_Resource context, GLuint array); void (*BindVertexArrayOES)(PP_Resource context, GLuint array); }; /** * @} */ #endif /* PPAPI_C_PPB_OPENGLES2_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_tcp_socket.h000066400000000000000000000323161321746453100235540ustar00rootroot00000000000000/* Copyright 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_tcp_socket.idl modified Mon Dec 8 16:50:44 2014. */ #ifndef PPAPI_C_PPB_TCP_SOCKET_H_ #define PPAPI_C_PPB_TCP_SOCKET_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_TCPSOCKET_INTERFACE_1_0 "PPB_TCPSocket;1.0" #define PPB_TCPSOCKET_INTERFACE_1_1 "PPB_TCPSocket;1.1" #define PPB_TCPSOCKET_INTERFACE_1_2 "PPB_TCPSocket;1.2" #define PPB_TCPSOCKET_INTERFACE PPB_TCPSOCKET_INTERFACE_1_2 /** * @file * This file defines the PPB_TCPSocket interface. */ /** * @addtogroup Enums * @{ */ /** * Option names used by SetOption(). */ typedef enum { /** * Disables coalescing of small writes to make TCP segments, and instead * delivers data immediately. Value's type is PP_VARTYPE_BOOL. * On version 1.1 or earlier, this option can only be set after a successful * Connect() call. On version 1.2 or later, there is no such * limitation. */ PP_TCPSOCKET_OPTION_NO_DELAY = 0, /** * Specifies the total per-socket buffer space reserved for sends. Value's * type should be PP_VARTYPE_INT32. * On version 1.1 or earlier, this option can only be set after a successful * Connect() call. On version 1.2 or later, there is no such * limitation. * * Note: This is only treated as a hint for the browser to set the buffer * size. Even if SetOption() succeeds, the browser doesn't * guarantee it will conform to the size. */ PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE = 1, /** * Specifies the total per-socket buffer space reserved for receives. Value's * type should be PP_VARTYPE_INT32. * On version 1.1 or earlier, this option can only be set after a successful * Connect() call. On version 1.2 or later, there is no such * limitation. * * Note: This is only treated as a hint for the browser to set the buffer * size. Even if SetOption() succeeds, the browser doesn't * guarantee it will conform to the size. */ PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE = 2 } PP_TCPSocket_Option; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TCPSocket_Option, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_TCPSocket interface provides TCP socket operations. * * Permissions: Apps permission socket with subrule * tcp-connect is required for Connect(); subrule * tcp-listen is required for Listen(). * For more details about network communication permissions, please see: * http://developer.chrome.com/apps/app_network.html */ struct PPB_TCPSocket_1_2 { /** * Creates a TCP socket resource. * * @param[in] instance A PP_Instance identifying one instance of * a module. * * @return A PP_Resource corresponding to a TCP socket or 0 * on failure. */ PP_Resource (*Create)(PP_Instance instance); /** * Determines if a given resource is a TCP socket. * * @param[in] resource A PP_Resource to check. * * @return PP_TRUE if the input is a * PPB_TCPSocket resource; PP_FALSE otherwise. */ PP_Bool (*IsTCPSocket)(PP_Resource resource); /** * Binds the socket to the given address. The socket must not be bound. * * @param[in] tcp_socket A PP_Resource corresponding to a TCP * socket. * @param[in] addr A PPB_NetAddress resource. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h, * including (but not limited to): * - PP_ERROR_ADDRESS_IN_USE: the address is already in use. * - PP_ERROR_ADDRESS_INVALID: the address is invalid. */ int32_t (*Bind)(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback callback); /** * Connects the socket to the given address. The socket must not be listening. * Binding the socket beforehand is optional. * * @param[in] tcp_socket A PP_Resource corresponding to a TCP * socket. * @param[in] addr A PPB_NetAddress resource. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h, * including (but not limited to): * - PP_ERROR_NOACCESS: the caller doesn't have required * permissions. * - PP_ERROR_ADDRESS_UNREACHABLE: addr is * unreachable. * - PP_ERROR_CONNECTION_REFUSED: the connection attempt was * refused. * - PP_ERROR_CONNECTION_FAILED: the connection attempt failed. * - PP_ERROR_CONNECTION_TIMEDOUT: the connection attempt timed * out. * * Since version 1.1, if the socket is listening/connected or has a pending * listen/connect request, Connect() will fail without starting a * connection attempt; otherwise, any failure during the connection attempt * will cause the socket to be closed. */ int32_t (*Connect)(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback callback); /** * Gets the local address of the socket, if it is bound. * * @param[in] tcp_socket A PP_Resource corresponding to a TCP * socket. * * @return A PPB_NetAddress resource on success or 0 on failure. */ PP_Resource (*GetLocalAddress)(PP_Resource tcp_socket); /** * Gets the remote address of the socket, if it is connected. * * @param[in] tcp_socket A PP_Resource corresponding to a TCP * socket. * * @return A PPB_NetAddress resource on success or 0 on failure. */ PP_Resource (*GetRemoteAddress)(PP_Resource tcp_socket); /** * Reads data from the socket. The socket must be connected. It may perform a * partial read. * * @param[in] tcp_socket A PP_Resource corresponding to a TCP * socket. * @param[out] buffer The buffer to store the received data on success. It * must be at least as large as bytes_to_read. * @param[in] bytes_to_read The number of bytes to read. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return A non-negative number on success to indicate how many bytes have * been read, 0 means that end-of-file was reached; otherwise, an error code * from pp_errors.h. */ int32_t (*Read)(PP_Resource tcp_socket, char* buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback); /** * Writes data to the socket. The socket must be connected. It may perform a * partial write. * * @param[in] tcp_socket A PP_Resource corresponding to a TCP * socket. * @param[in] buffer The buffer containing the data to write. * @param[in] bytes_to_write The number of bytes to write. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return A non-negative number on success to indicate how many bytes have * been written; otherwise, an error code from pp_errors.h. */ int32_t (*Write)(PP_Resource tcp_socket, const char* buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback); /** * Starts listening. The socket must be bound and not connected. * * @param[in] tcp_socket A PP_Resource corresponding to a TCP * socket. * @param[in] backlog A hint to determine the maximum length to which the * queue of pending connections may grow. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h, * including (but not limited to): * - PP_ERROR_NOACCESS: the caller doesn't have required * permissions. * - PP_ERROR_ADDRESS_IN_USE: Another socket is already listening * on the same port. */ int32_t (*Listen)(PP_Resource tcp_socket, int32_t backlog, struct PP_CompletionCallback callback); /** * Accepts a connection. The socket must be listening. * * @param[in] tcp_socket A PP_Resource corresponding to a TCP * socket. * @param[out] accepted_tcp_socket Stores the accepted TCP socket on success. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h, * including (but not limited to): * - PP_ERROR_CONNECTION_ABORTED: A connection has been aborted. */ int32_t (*Accept)(PP_Resource tcp_socket, PP_Resource* accepted_tcp_socket, struct PP_CompletionCallback callback); /** * Cancels all pending operations and closes the socket. Any pending callbacks * will still run, reporting PP_ERROR_ABORTED if pending IO was * interrupted. After a call to this method, no output buffer pointers passed * into previous Read() or Accept() calls will be * accessed. It is not valid to call Connect() or * Listen() again. * * The socket is implicitly closed if it is destroyed, so you are not required * to call this method. * * @param[in] tcp_socket A PP_Resource corresponding to a TCP * socket. */ void (*Close)(PP_Resource tcp_socket); /** * Sets a socket option on the TCP socket. * Please see the PP_TCPSocket_Option description for option * names, value types and allowed values. * * @param[in] tcp_socket A PP_Resource corresponding to a TCP * socket. * @param[in] name The option to set. * @param[in] value The option value to set. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*SetOption)(PP_Resource tcp_socket, PP_TCPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback); }; typedef struct PPB_TCPSocket_1_2 PPB_TCPSocket; struct PPB_TCPSocket_1_0 { PP_Resource (*Create)(PP_Instance instance); PP_Bool (*IsTCPSocket)(PP_Resource resource); int32_t (*Connect)(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback callback); PP_Resource (*GetLocalAddress)(PP_Resource tcp_socket); PP_Resource (*GetRemoteAddress)(PP_Resource tcp_socket); int32_t (*Read)(PP_Resource tcp_socket, char* buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback); int32_t (*Write)(PP_Resource tcp_socket, const char* buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback); void (*Close)(PP_Resource tcp_socket); int32_t (*SetOption)(PP_Resource tcp_socket, PP_TCPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback); }; struct PPB_TCPSocket_1_1 { PP_Resource (*Create)(PP_Instance instance); PP_Bool (*IsTCPSocket)(PP_Resource resource); int32_t (*Bind)(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback callback); int32_t (*Connect)(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback callback); PP_Resource (*GetLocalAddress)(PP_Resource tcp_socket); PP_Resource (*GetRemoteAddress)(PP_Resource tcp_socket); int32_t (*Read)(PP_Resource tcp_socket, char* buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback); int32_t (*Write)(PP_Resource tcp_socket, const char* buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback); int32_t (*Listen)(PP_Resource tcp_socket, int32_t backlog, struct PP_CompletionCallback callback); int32_t (*Accept)(PP_Resource tcp_socket, PP_Resource* accepted_tcp_socket, struct PP_CompletionCallback callback); void (*Close)(PP_Resource tcp_socket); int32_t (*SetOption)(PP_Resource tcp_socket, PP_TCPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback); }; /** * @} */ #endif /* PPAPI_C_PPB_TCP_SOCKET_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_text_input_controller.h000066400000000000000000000104501321746453100260570ustar00rootroot00000000000000/* Copyright 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_text_input_controller.idl modified Thu Aug 1 09:30:48 2013. */ #ifndef PPAPI_C_PPB_TEXT_INPUT_CONTROLLER_H_ #define PPAPI_C_PPB_TEXT_INPUT_CONTROLLER_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_TEXTINPUTCONTROLLER_INTERFACE_1_0 "PPB_TextInputController;1.0" #define PPB_TEXTINPUTCONTROLLER_INTERFACE PPB_TEXTINPUTCONTROLLER_INTERFACE_1_0 /** * @file * This file defines the PPB_TextInputController interface. */ /** * @addtogroup Enums * @{ */ /** * PP_TextInput_Type is used to indicate the status of a plugin in regard to * text input. */ typedef enum { /** * Input caret is not in an editable mode, no input method shall be used. */ PP_TEXTINPUT_TYPE_NONE = 0, /** * Input caret is in a normal editable mode, any input method can be used. */ PP_TEXTINPUT_TYPE_TEXT = 1, /** * Input caret is in a password box, an input method may be used only if * it's suitable for password input. */ PP_TEXTINPUT_TYPE_PASSWORD = 2, PP_TEXTINPUT_TYPE_SEARCH = 3, PP_TEXTINPUT_TYPE_EMAIL = 4, PP_TEXTINPUT_TYPE_NUMBER = 5, PP_TEXTINPUT_TYPE_TELEPHONE = 6, PP_TEXTINPUT_TYPE_URL = 7 } PP_TextInput_Type; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TextInput_Type, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * PPB_TextInputController provides a set of functions for giving * hints to the browser about the text input status of plugins, and functions * for controlling input method editors (IMEs). */ struct PPB_TextInputController_1_0 { /** * Informs the browser about the current text input mode of the plugin. * Typical use of this information in the browser is to properly * display/suppress tools for supporting text inputs (such as virtual * keyboards in touch screen based devices, or input method editors often * used for composing East Asian characters). */ void (*SetTextInputType)(PP_Instance instance, PP_TextInput_Type type); /** * Informs the browser about the coordinates of the text input caret area. * Typical use of this information in the browser is to layout IME windows * etc. */ void (*UpdateCaretPosition)(PP_Instance instance, const struct PP_Rect* caret); /** * Cancels the current composition in IME. */ void (*CancelCompositionText)(PP_Instance instance); /** * Informs the browser about the current text selection and surrounding * text. text is a UTF-8 string that contains the current range * of text selection in the plugin. caret is the byte-index of * the caret position within text. anchor is the * byte-index of the anchor position (i.e., if a range of text is selected, * it is the other edge of selection different from caret. If * there are no selection, anchor is equal to caret. * * Typical use of this information in the browser is to enable "reconversion" * features of IME that puts back the already committed text into the * pre-commit composition state. Another use is to improve the precision * of suggestion of IME by taking the context into account (e.g., if the caret * looks to be on the beginning of a sentence, suggest capital letters in a * virtual keyboard). * * When the focus is not on text, call this function setting text * to an empty string and caret and anchor to zero. * Also, the plugin should send the empty text when it does not want to reveal * the selection to IME (e.g., when the surrounding text is containing * password text). */ void (*UpdateSurroundingText)(PP_Instance instance, struct PP_Var text, uint32_t caret, uint32_t anchor); }; typedef struct PPB_TextInputController_1_0 PPB_TextInputController; /** * @} */ #endif /* PPAPI_C_PPB_TEXT_INPUT_CONTROLLER_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_udp_socket.h000066400000000000000000000307721321746453100235620ustar00rootroot00000000000000/* Copyright 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_udp_socket.idl modified Tue Mar 17 11:47:56 2015. */ #ifndef PPAPI_C_PPB_UDP_SOCKET_H_ #define PPAPI_C_PPB_UDP_SOCKET_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_UDPSOCKET_INTERFACE_1_0 "PPB_UDPSocket;1.0" #define PPB_UDPSOCKET_INTERFACE_1_1 "PPB_UDPSocket;1.1" #define PPB_UDPSOCKET_INTERFACE_1_2 "PPB_UDPSocket;1.2" #define PPB_UDPSOCKET_INTERFACE PPB_UDPSOCKET_INTERFACE_1_2 /** * @file * This file defines the PPB_UDPSocket interface. */ /** * @addtogroup Enums * @{ */ /** * Option names used by SetOption(). */ typedef enum { /** * Allows the socket to share the local address to which it will be bound with * other processes. Value's type should be PP_VARTYPE_BOOL. * This option can only be set before calling Bind(). */ PP_UDPSOCKET_OPTION_ADDRESS_REUSE = 0, /** * Allows sending and receiving packets to and from broadcast addresses. * Value's type should be PP_VARTYPE_BOOL. * On version 1.0, this option can only be set before calling * Bind(). On version 1.1 or later, there is no such limitation. */ PP_UDPSOCKET_OPTION_BROADCAST = 1, /** * Specifies the total per-socket buffer space reserved for sends. Value's * type should be PP_VARTYPE_INT32. * On version 1.0, this option can only be set after a successful * Bind() call. On version 1.1 or later, there is no such * limitation. * * Note: This is only treated as a hint for the browser to set the buffer * size. Even if SetOption() succeeds, the browser doesn't * guarantee it will conform to the size. */ PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE = 2, /** * Specifies the total per-socket buffer space reserved for receives. Value's * type should be PP_VARTYPE_INT32. * On version 1.0, this option can only be set after a successful * Bind() call. On version 1.1 or later, there is no such * limitation. * * Note: This is only treated as a hint for the browser to set the buffer * size. Even if SetOption() succeeds, the browser doesn't * guarantee it will conform to the size. */ PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3, /** * Specifies whether the packets sent from the host to the multicast group * should be looped back to the host or not. Value's type should be * PP_VARTYPE_BOOL. * This option can only be set before calling Bind(). * * This is only supported in version 1.2 of the API (Chrome 43) and later. */ PP_UDPSOCKET_OPTION_MULTICAST_LOOP = 4, /** * Specifies the time-to-live for packets sent to the multicast group. The * value should be within 0 to 255 range. The default value is 1 and means * that packets will not be routed beyond the local network. Value's type * should be PP_VARTYPE_INT32. * This option can only be set before calling Bind(). * * This is only supported in version 1.2 of the API (Chrome 43) and later. */ PP_UDPSOCKET_OPTION_MULTICAST_TTL = 5 } PP_UDPSocket_Option; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_UDPSocket_Option, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_UDPSocket interface provides UDP socket operations. * * Permissions: Apps permission socket with subrule * udp-bind is required for Bind(); subrule * udp-send-to is required for SendTo(). * For more details about network communication permissions, please see: * http://developer.chrome.com/apps/app_network.html */ struct PPB_UDPSocket_1_2 { /** * Creates a UDP socket resource. * * @param[in] instance A PP_Instance identifying one instance of * a module. * * @return A PP_Resource corresponding to a UDP socket or 0 * on failure. */ PP_Resource (*Create)(PP_Instance instance); /** * Determines if a given resource is a UDP socket. * * @param[in] resource A PP_Resource to check. * * @return PP_TRUE if the input is a PPB_UDPSocket * resource; PP_FALSE otherwise. */ PP_Bool (*IsUDPSocket)(PP_Resource resource); /** * Binds the socket to the given address. * * @param[in] udp_socket A PP_Resource corresponding to a UDP * socket. * @param[in] addr A PPB_NetAddress resource. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h. * PP_ERROR_NOACCESS will be returned if the caller doesn't have * required permissions. PP_ERROR_ADDRESS_IN_USE will be returned * if the address is already in use. */ int32_t (*Bind)(PP_Resource udp_socket, PP_Resource addr, struct PP_CompletionCallback callback); /** * Gets the address that the socket is bound to. The socket must be bound. * * @param[in] udp_socket A PP_Resource corresponding to a UDP * socket. * * @return A PPB_NetAddress resource on success or 0 on failure. */ PP_Resource (*GetBoundAddress)(PP_Resource udp_socket); /** * Receives data from the socket and stores the source address. The socket * must be bound. * * @param[in] udp_socket A PP_Resource corresponding to a UDP * socket. * @param[out] buffer The buffer to store the received data on success. It * must be at least as large as num_bytes. * @param[in] num_bytes The number of bytes to receive. * @param[out] addr A PPB_NetAddress resource to store the source * address on success. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return A non-negative number on success to indicate how many bytes have * been received; otherwise, an error code from pp_errors.h. */ int32_t (*RecvFrom)(PP_Resource udp_socket, char* buffer, int32_t num_bytes, PP_Resource* addr, struct PP_CompletionCallback callback); /** * Sends data to a specific destination. The socket must be bound. * * @param[in] udp_socket A PP_Resource corresponding to a UDP * socket. * @param[in] buffer The buffer containing the data to send. * @param[in] num_bytes The number of bytes to send. * @param[in] addr A PPB_NetAddress resource holding the * destination address. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return A non-negative number on success to indicate how many bytes have * been sent; otherwise, an error code from pp_errors.h. * PP_ERROR_NOACCESS will be returned if the caller doesn't have * required permissions. * PP_ERROR_INPROGRESS will be returned if the socket is busy * sending. The caller should wait until a pending send completes before * retrying. */ int32_t (*SendTo)(PP_Resource udp_socket, const char* buffer, int32_t num_bytes, PP_Resource addr, struct PP_CompletionCallback callback); /** * Cancels all pending reads and writes, and closes the socket. Any pending * callbacks will still run, reporting PP_ERROR_ABORTED if * pending IO was interrupted. After a call to this method, no output * parameters passed into previous RecvFrom() calls will be * accessed. It is not valid to call Bind() again. * * The socket is implicitly closed if it is destroyed, so you are not * required to call this method. * * @param[in] udp_socket A PP_Resource corresponding to a UDP * socket. */ void (*Close)(PP_Resource udp_socket); /** * Sets a socket option on the UDP socket. * Please see the PP_UDPSocket_Option description for option * names, value types and allowed values. * * @param[in] udp_socket A PP_Resource corresponding to a UDP * socket. * @param[in] name The option to set. * @param[in] value The option value to set. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*SetOption)(PP_Resource udp_socket, PP_UDPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback); /** * Joins the multicast group with address specified by group * parameter, which is expected to be a PPB_NetAddress object. * * @param[in] udp_socket A PP_Resource corresponding to a UDP * socket. * @param[in] group A PP_Resource corresponding to the network * address of the multicast group. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*JoinGroup)(PP_Resource udp_socket, PP_Resource group, struct PP_CompletionCallback callback); /** * Leaves the multicast group with address specified by group * parameter, which is expected to be a PPB_NetAddress object. * * @param[in] udp_socket A PP_Resource corresponding to a UDP * socket. * @param[in] group A PP_Resource corresponding to the network * address of the multicast group. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*LeaveGroup)(PP_Resource udp_socket, PP_Resource group, struct PP_CompletionCallback callback); }; typedef struct PPB_UDPSocket_1_2 PPB_UDPSocket; struct PPB_UDPSocket_1_0 { PP_Resource (*Create)(PP_Instance instance); PP_Bool (*IsUDPSocket)(PP_Resource resource); int32_t (*Bind)(PP_Resource udp_socket, PP_Resource addr, struct PP_CompletionCallback callback); PP_Resource (*GetBoundAddress)(PP_Resource udp_socket); int32_t (*RecvFrom)(PP_Resource udp_socket, char* buffer, int32_t num_bytes, PP_Resource* addr, struct PP_CompletionCallback callback); int32_t (*SendTo)(PP_Resource udp_socket, const char* buffer, int32_t num_bytes, PP_Resource addr, struct PP_CompletionCallback callback); void (*Close)(PP_Resource udp_socket); int32_t (*SetOption)(PP_Resource udp_socket, PP_UDPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback); }; struct PPB_UDPSocket_1_1 { PP_Resource (*Create)(PP_Instance instance); PP_Bool (*IsUDPSocket)(PP_Resource resource); int32_t (*Bind)(PP_Resource udp_socket, PP_Resource addr, struct PP_CompletionCallback callback); PP_Resource (*GetBoundAddress)(PP_Resource udp_socket); int32_t (*RecvFrom)(PP_Resource udp_socket, char* buffer, int32_t num_bytes, PP_Resource* addr, struct PP_CompletionCallback callback); int32_t (*SendTo)(PP_Resource udp_socket, const char* buffer, int32_t num_bytes, PP_Resource addr, struct PP_CompletionCallback callback); void (*Close)(PP_Resource udp_socket); int32_t (*SetOption)(PP_Resource udp_socket, PP_UDPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback); }; /** * @} */ #endif /* PPAPI_C_PPB_UDP_SOCKET_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_url_loader.h000066400000000000000000000231551321746453100235470ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_url_loader.idl modified Thu Mar 28 10:07:37 2013. */ #ifndef PPAPI_C_PPB_URL_LOADER_H_ #define PPAPI_C_PPB_URL_LOADER_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_URLLOADER_INTERFACE_1_0 "PPB_URLLoader;1.0" #define PPB_URLLOADER_INTERFACE PPB_URLLOADER_INTERFACE_1_0 /** * @file * This file defines the PPB_URLLoader interface for loading * URLs. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_URLLoader interface contains pointers to functions * for loading URLs. The typical steps for loading a URL are: * * -# Call Create() to create a URLLoader object. * -# Create a URLRequestInfo object and set properties on it. * Refer to PPB_URLRequestInfo for further information. * -# Call Open() with the URLRequestInfo as an argument. * -# When Open() completes, call GetResponseInfo() to examine the response * headers. Refer to PPB_URLResponseInfo for further information. * -# Call ReadResponseBody() to stream the data for the response. * * Alternatively, if PP_URLREQUESTPROPERTY_STREAMTOFILE was set on * the URLRequestInfo in step #2: * - Call FinishStreamingToFile(), after examining the response headers * (step #4), to wait for the downloaded file to be complete. * - Then, access the downloaded file using the GetBodyAsFileRef() function of * the URLResponseInfo returned in step #4. */ struct PPB_URLLoader_1_0 { /** * Create() creates a new URLLoader object. The * URLLoader is associated with a particular instance, so that * any UI dialogs that need to be shown to the user can be positioned * relative to the window containing the instance. * * @param[in] instance A PP_Instance identifying one instance * of a module. * * @return A PP_Resource corresponding to a URLLoader if * successful, 0 if the instance is invalid. */ PP_Resource (*Create)(PP_Instance instance); /** * IsURLLoader() determines if a resource is an URLLoader. * * @param[in] resource A PP_Resource corresponding to a * URLLoader. * * @return PP_TRUE if the resource is a URLLoader, * PP_FALSE if the resource is invalid or some type other * than URLLoader. */ PP_Bool (*IsURLLoader)(PP_Resource resource); /** * Open() begins loading the URLRequestInfo. The operation * completes when response headers are received or when an error occurs. Use * GetResponseInfo() to access the response headers. * * @param[in] loader A PP_Resource corresponding to a * URLLoader. * @param[in] resource A PP_Resource corresponding to a * URLRequestInfo. * @param[in] callback A PP_CompletionCallback to run on * asynchronous completion of Open(). This callback will run when response * headers for the url are received or error occurred. This callback * will only run if Open() returns PP_OK_COMPLETIONPENDING. * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*Open)(PP_Resource loader, PP_Resource request_info, struct PP_CompletionCallback callback); /** * FollowRedirect() can be invoked to follow a redirect after Open() * completed on receiving redirect headers. * * @param[in] loader A PP_Resource corresponding to a * URLLoader. * @param[in] callback A PP_CompletionCallback to run on * asynchronous completion of FollowRedirect(). This callback will run when * response headers for the redirect url are received or error occurred. This * callback will only run if FollowRedirect() returns * PP_OK_COMPLETIONPENDING. * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*FollowRedirect)(PP_Resource loader, struct PP_CompletionCallback callback); /** * GetUploadProgress() returns the current upload progress (which is * meaningful after Open() has been called). Progress only refers to the * request body and does not include the headers. * * This data is only available if the URLRequestInfo passed * to Open() had the PP_URLREQUESTPROPERTY_REPORTUPLOADPROGRESS * property set to PP_TRUE. * * @param[in] loader A PP_Resource corresponding to a * URLLoader. * @param[in] bytes_sent The number of bytes sent thus far. * @param[in] total_bytes_to_be_sent The total number of bytes to be sent. * * @return PP_TRUE if the upload progress is available, * PP_FALSE if it is not available. */ PP_Bool (*GetUploadProgress)(PP_Resource loader, int64_t* bytes_sent, int64_t* total_bytes_to_be_sent); /** * GetDownloadProgress() returns the current download progress, which is * meaningful after Open() has been called. Progress only refers to the * response body and does not include the headers. * * This data is only available if the URLRequestInfo passed to * Open() had the PP_URLREQUESTPROPERTY_REPORTDOWNLOADPROGRESS * property set to PP_TRUE. * * @param[in] loader A PP_Resource corresponding to a * URLLoader. * @param[in] bytes_received The number of bytes received thus far. * @param[in] total_bytes_to_be_received The total number of bytes to be * received. The total bytes to be received may be unknown, in which case * total_bytes_to_be_received will be set to -1. * * @return PP_TRUE if the download progress is available, * PP_FALSE if it is not available. */ PP_Bool (*GetDownloadProgress)(PP_Resource loader, int64_t* bytes_received, int64_t* total_bytes_to_be_received); /** * GetResponseInfo() returns the current URLResponseInfo object. * * @param[in] instance A PP_Resource corresponding to a * URLLoader. * * @return A PP_Resource corresponding to the * URLResponseInfo if successful, 0 if the loader is not a valid * resource or if Open() has not been called. */ PP_Resource (*GetResponseInfo)(PP_Resource loader); /** * ReadResponseBody() is used to read the response body. The size of the * buffer must be large enough to hold the specified number of bytes to read. * This function might perform a partial read. * * @param[in] loader A PP_Resource corresponding to a * URLLoader. * @param[in,out] buffer A pointer to the buffer for the response body. * @param[in] bytes_to_read The number of bytes to read. * @param[in] callback A PP_CompletionCallback to run on * asynchronous completion. The callback will run if the bytes (full or * partial) are read or an error occurs asynchronously. This callback will * run only if this function returns PP_OK_COMPLETIONPENDING. * * @return An int32_t containing the number of bytes read or an error code * from pp_errors.h. */ int32_t (*ReadResponseBody)(PP_Resource loader, void* buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback); /** * FinishStreamingToFile() is used to wait for the response body to be * completely downloaded to the file provided by the GetBodyAsFileRef() * in the current URLResponseInfo. This function is only used if * PP_URLREQUESTPROPERTY_STREAMTOFILE was set on the * URLRequestInfo passed to Open(). * * @param[in] loader A PP_Resource corresponding to a * URLLoader. * @param[in] callback A PP_CompletionCallback to run on * asynchronous completion. This callback will run when body is downloaded * or an error occurs after FinishStreamingToFile() returns * PP_OK_COMPLETIONPENDING. * * @return An int32_t containing the number of bytes read or an error code * from pp_errors.h. */ int32_t (*FinishStreamingToFile)(PP_Resource loader, struct PP_CompletionCallback callback); /** * Close is a pointer to a function used to cancel any pending IO and close * the URLLoader object. Any pending callbacks will still run, * reporting PP_ERROR_ABORTED if pending IO was interrupted. * It is NOT valid to call Open() again after a call to this function. * * Note: If the URLLoader object is destroyed * while it is still open, then it will be implicitly closed so you are not * required to call Close(). * * @param[in] loader A PP_Resource corresponding to a * URLLoader. */ void (*Close)(PP_Resource loader); }; typedef struct PPB_URLLoader_1_0 PPB_URLLoader; /** * @} */ #endif /* PPAPI_C_PPB_URL_LOADER_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_url_request_info.h000066400000000000000000000261301321746453100250000ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_url_request_info.idl modified Thu Mar 28 10:19:35 2013. */ #ifndef PPAPI_C_PPB_URL_REQUEST_INFO_H_ #define PPAPI_C_PPB_URL_REQUEST_INFO_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" #include "ppapi/c/pp_var.h" #define PPB_URLREQUESTINFO_INTERFACE_1_0 "PPB_URLRequestInfo;1.0" #define PPB_URLREQUESTINFO_INTERFACE PPB_URLREQUESTINFO_INTERFACE_1_0 /** * @file * This file defines the PPB_URLRequestInfo API for creating and * manipulating URL requests. */ /** * @addtogroup Enums * @{ */ /** * This enumeration contains properties that can be set on a URL request. */ typedef enum { /** This corresponds to a string (PP_VARTYPE_STRING). */ PP_URLREQUESTPROPERTY_URL = 0, /** * This corresponds to a string (PP_VARTYPE_STRING); either * POST or GET. Refer to the * HTTP * Methods documentation for further information. * */ PP_URLREQUESTPROPERTY_METHOD = 1, /** * This corresponds to a string (PP_VARTYPE_STRING); \n * delimited. Refer to the * documentation for further information. */ PP_URLREQUESTPROPERTY_HEADERS = 2, /** * This corresponds to a PP_Bool (PP_VARTYPE_BOOL; * default=PP_FALSE). * Set this value to PP_TRUE if you want to download the data * to a file. Use PPB_URLLoader.FinishStreamingToFile() to complete the * download. */ PP_URLREQUESTPROPERTY_STREAMTOFILE = 3, /** * This corresponds to a PP_Bool (PP_VARTYPE_BOOL; * default=PP_TRUE). * Set this value to PP_FALSE if you want to use * PPB_URLLoader.FollowRedirects() to follow the redirects only after * examining redirect headers. */ PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS = 4, /** * This corresponds to a PP_Bool (PP_VARTYPE_BOOL; * default=PP_FALSE). * Set this value to PP_TRUE if you want to be able to poll the * download progress using PPB_URLLoader.GetDownloadProgress(). */ PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS = 5, /** * This corresponds to a PP_Bool * (default=PP_FALSE). Set this value to PP_TRUE if * you want to be able to poll the upload progress using * PPB_URLLoader.GetUploadProgress(). */ PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS = 6, /** * This corresponds to a string (PP_VARTYPE_STRING) or may be * undefined (PP_VARTYPE_UNDEFINED; default). * Set it to a string to set a custom referrer (if empty, the referrer header * will be omitted), or to undefined to use the default referrer. Only loaders * with universal access (only available on trusted implementations) will * accept URLRequestInfo objects that try to set a custom * referrer; if given to a loader without universal access, * PP_ERROR_NOACCESS will result. */ PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL = 7, /** * This corresponds to a PP_Bool (PP_VARTYPE_BOOL; * default=PP_FALSE). Whether cross-origin requests are allowed. * Cross-origin requests are made using the CORS (Cross-Origin Resource * Sharing) algorithm to check whether the request should be allowed. For the * complete CORS algorithm, refer to * the Cross-Origin Resource * Sharing documentation. */ PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS = 8, /** * This corresponds to a PP_Bool (PP_VARTYPE_BOOL; * default=PP_FALSE). * Whether HTTP credentials are sent with cross-origin requests. If false, * no credentials are sent with the request and cookies are ignored in the * response. If the request is not cross-origin, this property is ignored. */ PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS = 9, /** * This corresponds to a string (PP_VARTYPE_STRING) or may be * undefined (PP_VARTYPE_UNDEFINED; default). * Set it to a string to set a custom content-transfer-encoding header (if * empty, that header will be omitted), or to undefined to use the default * (if any). Only loaders with universal access (only available on trusted * implementations) will accept URLRequestInfo objects that try * to set a custom content transfer encoding; if given to a loader without * universal access, PP_ERROR_NOACCESS will result. */ PP_URLREQUESTPROPERTY_CUSTOMCONTENTTRANSFERENCODING = 10, /** * This corresponds to an integer (PP_VARTYPE_INT32); default * is not defined and is set by the browser, possibly depending on system * capabilities. Set it to an integer to set an upper threshold for the * prefetched buffer of an asynchronous load. When exceeded, the browser will * defer loading until * PP_URLREQUESTPROPERTY_PREFETCHBUFFERLOWERERTHRESHOLD is hit, * at which time it will begin prefetching again. When setting this property, * PP_URLREQUESTPROPERTY_PREFETCHBUFFERLOWERERTHRESHOLD must also * be set. Behavior is undefined if the former is <= the latter. */ PP_URLREQUESTPROPERTY_PREFETCHBUFFERUPPERTHRESHOLD = 11, /** * This corresponds to an integer (PP_VARTYPE_INT32); default is * not defined and is set by the browser to a value appropriate for the * default PP_URLREQUESTPROPERTY_PREFETCHBUFFERUPPERTHRESHOLD. * Set it to an integer to set a lower threshold for the prefetched buffer * of an asynchronous load. When reached, the browser will resume loading if * If PP_URLREQUESTPROPERTY_PREFETCHBUFFERLOWERERTHRESHOLD had * previously been reached. * When setting this property, * PP_URLREQUESTPROPERTY_PREFETCHBUFFERUPPERTHRESHOLD must also * be set. Behavior is undefined if the former is >= the latter. */ PP_URLREQUESTPROPERTY_PREFETCHBUFFERLOWERTHRESHOLD = 12, /** * This corresponds to a string (PP_VARTYPE_STRING) or may be * undefined (PP_VARTYPE_UNDEFINED; default). Set it to a string * to set a custom user-agent header (if empty, that header will be omitted), * or to undefined to use the default. Only loaders with universal access * (only available on trusted implementations) will accept * URLRequestInfo objects that try to set a custom user agent; if * given to a loader without universal access, PP_ERROR_NOACCESS * will result. */ PP_URLREQUESTPROPERTY_CUSTOMUSERAGENT = 13 } PP_URLRequestProperty; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_URLRequestProperty, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_URLRequestInfo interface is used to create * and handle URL requests. This API is used in conjunction with * PPB_URLLoader. Refer to PPB_URLLoader for further * information. */ struct PPB_URLRequestInfo_1_0 { /** * Create() creates a new URLRequestInfo object. * * @param[in] instance A PP_Instance identifying one instance * of a module. * * @return A PP_Resource identifying the * URLRequestInfo if successful, 0 if the instance is invalid. */ PP_Resource (*Create)(PP_Instance instance); /** * IsURLRequestInfo() determines if a resource is a * URLRequestInfo. * * @param[in] resource A PP_Resource corresponding to a * URLRequestInfo. * * @return PP_TRUE if the resource is a * URLRequestInfo, PP_FALSE if the resource is * invalid or some type other than URLRequestInfo. */ PP_Bool (*IsURLRequestInfo)(PP_Resource resource); /** * SetProperty() sets a request property. The value of the property must be * the correct type according to the property being set. * * @param[in] request A PP_Resource corresponding to a * URLRequestInfo. * @param[in] property A PP_URLRequestProperty identifying the * property to set. * @param[in] value A PP_Var containing the property value. * * @return PP_TRUE if successful, PP_FALSE if any * of the parameters are invalid. */ PP_Bool (*SetProperty)(PP_Resource request, PP_URLRequestProperty property, struct PP_Var value); /** * AppendDataToBody() appends data to the request body. A Content-Length * request header will be automatically generated. * * @param[in] request A PP_Resource corresponding to a * URLRequestInfo. * @param[in] data A pointer to a buffer holding the data. * @param[in] len The length, in bytes, of the data. * * @return PP_TRUE if successful, PP_FALSE if any * of the parameters are invalid. * * */ PP_Bool (*AppendDataToBody)(PP_Resource request, const void* data, uint32_t len); /** * AppendFileToBody() appends a file, to be uploaded, to the request body. * A content-length request header will be automatically generated. * * @param[in] request A PP_Resource corresponding to a * URLRequestInfo. * @param[in] file_ref A PP_Resource corresponding to a file * reference. * @param[in] start_offset An optional starting point offset within the * file. * @param[in] number_of_bytes An optional number of bytes of the file to * be included. If number_of_bytes is -1, then the sub-range * to upload extends to the end of the file. * @param[in] expected_last_modified_time An optional (non-zero) last * modified time stamp used to validate that the file was not modified since * the given time before it was uploaded. The upload will fail with an error * code of PP_ERROR_FILECHANGED if the file has been modified * since the given time. If expected_last_modified_time is 0, * then no validation is performed. * * @return PP_TRUE if successful, PP_FALSE if any * of the parameters are invalid. */ PP_Bool (*AppendFileToBody)(PP_Resource request, PP_Resource file_ref, int64_t start_offset, int64_t number_of_bytes, PP_Time expected_last_modified_time); }; typedef struct PPB_URLRequestInfo_1_0 PPB_URLRequestInfo; /** * @} */ #endif /* PPAPI_C_PPB_URL_REQUEST_INFO_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_url_response_info.h000066400000000000000000000126101321746453100251440ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_url_response_info.idl modified Mon Nov 14 10:36:01 2011. */ #ifndef PPAPI_C_PPB_URL_RESPONSE_INFO_H_ #define PPAPI_C_PPB_URL_RESPONSE_INFO_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_URLRESPONSEINFO_INTERFACE_1_0 "PPB_URLResponseInfo;1.0" #define PPB_URLRESPONSEINFO_INTERFACE PPB_URLRESPONSEINFO_INTERFACE_1_0 /** * @file * This file defines the PPB_URLResponseInfo API for examining URL * responses. */ /** * @addtogroup Enums * @{ */ /** * This enumeration contains properties set on a URL response. */ typedef enum { /** * This corresponds to a string (PP_VARTYPE_STRING); an absolute URL formed by * resolving the relative request URL with the absolute document URL. Refer * to the * * HTTP Request URI and * * HTML Resolving Relative URIs documentation for further information. */ PP_URLRESPONSEPROPERTY_URL = 0, /** * This corresponds to a string (PP_VARTYPE_STRING); the absolute URL returned * in the response header's 'Location' field if this is a redirect response, * an empty string otherwise. Refer to the * * HTTP Status Codes - Redirection documentation for further information. */ PP_URLRESPONSEPROPERTY_REDIRECTURL = 1, /** * This corresponds to a string (PP_VARTYPE_STRING); the HTTP method to be * used in a new request if this is a redirect response, an empty string * otherwise. Refer to the * * HTTP Status Codes - Redirection documentation for further information. */ PP_URLRESPONSEPROPERTY_REDIRECTMETHOD = 2, /** * This corresponds to an int32 (PP_VARETYPE_INT32); the status code from the * response, e.g., 200 if the request was successful. Refer to the * * HTTP Status Code and Reason Phrase documentation for further * information. */ PP_URLRESPONSEPROPERTY_STATUSCODE = 3, /** * This corresponds to a string (PP_VARTYPE_STRING); the status line * from the response. Refer to the * * HTTP Response Status Line documentation for further information. */ PP_URLRESPONSEPROPERTY_STATUSLINE = 4, /** * This corresponds to a string(PP_VARTYPE_STRING), a \n-delimited list of * header field/value pairs of the form "field: value", returned by the * server. Refer to the * * HTTP Header Field Definitions documentation for further information. */ PP_URLRESPONSEPROPERTY_HEADERS = 5 } PP_URLResponseProperty; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_URLResponseProperty, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_URLResponseInfo interface contains APIs for * examining URL responses. Refer to PPB_URLLoader for further * information. */ struct PPB_URLResponseInfo_1_0 { /** * IsURLResponseInfo() determines if a response is a * URLResponseInfo. * * @param[in] resource A PP_Resource corresponding to a * URLResponseInfo. * * @return PP_TRUE if the resource is a * URLResponseInfo, PP_FALSE if the resource is * invalid or some type other than URLResponseInfo. */ PP_Bool (*IsURLResponseInfo)(PP_Resource resource); /** * GetProperty() gets a response property. * * @param[in] request A PP_Resource corresponding to a * URLResponseInfo. * @param[in] property A PP_URLResponseProperty identifying * the type of property in the response. * * @return A PP_Var containing the response property value if * successful, PP_VARTYPE_VOID if an input parameter is invalid. */ struct PP_Var (*GetProperty)(PP_Resource response, PP_URLResponseProperty property); /** * GetBodyAsFileRef() returns a FileRef pointing to the file containing the * response body. This is only valid if * PP_URLREQUESTPROPERTY_STREAMTOFILE was set on the * URLRequestInfo used to produce this response. This file * remains valid until the URLLoader associated with this * URLResponseInfo is closed or destroyed. * * @param[in] request A PP_Resource corresponding to a * URLResponseInfo. * * @return A PP_Resource corresponding to a FileRef * if successful, 0 if PP_URLREQUESTPROPERTY_STREAMTOFILE was * not requested or if the URLLoader has not been opened yet. */ PP_Resource (*GetBodyAsFileRef)(PP_Resource response); }; typedef struct PPB_URLResponseInfo_1_0 PPB_URLResponseInfo; /** * @} */ #endif /* PPAPI_C_PPB_URL_RESPONSE_INFO_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_var.h000066400000000000000000000121331321746453100222010ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_var.idl modified Thu Apr 10 14:54:41 2014. */ #ifndef PPAPI_C_PPB_VAR_H_ #define PPAPI_C_PPB_VAR_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_VAR_INTERFACE_1_0 "PPB_Var;1.0" #define PPB_VAR_INTERFACE_1_1 "PPB_Var;1.1" #define PPB_VAR_INTERFACE_1_2 "PPB_Var;1.2" #define PPB_VAR_INTERFACE PPB_VAR_INTERFACE_1_2 /** * @file * This file defines the PPB_Var struct. */ /** * @addtogroup Interfaces * @{ */ /** * PPB_Var API */ struct PPB_Var_1_2 { /** * AddRef() adds a reference to the given var. If this is not a refcounted * object, this function will do nothing so you can always call it no matter * what the type. * * @param[in] var A PP_Var that will have a reference added. */ void (*AddRef)(struct PP_Var var); /** * Release() removes a reference to given var, deleting it if the internal * reference count becomes 0. If the PP_Var is of type * PP_VARTYPE_RESOURCE, * it will implicitly release a reference count on the * PP_Resource (equivalent to PPB_Core::ReleaseResource()). * * If the given var is not a refcounted object, this function will do nothing * so you can always call it no matter what the type. * * @param[in] var A PP_Var that will have a reference removed. */ void (*Release)(struct PP_Var var); /** * VarFromUtf8() creates a string var from a string. The string must be * encoded in valid UTF-8 and is NOT NULL-terminated, the length must be * specified in len. It is an error if the string is not * valid UTF-8. * * If the length is 0, the *data pointer will not be dereferenced * and may be NULL. Note, however if length is 0, the * "NULL-ness" will not be preserved, as VarToUtf8() will never return * NULL on success, even for empty strings. * * The resulting object will be a refcounted string object. It will be * AddRef'ed for the caller. When the caller is done with it, it should be * Released. * * On error (basically out of memory to allocate the string, or input that * is not valid UTF-8), this function will return a Null var. * * @param[in] data A string * @param[in] len The length of the string. * * @return A PP_Var structure containing a reference counted * string object. */ struct PP_Var (*VarFromUtf8)(const char* data, uint32_t len); /** * VarToUtf8() converts a string-type var to a char* encoded in UTF-8. This * string is NOT NULL-terminated. The length will be placed in * *len. If the string is valid but empty the return value will * be non-NULL, but *len will still be 0. * * If the var is not a string, this function will return NULL and * *len will be 0. * * The returned buffer will be valid as long as the underlying var is alive. * If the instance frees its reference, the string will be freed and the * pointer will be to arbitrary memory. * * @param[in] var A PP_Var struct containing a string-type var. * @param[in,out] len A pointer to the length of the string-type var. * * @return A char* encoded in UTF-8. */ const char* (*VarToUtf8)(struct PP_Var var, uint32_t* len); /** * Converts a resource-type var to a PP_Resource. * * @param[in] var A PP_Var struct containing a resource-type var. * * @return A PP_Resource retrieved from the var, or 0 if the var * is not a resource. The reference count of the resource is incremented on * behalf of the caller. */ PP_Resource (*VarToResource)(struct PP_Var var); /** * Creates a new PP_Var from a given resource. Implicitly adds a * reference count on the PP_Resource (equivalent to * PPB_Core::AddRefResource(resource)). * * @param[in] resource A PP_Resource to be wrapped in a var. * * @return A PP_Var created for this resource, with type * PP_VARTYPE_RESOURCE. The reference count of the var is set to * 1 on behalf of the caller. */ struct PP_Var (*VarFromResource)(PP_Resource resource); }; typedef struct PPB_Var_1_2 PPB_Var; struct PPB_Var_1_0 { void (*AddRef)(struct PP_Var var); void (*Release)(struct PP_Var var); struct PP_Var (*VarFromUtf8)(PP_Module module, const char* data, uint32_t len); const char* (*VarToUtf8)(struct PP_Var var, uint32_t* len); }; struct PPB_Var_1_1 { void (*AddRef)(struct PP_Var var); void (*Release)(struct PP_Var var); struct PP_Var (*VarFromUtf8)(const char* data, uint32_t len); const char* (*VarToUtf8)(struct PP_Var var, uint32_t* len); }; /** * @} */ #endif /* PPAPI_C_PPB_VAR_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_var_array.h000066400000000000000000000057741321746453100234140ustar00rootroot00000000000000/* Copyright 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_var_array.idl modified Sun Jun 16 15:37:27 2013. */ #ifndef PPAPI_C_PPB_VAR_ARRAY_H_ #define PPAPI_C_PPB_VAR_ARRAY_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_VAR_ARRAY_INTERFACE_1_0 "PPB_VarArray;1.0" #define PPB_VAR_ARRAY_INTERFACE PPB_VAR_ARRAY_INTERFACE_1_0 /** * @file * This file defines the PPB_VarArray struct providing * a way to interact with array vars. */ /** * @addtogroup Interfaces * @{ */ struct PPB_VarArray_1_0 { /** * Creates an array var, i.e., a PP_Var with type set to * PP_VARTYPE_ARRAY. The array length is set to 0. * * @return An empty array var, whose reference count is set to 1 on behalf of * the caller. */ struct PP_Var (*Create)(void); /** * Gets an element from the array. * * @param[in] array An array var. * @param[in] index An index indicating which element to return. * * @return The element at the specified position. The reference count of the * element returned is incremented on behalf of the caller. If * index is larger than or equal to the array length, an * undefined var is returned. */ struct PP_Var (*Get)(struct PP_Var array, uint32_t index); /** * Sets the value of an element in the array. * * @param[in] array An array var. * @param[in] index An index indicating which element to modify. If * index is larger than or equal to the array length, the length * is updated to be index + 1. Any position in the array that * hasn't been set before is set to undefined, i.e., PP_Var of * type PP_VARTYPE_UNDEFINED. * @param[in] value The value to set. The array holds a reference to it on * success. * * @return A PP_Bool indicating whether the operation succeeds. */ PP_Bool (*Set)(struct PP_Var array, uint32_t index, struct PP_Var value); /** * Gets the array length. * * @param[in] array An array var. * * @return The array length. */ uint32_t (*GetLength)(struct PP_Var array); /** * Sets the array length. * * @param[in] array An array var. * @param[in] length The new array length. If length is smaller * than its current value, the array is truncated to the new length; any * elements that no longer fit are removed and the references to them will be * released. If length is larger than its current value, * undefined vars are appended to increase the array to the specified length. * * @return A PP_Bool indicating whether the operation succeeds. */ PP_Bool (*SetLength)(struct PP_Var array, uint32_t length); }; typedef struct PPB_VarArray_1_0 PPB_VarArray; /** * @} */ #endif /* PPAPI_C_PPB_VAR_ARRAY_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_var_array_buffer.h000066400000000000000000000106161321746453100247340ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_var_array_buffer.idl modified Thu Feb 28 09:24:06 2013. */ #ifndef PPAPI_C_PPB_VAR_ARRAY_BUFFER_H_ #define PPAPI_C_PPB_VAR_ARRAY_BUFFER_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_VAR_ARRAY_BUFFER_INTERFACE_1_0 "PPB_VarArrayBuffer;1.0" #define PPB_VAR_ARRAY_BUFFER_INTERFACE PPB_VAR_ARRAY_BUFFER_INTERFACE_1_0 /** * @file * This file defines the PPB_VarArrayBuffer struct providing * a way to interact with JavaScript ArrayBuffers. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_VarArrayBuffer interface provides a way to interact * with JavaScript ArrayBuffers, which represent a contiguous sequence of * bytes. Use PPB_Var to manage the reference count for a * VarArrayBuffer. Note that these Vars are not part of the * embedding page's DOM, and can only be shared with JavaScript using the * PostMessage and HandleMessage functions of * pp::Instance. */ struct PPB_VarArrayBuffer_1_0 { /** * Create() creates a zero-initialized VarArrayBuffer. * * @param[in] size_in_bytes The size of the ArrayBuffer to * be created. * * @return A PP_Var representing a VarArrayBuffer * of the requested size and with a reference count of 1. */ struct PP_Var (*Create)(uint32_t size_in_bytes); /** * ByteLength() retrieves the length of the VarArrayBuffer in * bytes. On success, byte_length is set to the length of the * given ArrayBuffer var. On failure, byte_length * is unchanged (this could happen, for instance, if the given * PP_Var is not of type PP_VARTYPE_ARRAY_BUFFER). * Note that ByteLength() will successfully retrieve the size of an * ArrayBuffer even if the ArrayBuffer is not * currently mapped. * * @param[in] array The ArrayBuffer whose length should be * returned. * * @param[out] byte_length A variable which is set to the length of the given * ArrayBuffer on success. * * @return PP_TRUE on success, PP_FALSE on failure. */ PP_Bool (*ByteLength)(struct PP_Var array, uint32_t* byte_length); /** * Map() maps the ArrayBuffer in to the module's address space * and returns a pointer to the beginning of the buffer for the given * ArrayBuffer PP_Var. ArrayBuffers are copied when transmitted, * so changes to the underlying memory are not automatically available to * the embedding page. * * Note that calling Map() can be a relatively expensive operation. Use care * when calling it in performance-critical code. For example, you should call * it only once when looping over an ArrayBuffer. * * Example: * * @code * char* data = (char*)(array_buffer_if.Map(array_buffer_var)); * uint32_t byte_length = 0; * PP_Bool ok = array_buffer_if.ByteLength(array_buffer_var, &byte_length); * if (!ok) * return DoSomethingBecauseMyVarIsNotAnArrayBuffer(); * for (uint32_t i = 0; i < byte_length; ++i) * data[i] = 'A'; * @endcode * * @param[in] array The ArrayBuffer whose internal buffer should * be returned. * * @return A pointer to the internal buffer for this * ArrayBuffer. Returns NULL * if the given PP_Var is not of type * PP_VARTYPE_ARRAY_BUFFER. */ void* (*Map)(struct PP_Var array); /** * Unmap() unmaps the given ArrayBuffer var from the module * address space. Use this if you want to save memory but might want to call * Map() to map the buffer again later. The PP_Var remains valid * and should still be released using PPB_Var when you are done * with the ArrayBuffer. * * @param[in] array The ArrayBuffer to be released. */ void (*Unmap)(struct PP_Var array); }; typedef struct PPB_VarArrayBuffer_1_0 PPB_VarArrayBuffer; /** * @} */ #endif /* PPAPI_C_PPB_VAR_ARRAY_BUFFER_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_var_dictionary.h000066400000000000000000000067341321746453100244400ustar00rootroot00000000000000/* Copyright 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_var_dictionary.idl modified Sat Jun 8 23:03:54 2013. */ #ifndef PPAPI_C_PPB_VAR_DICTIONARY_H_ #define PPAPI_C_PPB_VAR_DICTIONARY_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_VAR_DICTIONARY_INTERFACE_1_0 "PPB_VarDictionary;1.0" #define PPB_VAR_DICTIONARY_INTERFACE PPB_VAR_DICTIONARY_INTERFACE_1_0 /** * @file * This file defines the PPB_VarDictionary struct providing * a way to interact with dictionary vars. */ /** * @addtogroup Interfaces * @{ */ /** * A dictionary var contains key-value pairs with unique keys. The keys are * strings while the values can be arbitrary vars. Key comparison is always * done by value instead of by reference. */ struct PPB_VarDictionary_1_0 { /** * Creates a dictionary var, i.e., a PP_Var with type set to * PP_VARTYPE_DICTIONARY. * * @return An empty dictionary var, whose reference count is set to 1 on * behalf of the caller. */ struct PP_Var (*Create)(void); /** * Gets the value associated with the specified key. * * @param[in] dict A dictionary var. * @param[in] key A string var. * * @return The value that is associated with key. The reference * count of the element returned is incremented on behalf of the caller. If * key is not a string var, or it doesn't exist in * dict, an undefined var is returned. */ struct PP_Var (*Get)(struct PP_Var dict, struct PP_Var key); /** * Sets the value associated with the specified key. * * @param[in] dict A dictionary var. * @param[in] key A string var. If this key hasn't existed in * dict, it is added and associated with value; * otherwise, the previous value is replaced with value. * @param[in] value The value to set. The dictionary holds a reference to it * on success. * * @return A PP_Bool indicating whether the operation succeeds. */ PP_Bool (*Set)(struct PP_Var dict, struct PP_Var key, struct PP_Var value); /** * Deletes the specified key and its associated value, if the key exists. The * reference to the element will be released. * * @param[in] dict A dictionary var. * @param[in] key A string var. */ void (*Delete)(struct PP_Var dict, struct PP_Var key); /** * Checks whether a key exists. * * @param[in] dict A dictionary var. * @param[in] key A string var. * * @return A PP_Bool indicating whether the key exists. */ PP_Bool (*HasKey)(struct PP_Var dict, struct PP_Var key); /** * Gets all the keys in a dictionary. Please note that for each key that you * set into the dictionary, a string var with the same contents is returned; * but it may not be the same string var (i.e., value.as_id may * be different). * * @param[in] dict A dictionary var. * * @return An array var which contains all the keys of dict. Its * reference count is incremented on behalf of the caller. The elements are * string vars. Returns a null var if failed. */ struct PP_Var (*GetKeys)(struct PP_Var dict); }; typedef struct PPB_VarDictionary_1_0 PPB_VarDictionary; /** * @} */ #endif /* PPAPI_C_PPB_VAR_DICTIONARY_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_video_decoder.h000066400000000000000000000334051321746453100242110ustar00rootroot00000000000000/* Copyright (c) 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_video_decoder.idl modified Mon Sep 28 15:23:30 2015. */ #ifndef PPAPI_C_PPB_VIDEO_DECODER_H_ #define PPAPI_C_PPB_VIDEO_DECODER_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_codecs.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #define PPB_VIDEODECODER_INTERFACE_0_1 "PPB_VideoDecoder;0.1" #define PPB_VIDEODECODER_INTERFACE_0_2 "PPB_VideoDecoder;0.2" #define PPB_VIDEODECODER_INTERFACE_1_0 "PPB_VideoDecoder;1.0" #define PPB_VIDEODECODER_INTERFACE_1_1 "PPB_VideoDecoder;1.1" #define PPB_VIDEODECODER_INTERFACE PPB_VIDEODECODER_INTERFACE_1_1 /** * @file * This file defines the PPB_VideoDecoder interface. */ /** * @addtogroup Interfaces * @{ */ /** * Video decoder interface. * * Typical usage: * - Call Create() to create a new video decoder resource. * - Call Initialize() to initialize it with a 3d graphics context and the * desired codec profile. * - Call Decode() continuously (waiting for each previous call to complete) to * push bitstream buffers to the decoder. * - Call GetPicture() continuously (waiting for each previous call to complete) * to pull decoded pictures from the decoder. * - Call Flush() to signal end of stream to the decoder and perform shutdown * when it completes. * - Call Reset() to quickly stop the decoder (e.g. to implement Seek) and wait * for the callback before restarting decoding at another point. * - To destroy the decoder, the plugin should release all of its references to * it. Any pending callbacks will abort before the decoder is destroyed. * * Available video codecs vary by platform. * All: theora, vorbis, vp8. * Chrome and ChromeOS: aac, h264. * ChromeOS: mpeg4. */ struct PPB_VideoDecoder_1_1 { /** * Creates a new video decoder resource. * * @param[in] instance A PP_Instance identifying the instance * with the video decoder. * * @return A PP_Resource corresponding to a video decoder if * successful or 0 otherwise. */ PP_Resource (*Create)(PP_Instance instance); /** * Determines if the given resource is a video decoder. * * @param[in] resource A PP_Resource identifying a resource. * * @return PP_TRUE if the resource is a * PPB_VideoDecoder, PP_FALSE if the resource is * invalid or some other type. */ PP_Bool (*IsVideoDecoder)(PP_Resource resource); /** * Initializes a video decoder resource. This should be called after Create() * and before any other functions. * * @param[in] video_decoder A PP_Resource identifying the video * decoder. * @param[in] graphics3d_context A PPB_Graphics3D resource to use * during decoding. * @param[in] profile A PP_VideoProfile specifying the video * codec profile. * @param[in] acceleration A PP_HardwareAcceleration specifying * whether to use a hardware accelerated or a software implementation. * @param[in] min_picture_count A count of pictures the plugin would like to * have in flight. This is effectively the number of times the plugin can * call GetPicture() and get a decoded frame without calling * RecyclePicture(). The decoder has its own internal minimum count, and will * take the larger of its internal and this value. A client that doesn't care * can therefore just pass in zero for this argument. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h. * Returns PP_ERROR_NOTSUPPORTED if video decoding is not available, or the * requested profile is not supported. In this case, the client may call * Initialize() again with different parameters to find a good configuration. * Returns PP_ERROR_BADARGUMENT if the requested minimum picture count is * unreasonably large. */ int32_t (*Initialize)(PP_Resource video_decoder, PP_Resource graphics3d_context, PP_VideoProfile profile, PP_HardwareAcceleration acceleration, uint32_t min_picture_count, struct PP_CompletionCallback callback); /** * Decodes a bitstream buffer. Copies |size| bytes of data from the plugin's * |buffer|. The plugin should wait until the decoder signals completion by * returning PP_OK or by running |callback| before calling Decode() again. * * In general, each bitstream buffer should contain a demuxed bitstream frame * for the selected video codec. For example, H264 decoders expect to receive * one AnnexB NAL unit, including the 4 byte start code prefix, while VP8 * decoders expect to receive a bitstream frame without the IVF frame header. * * If the call to Decode() eventually results in a picture, the |decode_id| * parameter is copied into the returned picture. The plugin can use this to * associate decoded pictures with Decode() calls (e.g. to assign timestamps * or frame numbers to pictures.) This value is opaque to the API so the * plugin is free to pass any value. * * @param[in] video_decoder A PP_Resource identifying the video * decoder. * @param[in] decode_id An optional value, chosen by the plugin, that can be * used to associate calls to Decode() with decoded pictures returned by * GetPicture(). * @param[in] size Buffer size in bytes. * @param[in] buffer Starting address of buffer. * @param[in] callback A PP_CompletionCallback to be called on * completion. * * @return An int32_t containing an error code from pp_errors.h. * Returns PP_ERROR_FAILED if the decoder isn't initialized or if a Flush() * or Reset() call is pending. * Returns PP_ERROR_INPROGRESS if there is another Decode() call pending. * Returns PP_ERROR_NOMEMORY if a bitstream buffer can't be created. * Returns PP_ERROR_ABORTED when Reset() is called while Decode() is pending. */ int32_t (*Decode)(PP_Resource video_decoder, uint32_t decode_id, uint32_t size, const void* buffer, struct PP_CompletionCallback callback); /** * Gets the next picture from the decoder. The picture is valid after the * decoder signals completion by returning PP_OK or running |callback|. The * plugin can call GetPicture() again after the decoder signals completion. * When the plugin is finished using the picture, it should return it to the * system by calling RecyclePicture(). * * @param[in] video_decoder A PP_Resource identifying the video * decoder. * @param[out] picture A PP_VideoPicture to hold the decoded * picture. * @param[in] callback A PP_CompletionCallback to be called on * completion. * * @return An int32_t containing an error code from pp_errors.h. * Returns PP_ERROR_FAILED if the decoder isn't initialized or if a Reset() * call is pending. * Returns PP_ERROR_INPROGRESS if there is another GetPicture() call pending. * Returns PP_ERROR_ABORTED when Reset() is called, or if a call to Flush() * completes while GetPicture() is pending. */ int32_t (*GetPicture)(PP_Resource video_decoder, struct PP_VideoPicture* picture, struct PP_CompletionCallback callback); /** * Recycles a picture that the plugin has received from the decoder. * The plugin should call this as soon as it has finished using the texture so * the decoder can decode more pictures. * * @param[in] video_decoder A PP_Resource identifying the video * decoder. * @param[in] picture A PP_VideoPicture to return to * the decoder. */ void (*RecyclePicture)(PP_Resource video_decoder, const struct PP_VideoPicture* picture); /** * Flushes the decoder. The plugin should call Flush() when it reaches the * end of its video stream in order to stop cleanly. The decoder will run any * pending Decode() call to completion. The plugin should make no further * calls to the decoder other than GetPicture() and RecyclePicture() until * the decoder signals completion by running |callback|. Just before * completion, any pending GetPicture() call will complete by running its * callback with result PP_ERROR_ABORTED to signal that no more pictures are * available. Any pictures held by the plugin remain valid during and after * the flush and should be recycled back to the decoder. * * @param[in] video_decoder A PP_Resource identifying the video * decoder. * @param[in] callback A PP_CompletionCallback to be called on * completion. * * @return An int32_t containing an error code from pp_errors.h. * Returns PP_ERROR_FAILED if the decoder isn't initialized. */ int32_t (*Flush)(PP_Resource video_decoder, struct PP_CompletionCallback callback); /** * Resets the decoder as quickly as possible. The plugin can call Reset() to * skip to another position in the video stream. After Reset() returns, any * pending calls to Decode() and GetPicture()) abort, causing their callbacks * to run with PP_ERROR_ABORTED. The plugin should not make further calls to * the decoder other than RecyclePicture() until the decoder signals * completion by running |callback|. Any pictures held by the plugin remain * valid during and after the reset and should be recycled back to the * decoder. * * @param[in] video_decoder A PP_Resource identifying the video * decoder. * @param[in] callback A PP_CompletionCallback to be called on * completion. * * @return An int32_t containing an error code from pp_errors.h. * Returns PP_ERROR_FAILED if the decoder isn't initialized. */ int32_t (*Reset)(PP_Resource video_decoder, struct PP_CompletionCallback callback); }; typedef struct PPB_VideoDecoder_1_1 PPB_VideoDecoder; struct PPB_VideoDecoder_0_1 { PP_Resource (*Create)(PP_Instance instance); PP_Bool (*IsVideoDecoder)(PP_Resource resource); int32_t (*Initialize)(PP_Resource video_decoder, PP_Resource graphics3d_context, PP_VideoProfile profile, PP_Bool allow_software_fallback, struct PP_CompletionCallback callback); int32_t (*Decode)(PP_Resource video_decoder, uint32_t decode_id, uint32_t size, const void* buffer, struct PP_CompletionCallback callback); int32_t (*GetPicture)(PP_Resource video_decoder, struct PP_VideoPicture_0_1* picture, struct PP_CompletionCallback callback); void (*RecyclePicture)(PP_Resource video_decoder, const struct PP_VideoPicture* picture); int32_t (*Flush)(PP_Resource video_decoder, struct PP_CompletionCallback callback); int32_t (*Reset)(PP_Resource video_decoder, struct PP_CompletionCallback callback); }; struct PPB_VideoDecoder_0_2 { PP_Resource (*Create)(PP_Instance instance); PP_Bool (*IsVideoDecoder)(PP_Resource resource); int32_t (*Initialize)(PP_Resource video_decoder, PP_Resource graphics3d_context, PP_VideoProfile profile, PP_HardwareAcceleration acceleration, struct PP_CompletionCallback callback); int32_t (*Decode)(PP_Resource video_decoder, uint32_t decode_id, uint32_t size, const void* buffer, struct PP_CompletionCallback callback); int32_t (*GetPicture)(PP_Resource video_decoder, struct PP_VideoPicture_0_1* picture, struct PP_CompletionCallback callback); void (*RecyclePicture)(PP_Resource video_decoder, const struct PP_VideoPicture* picture); int32_t (*Flush)(PP_Resource video_decoder, struct PP_CompletionCallback callback); int32_t (*Reset)(PP_Resource video_decoder, struct PP_CompletionCallback callback); }; struct PPB_VideoDecoder_1_0 { PP_Resource (*Create)(PP_Instance instance); PP_Bool (*IsVideoDecoder)(PP_Resource resource); int32_t (*Initialize)(PP_Resource video_decoder, PP_Resource graphics3d_context, PP_VideoProfile profile, PP_HardwareAcceleration acceleration, struct PP_CompletionCallback callback); int32_t (*Decode)(PP_Resource video_decoder, uint32_t decode_id, uint32_t size, const void* buffer, struct PP_CompletionCallback callback); int32_t (*GetPicture)(PP_Resource video_decoder, struct PP_VideoPicture* picture, struct PP_CompletionCallback callback); void (*RecyclePicture)(PP_Resource video_decoder, const struct PP_VideoPicture* picture); int32_t (*Flush)(PP_Resource video_decoder, struct PP_CompletionCallback callback); int32_t (*Reset)(PP_Resource video_decoder, struct PP_CompletionCallback callback); }; /** * @} */ #endif /* PPAPI_C_PPB_VIDEO_DECODER_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_video_encoder.h000066400000000000000000000302501321746453100242160ustar00rootroot00000000000000/* Copyright 2015 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_video_encoder.idl modified Wed Jul 15 11:34:20 2015. */ #ifndef PPAPI_C_PPB_VIDEO_ENCODER_H_ #define PPAPI_C_PPB_VIDEO_ENCODER_H_ #include "ppapi/c/pp_array_output.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_codecs.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/ppb_video_frame.h" #define PPB_VIDEOENCODER_INTERFACE_0_1 "PPB_VideoEncoder;0.1" /* dev */ #define PPB_VIDEOENCODER_INTERFACE_0_2 "PPB_VideoEncoder;0.2" #define PPB_VIDEOENCODER_INTERFACE PPB_VIDEOENCODER_INTERFACE_0_2 /** * @file * This file defines the PPB_VideoEncoder interface. */ /** * @addtogroup Interfaces * @{ */ /** * Video encoder interface. * * Typical usage: * - Call Create() to create a new video encoder resource. * - Call GetSupportedFormats() to determine which codecs and profiles are * available. * - Call Initialize() to initialize the encoder for a supported profile. * - Call GetVideoFrame() to get a blank frame and fill it in, or get a video * frame from another resource, e.g. PPB_MediaStreamVideoTrack. * - Call Encode() to push the video frame to the encoder. If an external frame * is pushed, wait for completion to recycle the frame. * - Call GetBitstreamBuffer() continuously (waiting for each previous call to * complete) to pull encoded pictures from the encoder. * - Call RecycleBitstreamBuffer() after consuming the data in the bitstream * buffer. * - To destroy the encoder, the plugin should release all of its references to * it. Any pending callbacks will abort before the encoder is destroyed. * * Available video codecs vary by platform. * All: vp8 (software). * ChromeOS, depending on your device: h264 (hardware), vp8 (hardware) */ struct PPB_VideoEncoder_0_2 { /** * Creates a new video encoder resource. * * @param[in] instance A PP_Instance identifying the instance * with the video encoder. * * @return A PP_Resource corresponding to a video encoder if * successful or 0 otherwise. */ PP_Resource (*Create)(PP_Instance instance); /** * Determines if the given resource is a video encoder. * * @param[in] resource A PP_Resource identifying a resource. * * @return PP_TRUE if the resource is a * PPB_VideoEncoder, PP_FALSE if the resource is * invalid or some other type. */ PP_Bool (*IsVideoEncoder)(PP_Resource resource); /** * Gets an array of supported video encoder profiles. * These can be used to choose a profile before calling Initialize(). * * @param[in] video_encoder A PP_Resource identifying the video * encoder. * @param[in] output A PP_ArrayOutput to receive the supported * PP_VideoProfileDescription structs. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return If >= 0, the number of supported profiles returned, otherwise an * error code from pp_errors.h. */ int32_t (*GetSupportedProfiles)(PP_Resource video_encoder, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); /** * Initializes a video encoder resource. The plugin should call Initialize() * successfully before calling any of the functions below. * * @param[in] video_encoder A PP_Resource identifying the video * encoder. * @param[in] input_format The PP_VideoFrame_Format of the * frames which will be encoded. * @param[in] input_visible_size A PP_Size specifying the * dimensions of the visible part of the input frames. * @param[in] output_profile A PP_VideoProfile specifying the * codec profile of the encoded output stream. * @param[in] acceleration A PP_HardwareAcceleration specifying * whether to use a hardware accelerated or a software implementation. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h. * Returns PP_ERROR_NOTSUPPORTED if video encoding is not available, or the * requested codec profile is not supported. */ int32_t (*Initialize)(PP_Resource video_encoder, PP_VideoFrame_Format input_format, const struct PP_Size* input_visible_size, PP_VideoProfile output_profile, uint32_t initial_bitrate, PP_HardwareAcceleration acceleration, struct PP_CompletionCallback callback); /** * Gets the number of input video frames that the encoder may hold while * encoding. If the plugin is providing the video frames, it should have at * least this many available. * * @param[in] video_encoder A PP_Resource identifying the video * encoder. * @return An int32_t containing the number of frames required, or an error * code from pp_errors.h. * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. */ int32_t (*GetFramesRequired)(PP_Resource video_encoder); /** * Gets the coded size of the video frames required by the encoder. Coded * size is the logical size of the input frames, in pixels. The encoder may * have hardware alignment requirements that make this different from * |input_visible_size|, as requested in the call to Initialize(). * * @param[in] video_encoder A PP_Resource identifying the video * encoder. * @param[in] coded_size A PP_Size to hold the coded size. * @return An int32_t containing a result code from pp_errors.h. * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. */ int32_t (*GetFrameCodedSize)(PP_Resource video_encoder, struct PP_Size* coded_size); /** * Gets a blank video frame which can be filled with video data and passed * to the encoder. * * @param[in] video_encoder A PP_Resource identifying the video * encoder. * @param[out] video_frame A blank PPB_VideoFrame resource. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An int32_t containing an error code from pp_errors.h. * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. */ int32_t (*GetVideoFrame)(PP_Resource video_encoder, PP_Resource* video_frame, struct PP_CompletionCallback callback); /** * Encodes a video frame. * * @param[in] video_encoder A PP_Resource identifying the video * encoder. * @param[in] video_frame The PPB_VideoFrame to be encoded. * @param[in] force_keyframe A PP_Bool> specifying whether the encoder * should emit a key frame for this video frame. * @param[in] callback A PP_CompletionCallback to be called upon * completion. Plugins that pass PPB_VideoFrame resources owned * by other resources should wait for completion before reusing them. * * @return An int32_t containing an error code from pp_errors.h. * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. */ int32_t (*Encode)(PP_Resource video_encoder, PP_Resource video_frame, PP_Bool force_keyframe, struct PP_CompletionCallback callback); /** * Gets the next encoded bitstream buffer from the encoder. * * @param[in] video_encoder A PP_Resource identifying the video * encoder. * @param[out] bitstream_buffer A PP_BitstreamBuffer containing * encoded video data. * @param[in] callback A PP_CompletionCallback to be called upon * completion. The plugin can call GetBitstreamBuffer from the callback in * order to continuously "pull" bitstream buffers from the encoder. * * @return An int32_t containing an error code from pp_errors.h. * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. * Returns PP_ERROR_INPROGRESS if a prior call to GetBitstreamBuffer() has * not completed. */ int32_t (*GetBitstreamBuffer)(PP_Resource video_encoder, struct PP_BitstreamBuffer* bitstream_buffer, struct PP_CompletionCallback callback); /** * Recycles a bitstream buffer back to the encoder. * * @param[in] video_encoder A PP_Resource identifying the video * encoder. * @param[in] bitstream_buffer A PP_BitstreamBuffer that is no * longer needed by the plugin. */ void (*RecycleBitstreamBuffer)( PP_Resource video_encoder, const struct PP_BitstreamBuffer* bitstream_buffer); /** * Requests a change to encoding parameters. This is only a request, * fulfilled on a best-effort basis. * * @param[in] video_encoder A PP_Resource identifying the video * encoder. * @param[in] bitrate The requested new bitrate, in bits per second. * @param[in] framerate The requested new framerate, in frames per second. */ void (*RequestEncodingParametersChange)(PP_Resource video_encoder, uint32_t bitrate, uint32_t framerate); /** * Closes the video encoder, and cancels any pending encodes. Any pending * callbacks will still run, reporting PP_ERROR_ABORTED . It is * not valid to call any encoder functions after a call to this method. * Note: Destroying the video encoder closes it implicitly, * so you are not required to call Close(). * * @param[in] video_encoder A PP_Resource identifying the video * encoder. */ void (*Close)(PP_Resource video_encoder); }; typedef struct PPB_VideoEncoder_0_2 PPB_VideoEncoder; struct PPB_VideoEncoder_0_1 { /* dev */ PP_Resource (*Create)(PP_Instance instance); PP_Bool (*IsVideoEncoder)(PP_Resource resource); int32_t (*GetSupportedProfiles)(PP_Resource video_encoder, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); int32_t (*Initialize)(PP_Resource video_encoder, PP_VideoFrame_Format input_format, const struct PP_Size* input_visible_size, PP_VideoProfile output_profile, uint32_t initial_bitrate, PP_HardwareAcceleration acceleration, struct PP_CompletionCallback callback); int32_t (*GetFramesRequired)(PP_Resource video_encoder); int32_t (*GetFrameCodedSize)(PP_Resource video_encoder, struct PP_Size* coded_size); int32_t (*GetVideoFrame)(PP_Resource video_encoder, PP_Resource* video_frame, struct PP_CompletionCallback callback); int32_t (*Encode)(PP_Resource video_encoder, PP_Resource video_frame, PP_Bool force_keyframe, struct PP_CompletionCallback callback); int32_t (*GetBitstreamBuffer)(PP_Resource video_encoder, struct PP_BitstreamBuffer* bitstream_buffer, struct PP_CompletionCallback callback); void (*RecycleBitstreamBuffer)( PP_Resource video_encoder, const struct PP_BitstreamBuffer* bitstream_buffer); void (*RequestEncodingParametersChange)(PP_Resource video_encoder, uint32_t bitrate, uint32_t framerate); void (*Close)(PP_Resource video_encoder); }; /** * @} */ #endif /* PPAPI_C_PPB_VIDEO_ENCODER_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_video_frame.h000066400000000000000000000072371321746453100237020ustar00rootroot00000000000000/* Copyright 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_video_frame.idl modified Tue Mar 25 18:28:57 2014. */ #ifndef PPAPI_C_PPB_VIDEO_FRAME_H_ #define PPAPI_C_PPB_VIDEO_FRAME_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" #define PPB_VIDEOFRAME_INTERFACE_0_1 "PPB_VideoFrame;0.1" #define PPB_VIDEOFRAME_INTERFACE PPB_VIDEOFRAME_INTERFACE_0_1 /** * @file * Defines the PPB_VideoFrame interface. */ /** * @addtogroup Enums * @{ */ typedef enum { /** * Unknown format value. */ PP_VIDEOFRAME_FORMAT_UNKNOWN = 0, /** * 12bpp YVU planar 1x1 Y, 2x2 VU samples. */ PP_VIDEOFRAME_FORMAT_YV12 = 1, /** * 12bpp YUV planar 1x1 Y, 2x2 UV samples. */ PP_VIDEOFRAME_FORMAT_I420 = 2, /** * 32bpp BGRA. */ PP_VIDEOFRAME_FORMAT_BGRA = 3, /** * The last format. */ PP_VIDEOFRAME_FORMAT_LAST = PP_VIDEOFRAME_FORMAT_BGRA } PP_VideoFrame_Format; /** * @} */ /** * @addtogroup Interfaces * @{ */ struct PPB_VideoFrame_0_1 { /** * Determines if a resource is a VideoFrame resource. * * @param[in] resource The PP_Resource to test. * * @return A PP_Bool with PP_TRUE if the given * resource is a VideoFrame resource or PP_FALSE otherwise. */ PP_Bool (*IsVideoFrame)(PP_Resource resource); /** * Gets the timestamp of the video frame. * * @param[in] frame A PP_Resource corresponding to a video frame * resource. * * @return A PP_TimeDelta containing the timestamp of the video * frame. Given in seconds since the start of the containing video stream. */ PP_TimeDelta (*GetTimestamp)(PP_Resource frame); /** * Sets the timestamp of the video frame. Given in seconds since the * start of the containing video stream. * * @param[in] frame A PP_Resource corresponding to a video frame * resource. * @param[in] timestamp A PP_TimeDelta containing the timestamp * of the video frame. Given in seconds since the start of the containing * video stream. */ void (*SetTimestamp)(PP_Resource frame, PP_TimeDelta timestamp); /** * Gets the format of the video frame. * * @param[in] frame A PP_Resource corresponding to a video frame * resource. * * @return A PP_VideoFrame_Format containing the format of the * video frame. */ PP_VideoFrame_Format (*GetFormat)(PP_Resource frame); /** * Gets the size of the video frame. * * @param[in] frame A PP_Resource corresponding to a video frame * resource. * @param[out] size A PP_Size. * * @return A PP_Bool with PP_TRUE on success or * PP_FALSE on failure. */ PP_Bool (*GetSize)(PP_Resource frame, struct PP_Size* size); /** * Gets the data buffer for video frame pixels. * * @param[in] frame A PP_Resource corresponding to a video frame * resource. * * @return A pointer to the beginning of the data buffer. */ void* (*GetDataBuffer)(PP_Resource frame); /** * Gets the size of data buffer. * * @param[in] frame A PP_Resource corresponding to a video frame * resource. * * @return The size of the data buffer. */ uint32_t (*GetDataBufferSize)(PP_Resource frame); }; typedef struct PPB_VideoFrame_0_1 PPB_VideoFrame; /** * @} */ #endif /* PPAPI_C_PPB_VIDEO_FRAME_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_view.h000066400000000000000000000237121321746453100223700ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_view.idl modified Fri Sep 5 11:32:22 2014. */ #ifndef PPAPI_C_PPB_VIEW_H_ #define PPAPI_C_PPB_VIEW_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #define PPB_VIEW_INTERFACE_1_0 "PPB_View;1.0" #define PPB_VIEW_INTERFACE_1_1 "PPB_View;1.1" #define PPB_VIEW_INTERFACE_1_2 "PPB_View;1.2" #define PPB_VIEW_INTERFACE PPB_VIEW_INTERFACE_1_2 /** * @file * This file defines the PPB_View struct representing the state * of the view of an instance. */ /** * @addtogroup Interfaces * @{ */ /** * PPB_View represents the state of the view of an instance. * You will receive new view information using * PPP_Instance.DidChangeView. */ struct PPB_View_1_2 { /** * IsView() determines if the given resource is a valid * PPB_View resource. Note that PPB_ViewChanged * resources derive from PPB_View and will return true here * as well. * * @param resource A PP_Resource corresponding to a * PPB_View resource. * * @return PP_TRUE if the given resource supports * PPB_View or PP_FALSE if it is an invalid * resource or is a resource of another type. */ PP_Bool (*IsView)(PP_Resource resource); /** * GetRect() retrieves the rectangle of the module instance associated * with a view changed notification relative to the upper-left of the browser * viewport. This position changes when the page is scrolled. * * The returned rectangle may not be inside the visible portion of the * viewport if the module instance is scrolled off the page. Therefore, the * position may be negative or larger than the size of the page. The size will * always reflect the size of the module were it to be scrolled entirely into * view. * * In general, most modules will not need to worry about the position of the * module instance in the viewport, and only need to use the size. * * @param resource A PP_Resource corresponding to a * PPB_View resource. * * @param rect A PP_Rect receiving the rectangle on success. * * @return Returns PP_TRUE if the resource was valid and the * viewport rectangle was filled in, PP_FALSE if not. */ PP_Bool (*GetRect)(PP_Resource resource, struct PP_Rect* rect); /** * IsFullscreen() returns whether the instance is currently * displaying in fullscreen mode. * * @param resource A PP_Resource corresponding to a * PPB_View resource. * * @return PP_TRUE if the instance is in full screen mode, * or PP_FALSE if it's not or the resource is invalid. */ PP_Bool (*IsFullscreen)(PP_Resource resource); /** * IsVisible() determines whether the module instance might be visible to * the user. For example, the Chrome window could be minimized or another * window could be over it. In both of these cases, the module instance * would not be visible to the user, but IsVisible() will return true. * * Use the result to speed up or stop updates for invisible module * instances. * * This function performs the duties of GetRect() (determining whether the * module instance is scrolled into view and the clip rectangle is nonempty) * and IsPageVisible() (whether the page is visible to the user). * * @param resource A PP_Resource corresponding to a * PPB_View resource. * * @return PP_TRUE if the instance might be visible to the * user, PP_FALSE if it is definitely not visible. */ PP_Bool (*IsVisible)(PP_Resource resource); /** * IsPageVisible() determines if the page that contains the module instance * is visible. The most common cause of invisible pages is that * the page is in a background tab in the browser. * * Most applications should use IsVisible() instead of this function since * the module instance could be scrolled off of a visible page, and this * function will still return true. However, depending on how your module * interacts with the page, there may be certain updates that you may want to * perform when the page is visible even if your specific module instance is * not visible. * * @param resource A PP_Resource corresponding to a * PPB_View resource. * * @return PP_TRUE if the instance is plausibly visible to the * user, PP_FALSE if it is definitely not visible. */ PP_Bool (*IsPageVisible)(PP_Resource resource); /** * GetClipRect() returns the clip rectangle relative to the upper-left corner * of the module instance. This rectangle indicates the portions of the module * instance that are scrolled into view. * * If the module instance is scrolled off the view, the return value will be * (0, 0, 0, 0). This clip rectangle does not take into account page * visibility. Therefore, if the module instance is scrolled into view, but * the page itself is on a tab that is not visible, the return rectangle will * contain the visible rectangle as though the page were visible. Refer to * IsPageVisible() and IsVisible() if you want to account for page * visibility. * * Most applications will not need to worry about the clip rectangle. The * recommended behavior is to do full updates if the module instance is * visible, as determined by IsVisible(), and do no updates if it is not * visible. * * However, if the cost for computing pixels is very high for your * application, or the pages you're targeting frequently have very large * module instances with small visible portions, you may wish to optimize * further. In this case, the clip rectangle will tell you which parts of * the module to update. * * Note that painting of the page and sending of view changed updates * happens asynchronously. This means when the user scrolls, for example, * it is likely that the previous backing store of the module instance will * be used for the first paint, and will be updated later when your * application generates new content with the new clip. This may cause * flickering at the boundaries when scrolling. If you do choose to do * partial updates, you may want to think about what color the invisible * portions of your backing store contain (be it transparent or some * background color) or to paint a certain region outside the clip to reduce * the visual distraction when this happens. * * @param resource A PP_Resource corresponding to a * PPB_View resource. * * @param clip Output argument receiving the clip rect on success. * * @return Returns PP_TRUE if the resource was valid and the * clip rect was filled in, PP_FALSE if not. */ PP_Bool (*GetClipRect)(PP_Resource resource, struct PP_Rect* clip); /** * GetDeviceScale returns the scale factor between device pixels and Density * Independent Pixels (DIPs, also known as logical pixels or UI pixels on * some platforms). This allows the developer to render their contents at * device resolution, even as coordinates / sizes are given in DIPs through * the API. * * Note that the coordinate system for Pepper APIs is DIPs. Also note that * one DIP might not equal one CSS pixel - when page scale/zoom is in effect. * * @param[in] resource A PP_Resource corresponding to a * PPB_View resource. * * @return A float value representing the number of device pixels * per DIP. If the resource is invalid, the value will be 0.0. */ float (*GetDeviceScale)(PP_Resource resource); /** * GetCSSScale returns the scale factor between DIPs and CSS pixels. This * allows proper scaling between DIPs - as sent via the Pepper API - and CSS * pixel coordinates used for Web content. * * @param[in] resource A PP_Resource corresponding to a * PPB_View resource. * * @return css_scale A float value representing the number of * DIPs per CSS pixel. If the resource is invalid, the value will be 0.0. */ float (*GetCSSScale)(PP_Resource resource); /** * GetScrollOffset returns the scroll offset of the window containing the * plugin. * * @param[in] resource A PP_Resource corresponding to a * PPB_View resource. * * @param[out] offset A PP_Point which will be set to the value * of the scroll offset in CSS pixels. * * @return Returns PP_TRUE if the resource was valid and the * offset was filled in, PP_FALSE if not. */ PP_Bool (*GetScrollOffset)(PP_Resource resource, struct PP_Point* offset); }; typedef struct PPB_View_1_2 PPB_View; struct PPB_View_1_0 { PP_Bool (*IsView)(PP_Resource resource); PP_Bool (*GetRect)(PP_Resource resource, struct PP_Rect* rect); PP_Bool (*IsFullscreen)(PP_Resource resource); PP_Bool (*IsVisible)(PP_Resource resource); PP_Bool (*IsPageVisible)(PP_Resource resource); PP_Bool (*GetClipRect)(PP_Resource resource, struct PP_Rect* clip); }; struct PPB_View_1_1 { PP_Bool (*IsView)(PP_Resource resource); PP_Bool (*GetRect)(PP_Resource resource, struct PP_Rect* rect); PP_Bool (*IsFullscreen)(PP_Resource resource); PP_Bool (*IsVisible)(PP_Resource resource); PP_Bool (*IsPageVisible)(PP_Resource resource); PP_Bool (*GetClipRect)(PP_Resource resource, struct PP_Rect* clip); float (*GetDeviceScale)(PP_Resource resource); float (*GetCSSScale)(PP_Resource resource); }; /** * @} */ #endif /* PPAPI_C_PPB_VIEW_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppb_websocket.h000066400000000000000000000420611321746453100234020ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppb_websocket.idl modified Thu May 31 15:47:38 2012. */ #ifndef PPAPI_C_PPB_WEBSOCKET_H_ #define PPAPI_C_PPB_WEBSOCKET_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_WEBSOCKET_INTERFACE_1_0 "PPB_WebSocket;1.0" #define PPB_WEBSOCKET_INTERFACE PPB_WEBSOCKET_INTERFACE_1_0 /** * @file * This file defines the PPB_WebSocket interface providing * bi-directional, full-duplex, communications over a single TCP socket. */ /** * @addtogroup Enums * @{ */ /** * This enumeration contains the types representing the WebSocket ready state * and these states are based on the JavaScript WebSocket API specification. * GetReadyState() returns one of these states. */ typedef enum { /** * Ready state is queried on an invalid resource. */ PP_WEBSOCKETREADYSTATE_INVALID = -1, /** * Ready state that the connection has not yet been established. */ PP_WEBSOCKETREADYSTATE_CONNECTING = 0, /** * Ready state that the WebSocket connection is established and communication * is possible. */ PP_WEBSOCKETREADYSTATE_OPEN = 1, /** * Ready state that the connection is going through the closing handshake. */ PP_WEBSOCKETREADYSTATE_CLOSING = 2, /** * Ready state that the connection has been closed or could not be opened. */ PP_WEBSOCKETREADYSTATE_CLOSED = 3 } PP_WebSocketReadyState; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_WebSocketReadyState, 4); /** * This enumeration contains status codes. These codes are used in Close() and * GetCloseCode(). Refer to RFC 6455, The WebSocket Protocol, for further * information. * PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE and codes in the range * PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MIN to * PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MAX, and * PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MIN to * PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MAX are valid for Close(). */ typedef enum { /** * Indicates to request closing connection without status code and reason. * * (Note that the code 1005 is forbidden to send in actual close frames by * the RFC. PP_WebSocket reuses this code internally and the code will never * appear in the actual close frames.) */ PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED = 1005, /** * Status codes in the range 0-999 are not used. */ /** * Indicates a normal closure. */ PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE = 1000, /** * Indicates that an endpoint is "going away", such as a server going down. */ PP_WEBSOCKETSTATUSCODE_GOING_AWAY = 1001, /** * Indicates that an endpoint is terminating the connection due to a protocol * error. */ PP_WEBSOCKETSTATUSCODE_PROTOCOL_ERROR = 1002, /** * Indicates that an endpoint is terminating the connection because it has * received a type of data it cannot accept. */ PP_WEBSOCKETSTATUSCODE_UNSUPPORTED_DATA = 1003, /** * Status code 1004 is reserved. */ /** * Pseudo code to indicate that receiving close frame doesn't contain any * status code. */ PP_WEBSOCKETSTATUSCODE_NO_STATUS_RECEIVED = 1005, /** * Pseudo code to indicate that connection was closed abnormally, e.g., * without closing handshake. */ PP_WEBSOCKETSTATUSCODE_ABNORMAL_CLOSURE = 1006, /** * Indicates that an endpoint is terminating the connection because it has * received data within a message that was not consistent with the type of * the message (e.g., non-UTF-8 data within a text message). */ PP_WEBSOCKETSTATUSCODE_INVALID_FRAME_PAYLOAD_DATA = 1007, /** * Indicates that an endpoint is terminating the connection because it has * received a message that violates its policy. */ PP_WEBSOCKETSTATUSCODE_POLICY_VIOLATION = 1008, /** * Indicates that an endpoint is terminating the connection because it has * received a message that is too big for it to process. */ PP_WEBSOCKETSTATUSCODE_MESSAGE_TOO_BIG = 1009, /** * Indicates that an endpoint (client) is terminating the connection because * it has expected the server to negotiate one or more extension, but the * server didn't return them in the response message of the WebSocket * handshake. */ PP_WEBSOCKETSTATUSCODE_MANDATORY_EXTENSION = 1010, /** * Indicates that a server is terminating the connection because it * encountered an unexpected condition. */ PP_WEBSOCKETSTATUSCODE_INTERNAL_SERVER_ERROR = 1011, /** * Status codes in the range 1012-1014 are reserved. */ /** * Pseudo code to indicate that the connection was closed due to a failure to * perform a TLS handshake. */ PP_WEBSOCKETSTATUSCODE_TLS_HANDSHAKE = 1015, /** * Status codes in the range 1016-2999 are reserved. */ /** * Status codes in the range 3000-3999 are reserved for use by libraries, * frameworks, and applications. These codes are registered directly with * IANA. */ PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MIN = 3000, PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MAX = 3999, /** * Status codes in the range 4000-4999 are reserved for private use. * Application can use these codes for application specific purposes freely. */ PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MIN = 4000, PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MAX = 4999 } PP_WebSocketCloseCode; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_WebSocketCloseCode, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_WebSocket interface provides bi-directional, * full-duplex, communications over a single TCP socket. */ struct PPB_WebSocket_1_0 { /** * Create() creates a WebSocket instance. * * @param[in] instance A PP_Instance identifying the instance * with the WebSocket. * * @return A PP_Resource corresponding to a WebSocket if * successful. */ PP_Resource (*Create)(PP_Instance instance); /** * IsWebSocket() determines if the provided resource is a * WebSocket instance. * * @param[in] resource A PP_Resource corresponding to a * WebSocket. * * @return Returns PP_TRUE if resource is a * PPB_WebSocket, PP_FALSE if the * resource is invalid or some type other than * PPB_WebSocket. */ PP_Bool (*IsWebSocket)(PP_Resource resource); /** * Connect() connects to the specified WebSocket server. You can call this * function once for a web_socket. * * @param[in] web_socket A PP_Resource corresponding to a * WebSocket. * * @param[in] url A PP_Var representing a WebSocket server URL. * The PP_VarType must be PP_VARTYPE_STRING. * * @param[in] protocols A pointer to an array of PP_Var * specifying sub-protocols. Each PP_Var represents one * sub-protocol and its PP_VarType must be * PP_VARTYPE_STRING. This argument can be null only if * protocol_count is 0. * * @param[in] protocol_count The number of sub-protocols in * protocols. * * @param[in] callback A PP_CompletionCallback called * when a connection is established or an error occurs in establishing * connection. * * @return An int32_t containing an error code from pp_errors.h. * Returns PP_ERROR_BADARGUMENT if the specified * url, or protocols contain an invalid string as * defined in the WebSocket API specification. * PP_ERROR_BADARGUMENT corresponds to a SyntaxError in the * WebSocket API specification. * Returns PP_ERROR_NOACCESS if the protocol specified in the * url is not a secure protocol, but the origin of the caller * has a secure scheme. Also returns PP_ERROR_NOACCESS if the * port specified in the url is a port that the user agent * is configured to block access to because it is a well-known port like * SMTP. PP_ERROR_NOACCESS corresponds to a SecurityError of the * specification. * Returns PP_ERROR_INPROGRESS if this is not the first call to * Connect(). */ int32_t (*Connect)(PP_Resource web_socket, struct PP_Var url, const struct PP_Var protocols[], uint32_t protocol_count, struct PP_CompletionCallback callback); /** * Close() closes the specified WebSocket connection by specifying * code and reason. * * @param[in] web_socket A PP_Resource corresponding to a * WebSocket. * * @param[in] code The WebSocket close code. This is ignored if it is * PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED. * PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE must be used for the * usual case. To indicate some specific error cases, codes in the range * PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MIN to * PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MAX, and in the range * PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MIN to * PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MAX are available. * * @param[in] reason A PP_Var representing the WebSocket * close reason. This is ignored if it is PP_VARTYPE_UNDEFINED. * Otherwise, its PP_VarType must be * PP_VARTYPE_STRING. * * @param[in] callback A PP_CompletionCallback called * when the connection is closed or an error occurs in closing the * connection. * * @return An int32_t containing an error code from pp_errors.h. * Returns PP_ERROR_BADARGUMENT if reason contains * an invalid character as a UTF-8 string, or is longer than 123 bytes. * PP_ERROR_BADARGUMENT corresponds to a JavaScript SyntaxError * in the WebSocket API specification. * Returns PP_ERROR_NOACCESS if the code is not an integer * equal to 1000 or in the range 3000 to 4999. PP_ERROR_NOACCESS * corresponds to an InvalidAccessError in the WebSocket API specification. * Returns PP_ERROR_INPROGRESS if a previous call to Close() is * not finished. */ int32_t (*Close)(PP_Resource web_socket, uint16_t code, struct PP_Var reason, struct PP_CompletionCallback callback); /** * ReceiveMessage() receives a message from the WebSocket server. * This interface only returns a single message. That is, this interface must * be called at least N times to receive N messages, no matter the size of * each message. * * @param[in] web_socket A PP_Resource corresponding to a * WebSocket. * * @param[out] message The received message is copied to provided * message. The message must remain valid until * ReceiveMessage() completes. Its received PP_VarType will be * PP_VARTYPE_STRING or PP_VARTYPE_ARRAY_BUFFER. * * @param[in] callback A PP_CompletionCallback called * when ReceiveMessage() completes. This callback is ignored if * ReceiveMessage() completes synchronously and returns PP_OK. * * @return An int32_t containing an error code from pp_errors.h. * If an error is detected or connection is closed, ReceiveMessage() returns * PP_ERROR_FAILED after all buffered messages are received. * Until buffered message become empty, ReceiveMessage() continues to return * PP_OK as if connection is still established without errors. */ int32_t (*ReceiveMessage)(PP_Resource web_socket, struct PP_Var* message, struct PP_CompletionCallback callback); /** * SendMessage() sends a message to the WebSocket server. * * @param[in] web_socket A PP_Resource corresponding to a * WebSocket. * * @param[in] message A message to send. The message is copied to an internal * buffer, so the caller can free message safely after returning * from the function. Its sent PP_VarType must be * PP_VARTYPE_STRING or PP_VARTYPE_ARRAY_BUFFER. * * @return An int32_t containing an error code from pp_errors.h. * Returns PP_ERROR_FAILED if the ReadyState is * PP_WEBSOCKETREADYSTATE_CONNECTING. * PP_ERROR_FAILED corresponds to a JavaScript * InvalidStateError in the WebSocket API specification. * Returns PP_ERROR_BADARGUMENT if the provided * message contains an invalid character as a UTF-8 string. * PP_ERROR_BADARGUMENT corresponds to a JavaScript * SyntaxError in the WebSocket API specification. * Otherwise, returns PP_OK, which doesn't necessarily mean * that the server received the message. */ int32_t (*SendMessage)(PP_Resource web_socket, struct PP_Var message); /** * GetBufferedAmount() returns the number of bytes of text and binary * messages that have been queued for the WebSocket connection to send, but * have not been transmitted to the network yet. * * @param[in] web_socket A PP_Resource corresponding to a * WebSocket. * * @return Returns the number of bytes. */ uint64_t (*GetBufferedAmount)(PP_Resource web_socket); /** * GetCloseCode() returns the connection close code for the WebSocket * connection. * * @param[in] web_socket A PP_Resource corresponding to a * WebSocket. * * @return Returns 0 if called before the close code is set. */ uint16_t (*GetCloseCode)(PP_Resource web_socket); /** * GetCloseReason() returns the connection close reason for the WebSocket * connection. * * @param[in] web_socket A PP_Resource corresponding to a * WebSocket. * * @return Returns a PP_VARTYPE_STRING var. If called before the * close reason is set, the return value contains an empty string. Returns a * PP_VARTYPE_UNDEFINED if called on an invalid resource. */ struct PP_Var (*GetCloseReason)(PP_Resource web_socket); /** * GetCloseWasClean() returns if the connection was closed cleanly for the * specified WebSocket connection. * * @param[in] web_socket A PP_Resource corresponding to a * WebSocket. * * @return Returns PP_FALSE if called before the connection is * closed, called on an invalid resource, or closed for abnormal reasons. * Otherwise, returns PP_TRUE if the connection was closed * cleanly. */ PP_Bool (*GetCloseWasClean)(PP_Resource web_socket); /** * GetExtensions() returns the extensions selected by the server for the * specified WebSocket connection. * * @param[in] web_socket A PP_Resource corresponding to a * WebSocket. * * @return Returns a PP_VARTYPE_STRING var. If called before the * connection is established, the var's data is an empty string. Returns a * PP_VARTYPE_UNDEFINED if called on an invalid resource. */ struct PP_Var (*GetExtensions)(PP_Resource web_socket); /** * GetProtocol() returns the sub-protocol chosen by the server for the * specified WebSocket connection. * * @param[in] web_socket A PP_Resource corresponding to a * WebSocket. * * @return Returns a PP_VARTYPE_STRING var. If called before the * connection is established, the var contains the empty string. Returns a * PP_VARTYPE_UNDEFINED if called on an invalid resource. */ struct PP_Var (*GetProtocol)(PP_Resource web_socket); /** * GetReadyState() returns the ready state of the specified WebSocket * connection. * * @param[in] web_socket A PP_Resource corresponding to a * WebSocket. * * @return Returns PP_WEBSOCKETREADYSTATE_INVALID if called * before Connect() is called, or if this function is called on an * invalid resource. */ PP_WebSocketReadyState (*GetReadyState)(PP_Resource web_socket); /** * GetURL() returns the URL associated with specified WebSocket connection. * * @param[in] web_socket A PP_Resource corresponding to a * WebSocket. * * @return Returns a PP_VARTYPE_STRING var. If called before the * connection is established, the var contains the empty string. Returns a * PP_VARTYPE_UNDEFINED if this function is called on an * invalid resource. */ struct PP_Var (*GetURL)(PP_Resource web_socket); }; typedef struct PPB_WebSocket_1_0 PPB_WebSocket; /** * @} */ #endif /* PPAPI_C_PPB_WEBSOCKET_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppp.h000066400000000000000000000106141321746453100213510ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppp.idl modified Mon Feb 11 15:48:41 2013. */ #ifndef PPAPI_C_PPP_H_ #define PPAPI_C_PPP_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/ppb.h" /** * @file * This file defines three functions that your module must * implement to interact with the browser. */ #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/ppb.h" #if __GNUC__ >= 4 #define PP_EXPORT __attribute__ ((visibility("default"))) #elif defined(_MSC_VER) #define PP_EXPORT __declspec(dllexport) #endif /* {PENDING: undefine PP_EXPORT?} */ /* We don't want name mangling for these external functions. We only need * 'extern "C"' if we're compiling with a C++ compiler. */ #ifdef __cplusplus extern "C" { #endif /** * @addtogroup Functions * @{ */ /** * PPP_InitializeModule() is the entry point for a module and is called by the * browser when your module loads. Your code must implement this function. * * Failure indicates to the browser that this module can not be used. In this * case, the module will be unloaded and ShutdownModule will NOT be called. * * @param[in] module A handle to your module. Generally you should store this * value since it will be required for other API calls. * @param[in] get_browser_interface A pointer to the function that you can * use to query for browser interfaces. Generally you should store this value * for future use. * * @return PP_OK on success. Any other value on failure. */ PP_EXPORT int32_t PPP_InitializeModule(PP_Module module, PPB_GetInterface get_browser_interface); /** * @} */ /** * @addtogroup Functions * @{ */ /** * PPP_ShutdownModule() is sometimes called before the module * is unloaded. It is not recommended that you implement this function. * * There is no practical use of this function for third party modules. Its * existence is because of some internal use cases inside Chrome. * * Since your module runs in a separate process, there's no need to free * allocated memory. There is also no need to free any resources since all of * resources associated with an instance will be force-freed when that instance * is deleted. * * Note: This function will always be skipped on untrusted * (Native Client) implementations. This function may be skipped on trusted * implementations in certain circumstances when Chrome does "fast shutdown" * of a web page. */ PP_EXPORT void PPP_ShutdownModule(void); /** * @} */ /** * @addtogroup Functions * @{ */ /** * PPP_GetInterface() is called by the browser to query the module for * interfaces it supports. * * Your module must implement the PPP_Instance interface or it * will be unloaded. Other interfaces are optional. * * This function is called from within browser code whenever an interface is * needed. This means your plugin could be reentered via this function if you * make a browser call and it needs an interface. Furthermore, you should not * make any other browser calls from within your implementation to avoid * reentering the browser. * * As a result, your implementation of this should merely provide a lookup * from the requested name to an interface pointer, via something like a big * if/else block or a map, and not do any other work. * * @param[in] interface_name A pointer to a "PPP" (plugin) interface name. * Interface names are null-terminated ASCII strings. * * @return A pointer for the interface or NULL if the interface is * not supported. */ PP_EXPORT const void* PPP_GetInterface(const char* interface_name); /** * @} */ #ifdef __cplusplus } /* extern "C" */ #endif /** * @addtogroup Typedefs * @{ */ /** * Defines the type of the PPP_InitializeModule function. */ typedef int32_t (*PP_InitializeModule_Func)( PP_Module module, PPB_GetInterface get_browser_interface); /** * Defines the type of the PPP_ShutdownModule function. */ typedef void (*PP_ShutdownModule_Func)(void); /** * Defines the type of the PPP_ShutdownModule function. */ typedef const void* (*PP_GetInterface_Func)(const char* interface_name); /** * @} */ #endif /* PPAPI_C_PPP_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppp_graphics_3d.h000066400000000000000000000021021321746453100236100ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppp_graphics_3d.idl modified Wed Mar 21 17:35:39 2012. */ #ifndef PPAPI_C_PPP_GRAPHICS_3D_H_ #define PPAPI_C_PPP_GRAPHICS_3D_H_ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #define PPP_GRAPHICS_3D_INTERFACE_1_0 "PPP_Graphics_3D;1.0" #define PPP_GRAPHICS_3D_INTERFACE PPP_GRAPHICS_3D_INTERFACE_1_0 /** * @file * Defines the PPP_Graphics3D struct representing a 3D graphics * context within the browser. */ /** * @addtogroup Interfaces * @{ */ /** * PPP_Graphics3D defines the notification interface for a 3D * graphics context. */ struct PPP_Graphics3D_1_0 { /** * Called when the OpenGL ES window is invalidated and needs to be repainted. */ void (*Graphics3DContextLost)(PP_Instance instance); }; typedef struct PPP_Graphics3D_1_0 PPP_Graphics3D; /** * @} */ #endif /* PPAPI_C_PPP_GRAPHICS_3D_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppp_input_event.h000066400000000000000000000063411321746453100237730ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppp_input_event.idl modified Tue Apr 8 15:19:45 2014. */ #ifndef PPAPI_C_PPP_INPUT_EVENT_H_ #define PPAPI_C_PPP_INPUT_EVENT_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPP_INPUT_EVENT_INTERFACE_0_1 "PPP_InputEvent;0.1" #define PPP_INPUT_EVENT_INTERFACE PPP_INPUT_EVENT_INTERFACE_0_1 /** * @file * This file defines the API for receiving input events from the browser. */ /** * @addtogroup Interfaces * @{ */ struct PPP_InputEvent_0_1 { /** * Function for receiving input events from the browser. * * In order to receive input events, you must register for them by calling * PPB_InputEvent.RequestInputEvents() or RequestFilteringInputEvents(). By * default, no events are delivered. * * If the event was handled, it will not be forwarded to the default handlers * in the web page. If it was not handled, it may be dispatched to a default * handler. So it is important that an instance respond accurately with * whether event propagation should continue. * * Event propagation also controls focus. If you handle an event like a mouse * event, typically the instance will be given focus. Returning false from * a filtered event handler or not registering for an event type means that * the click will be given to a lower part of the page and your instance will * not receive focus. This allows an instance to be partially transparent, * where clicks on the transparent areas will behave like clicks to the * underlying page. * * In general, you should try to keep input event handling short. Especially * for filtered input events, the browser or page may be blocked waiting for * you to respond. * * The caller of this function will maintain a reference to the input event * resource during this call. Unless you take a reference to the resource * to hold it for later, you don't need to release it. * * Note: If you're not receiving input events, make sure you * register for the event classes you want by calling RequestInputEvents or * RequestFilteringInputEvents. If you're still not receiving keyboard input * events, make sure you're returning true (or using a non-filtered event * handler) for mouse events. Otherwise, the instance will not receive focus * and keyboard events will not be sent. * * \see PPB_InputEvent.RequestInputEvents and * PPB_InputEvent.RequestFilteringInputEvents * * @return PP_TRUE if the event was handled, PP_FALSE if not. If you have * registered to filter this class of events by calling * RequestFilteringInputEvents, and you return PP_FALSE, the event will * be forwarded to the page (and eventually the browser) for the default * handling. For non-filtered events, the return value will be ignored. */ PP_Bool (*HandleInputEvent)(PP_Instance instance, PP_Resource input_event); }; typedef struct PPP_InputEvent_0_1 PPP_InputEvent; /** * @} */ #endif /* PPAPI_C_PPP_INPUT_EVENT_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppp_instance.h000066400000000000000000000211421321746453100232330ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppp_instance.idl modified Thu Apr 25 13:07:47 2013. */ #ifndef PPAPI_C_PPP_INSTANCE_H_ #define PPAPI_C_PPP_INSTANCE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #define PPP_INSTANCE_INTERFACE_1_0 "PPP_Instance;1.0" #define PPP_INSTANCE_INTERFACE_1_1 "PPP_Instance;1.1" #define PPP_INSTANCE_INTERFACE PPP_INSTANCE_INTERFACE_1_1 /** * @file * This file defines the PPP_Instance structure - a series of * pointers to methods that you must implement in your module. */ /** * @addtogroup Interfaces * @{ */ /** * The PPP_Instance interface contains pointers to a series of * functions that you must implement in your module. These functions can be * trivial (simply return the default return value) unless you want your module * to handle events such as change of focus or input events (keyboard/mouse) * events. */ struct PPP_Instance_1_1 { /** * DidCreate() is a creation handler that is called when a new instance is * created. This function is called for each instantiation on the page, * corresponding to one \ tag on the page. * * Generally you would handle this call by initializing the information * your module associates with an instance and creating a mapping from the * given PP_Instance handle to this data. The * PP_Instance handle will be used in subsequent calls to * identify which instance the call pertains to. * * It's possible for more than one instance to be created in a single module. * This means that you may get more than one OnCreate without an * OnDestroy in between, and should be prepared to maintain * multiple states associated with each instance. * * If this function reports a failure (by returning PP_FALSE), * the instance will be deleted. * * @param[in] instance A new PP_Instance identifying one * instance of a module. This is an opaque handle. * * @param[in] argc The number of arguments contained in argn * and argv. * * @param[in] argn An array of argument names. These argument names are * supplied in the \ tag, for example: * \ will produce two * argument names: "id" and "dimensions." * * @param[in] argv An array of argument values. These are the values of the * arguments listed in the \ tag, for example * \ will produce two * argument values: "nacl_module" and "2". The indices of these values match * the indices of the corresponding names in argn. * * @return PP_TRUE on success or PP_FALSE on * failure. */ PP_Bool (*DidCreate)(PP_Instance instance, uint32_t argc, const char* argn[], const char* argv[]); /** * DidDestroy() is an instance destruction handler. This function is called * in many cases (see below) when a module instance is destroyed. It will be * called even if DidCreate() returned failure. * * Generally you will handle this call by deallocating the tracking * information and the PP_Instance mapping you created in the * DidCreate() call. You can also free resources associated with this * instance but this isn't required; all resources associated with the deleted * instance will be automatically freed when this function returns. * * The instance identifier will still be valid during this call, so the module * can perform cleanup-related tasks. Once this function returns, the * PP_Instance handle will be invalid. This means that you can't * do any asynchronous operations like network requests, file writes or * messaging from this function since they will be immediately canceled. * * Note: This function will always be skipped on untrusted * (Native Client) implementations. This function may be skipped on trusted * implementations in certain circumstances when Chrome does "fast shutdown" * of a web page. Fast shutdown will happen in some cases when all module * instances are being deleted, and no cleanup functions will be called. * The module will just be unloaded and the process terminated. * * @param[in] instance A PP_Instance identifying one instance * of a module. */ void (*DidDestroy)(PP_Instance instance); /** * DidChangeView() is called when the position, size, or other view * attributes of the instance has changed. */ void (*DidChangeView)(PP_Instance instance, PP_Resource view); /** * DidChangeFocus() is called when an instance has gained or lost focus. * Having focus means that keyboard events will be sent to the instance. * An instance's default condition is that it will not have focus. * * The focus flag takes into account both browser tab and window focus as * well as focus of the plugin element on the page. In order to be deemed * to have focus, the browser window must be topmost, the tab must be * selected in the window, and the instance must be the focused element on * the page. * * Note:Clicks on instances will give focus only if you * handle the click event. Return true from * HandleInputEvent in PPP_InputEvent (or use * unfiltered events) to signal that the click event was handled. Otherwise, * the browser will bubble the event and give focus to the element on the page * that actually did end up consuming it. If you're not getting focus, check * to make sure you're either requesting them via * RequestInputEvents() (which implicitly marks all input events * as consumed) or via RequestFilteringInputEvents() and * returning true from your event handler. * * @param[in] instance A PP_Instance identifying the instance * receiving the input event. * * @param[in] has_focus Indicates the new focused state of the instance. */ void (*DidChangeFocus)(PP_Instance instance, PP_Bool has_focus); /** * HandleDocumentLoad() is called after initialize for a full-frame * instance that was instantiated based on the MIME type of a DOMWindow * navigation. This situation only applies to modules that are pre-registered * to handle certain MIME types. If you haven't specifically registered to * handle a MIME type or aren't positive this applies to you, your * implementation of this function can just return PP_FALSE. * * The given url_loader corresponds to a * PPB_URLLoader instance that is already opened. Its response * headers may be queried using PPB_URLLoader::GetResponseInfo. * The reference count for the URL loader is not incremented automatically on * behalf of the module. You need to increment the reference count yourself * if you are going to keep a reference to it. * * This method returns PP_FALSE if the module cannot handle the * data. In response to this method, the module should call * ReadResponseBody() to read the incoming data. * * @param[in] instance A PP_Instance identifying the instance * that should do the load. * * @param[in] url_loader An open PPB_URLLoader instance. * * @return PP_TRUE if the data was handled, * PP_FALSE otherwise. If you return false, the load will be * canceled for you. */ PP_Bool (*HandleDocumentLoad)(PP_Instance instance, PP_Resource url_loader); }; typedef struct PPP_Instance_1_1 PPP_Instance; struct PPP_Instance_1_0 { PP_Bool (*DidCreate)(PP_Instance instance, uint32_t argc, const char* argn[], const char* argv[]); void (*DidDestroy)(PP_Instance instance); void (*DidChangeView)(PP_Instance instance, const struct PP_Rect* position, const struct PP_Rect* clip); void (*DidChangeFocus)(PP_Instance instance, PP_Bool has_focus); PP_Bool (*HandleDocumentLoad)(PP_Instance instance, PP_Resource url_loader); }; /** * @} */ #endif /* PPAPI_C_PPP_INSTANCE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppp_message_handler.h000066400000000000000000000066531321746453100245620ustar00rootroot00000000000000/* Copyright 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppp_message_handler.idl modified Wed Sep 24 10:48:49 2014. */ #ifndef PPAPI_C_PPP_MESSAGE_HANDLER_H_ #define PPAPI_C_PPP_MESSAGE_HANDLER_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" /** * @file * This file defines the PPP_MessageHandler interface that plugins * can implement and register using PPB_Messaging::RegisterMessageHandler in * order to handle messages sent from JavaScript via postMessage() or * postMessageAndAwaitResponse(). */ /** * @addtogroup Interfaces * @{ */ /** * The PPP_MessageHandler interface is implemented by the plugin * if the plugin wants to receive messages from a thread other than the main * Pepper thread, or if the plugin wants to handle blocking messages which * JavaScript may send via postMessageAndAwaitResponse(). * * This interface struct should not be returned by PPP_GetInterface; instead it * must be passed as a parameter to PPB_Messaging::RegisterMessageHandler. */ struct PPP_MessageHandler_0_2 { /** * Invoked as a result of JavaScript invoking postMessage() on the plugin's * DOM element. * * @param[in] instance A PP_Instance identifying one instance * of a module. * @param[in] user_data is the same pointer which was provided by a call to * RegisterMessageHandler(). * @param[in] message A copy of the parameter that JavaScript provided to * postMessage(). */ void (*HandleMessage)(PP_Instance instance, void* user_data, const struct PP_Var* message); /** * Invoked as a result of JavaScript invoking postMessageAndAwaitResponse() * on the plugin's DOM element. * * NOTE: JavaScript execution is blocked during the duration of this call. * Hence, the plugin should respond as quickly as possible. For this reason, * blocking completion callbacks are disallowed while handling a blocking * message. * * @param[in] instance A PP_Instance identifying one instance * of a module. * @param[in] user_data is the same pointer which was provided by a call to * RegisterMessageHandler(). * @param[in] message is a copy of the parameter that JavaScript provided * to postMessageAndAwaitResponse(). * @param[out] response will be copied to a JavaScript object which is * returned as the result of postMessageAndAwaitResponse() to the invoking * */ void (*HandleBlockingMessage)(PP_Instance instance, void* user_data, const struct PP_Var* message, struct PP_Var* response); /** * Invoked when the handler object is no longer needed. After this, no more * calls will be made which pass this same value for instance * and user_data. * * @param[in] instance A PP_Instance identifying one instance * of a module. * @param[in] user_data is the same pointer which was provided by a call to * RegisterMessageHandler. */ void (*Destroy)(PP_Instance instance, void* user_data); }; typedef struct PPP_MessageHandler_0_2 PPP_MessageHandler; /** * @} */ #endif /* PPAPI_C_PPP_MESSAGE_HANDLER_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppp_messaging.h000066400000000000000000000053161321746453100234110ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppp_messaging.idl modified Wed Jun 5 10:32:43 2013. */ #ifndef PPAPI_C_PPP_MESSAGING_H_ #define PPAPI_C_PPP_MESSAGING_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPP_MESSAGING_INTERFACE_1_0 "PPP_Messaging;1.0" #define PPP_MESSAGING_INTERFACE PPP_MESSAGING_INTERFACE_1_0 /** * @file * This file defines the PPP_Messaging interface containing pointers to * functions that you must implement to handle postMessage messages * on the associated DOM element. * */ /** * @addtogroup Interfaces * @{ */ /** * The PPP_Messaging interface contains pointers to functions * that you must implement to handle postMessage events on the associated * DOM element. */ struct PPP_Messaging_1_0 { /** * HandleMessage() is a function that the browser calls when PostMessage() * is invoked on the DOM element for the module instance in JavaScript. Note * that PostMessage() in the JavaScript interface is asynchronous, meaning * JavaScript execution will not be blocked while HandleMessage() is * processing the message. * * @param[in] instance A PP_Instance identifying one instance * of a module. * @param[in] message A PP_Var which has been converted from a * JavaScript value. JavaScript array/object types are supported from Chrome * M29 onward. All JavaScript values are copied when passing them to the * plugin. * * When converting JavaScript arrays, any object properties whose name * is not an array index are ignored. When passing arrays and objects, the * entire reference graph will be converted and transferred. If the reference * graph has cycles, the message will not be sent and an error will be logged * to the console. * * The following JavaScript code invokes HandleMessage, passing * the module instance on which it was invoked, with message * being a string PP_Var containing "Hello world!" * * Example: * * @code * * * * * * * @endcode * */ void (*HandleMessage)(PP_Instance instance, struct PP_Var message); }; typedef struct PPP_Messaging_1_0 PPP_Messaging; /** * @} */ #endif /* PPAPI_C_PPP_MESSAGING_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/ppp_mouse_lock.h000066400000000000000000000024251321746453100235720ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppp_mouse_lock.idl modified Wed Dec 21 19:08:34 2011. */ #ifndef PPAPI_C_PPP_MOUSE_LOCK_H_ #define PPAPI_C_PPP_MOUSE_LOCK_H_ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #define PPP_MOUSELOCK_INTERFACE_1_0 "PPP_MouseLock;1.0" #define PPP_MOUSELOCK_INTERFACE PPP_MOUSELOCK_INTERFACE_1_0 /** * @file * This file defines the PPP_MouseLock interface containing a * function that you must implement to receive mouse lock events from the * browser. */ /** * @addtogroup Interfaces * @{ */ /** * The PPP_MouseLock interface contains a function that you must * implement to receive mouse lock events from the browser. */ struct PPP_MouseLock_1_0 { /** * MouseLockLost() is called when the instance loses the mouse lock, such as * when the user presses the ESC key. * * @param[in] instance A PP_Instance identifying one instance * of a module. */ void (*MouseLockLost)(PP_Instance instance); }; typedef struct PPP_MouseLock_1_0 PPP_MouseLock; /** * @} */ #endif /* PPAPI_C_PPP_MOUSE_LOCK_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/000077500000000000000000000000001321746453100220515ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/pp_content_decryptor.h000066400000000000000000000360471321746453100265000ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/pp_content_decryptor.idl modified Tue Oct 20 12:50:15 2015. */ #ifndef PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_ #define PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" /** * @file * The PP_DecryptTrackingInfo struct contains necessary information * that can be used to associate the decrypted block with a decrypt request * and/or an input block. */ /** * @addtogroup Structs * @{ */ struct PP_DecryptTrackingInfo { /** * Client-specified identifier for the associated decrypt request. By using * this value, the client can associate the decrypted block with a decryption * request. */ uint32_t request_id; /** * A unique buffer ID to identify a PPB_Buffer_Dev. Unlike a PP_Resource, * this ID is identical at both the renderer side and the plugin side. * In PPB_ContentDecryptor_Private calls, this is the ID of the * buffer associated with the decrypted block/frame/samples. * In PPP_ContentDecryptor_Private calls, this is the ID of a * buffer that is no longer need at the renderer side, which can be released * or recycled by the plugin. This ID can be 0 if there is no buffer to be * released or recycled. */ uint32_t buffer_id; /** * Timestamp in microseconds of the associated block. By using this value, * the client can associate the decrypted (and decoded) data with an input * block. This is needed because buffers may be delivered out of order and * not in response to the request_id they were provided with. */ int64_t timestamp; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptTrackingInfo, 16); /** * The PP_DecryptSubsampleDescription struct contains information * to support subsample decryption. * * An input block can be split into several continuous subsamples. * A PP_DecryptSubsampleEntry specifies the number of clear and * cipher bytes in each subsample. For example, the following block has three * subsamples: * * |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->| * | clear1 | cipher1 | clear2 | cipher2 | clear3 | cipher3 | * * For decryption, all of the cipher bytes in a block should be treated as a * contiguous (in the subsample order) logical stream. The clear bytes should * not be considered as part of decryption. * * Logical stream to decrypt: | cipher1 | cipher2 | cipher3 | * Decrypted stream: | decrypted1| decrypted2 | decrypted3 | * * After decryption, the decrypted bytes should be copied over the position * of the corresponding cipher bytes in the original block to form the output * block. Following the above example, the decrypted block should be: * * |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->| * | clear1 | decrypted1| clear2 | decrypted2 | clear3 | decrypted3 | */ struct PP_DecryptSubsampleDescription { /** * Size in bytes of clear data in a subsample entry. */ uint32_t clear_bytes; /** * Size in bytes of encrypted data in a subsample entry. */ uint32_t cipher_bytes; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptSubsampleDescription, 8); /** * The PP_EncryptedBlockInfo struct contains all the information * needed to decrypt an encrypted block. */ struct PP_EncryptedBlockInfo { /** * Information needed by the client to track the block to be decrypted. */ struct PP_DecryptTrackingInfo tracking_info; /** * Size in bytes of data to be decrypted (data_offset included). */ uint32_t data_size; /** * Key ID of the block to be decrypted. * * For WebM the key ID can be as large as 2048 bytes in theory. But it's not * used in current implementations. If we really need to support it, we should * move key ID out as a separate parameter, e.g. as a PP_Var, or * make the whole PP_EncryptedBlockInfo as a * PP_Resource. */ uint8_t key_id[64]; uint32_t key_id_size; /** * Initialization vector of the block to be decrypted. */ uint8_t iv[16]; uint32_t iv_size; /** * Subsample information of the block to be decrypted. * * We need to have a fixed size of |subsamples| here. Choose 32 because it is * sufficient for almost all real life scenarios. Note that in theory the * number of subsamples could be larger than 32. If that happens, playback * will fail. */ struct PP_DecryptSubsampleDescription subsamples[32]; uint32_t num_subsamples; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_EncryptedBlockInfo, 368); /** * @} */ /** * @addtogroup Enums * @{ */ /** * PP_DecryptedFrameFormat contains video frame formats. */ typedef enum { PP_DECRYPTEDFRAMEFORMAT_UNKNOWN = 0, PP_DECRYPTEDFRAMEFORMAT_YV12 = 1, PP_DECRYPTEDFRAMEFORMAT_I420 = 2 } PP_DecryptedFrameFormat; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptedFrameFormat, 4); /** * PP_DecryptedSampleFormat contains audio sample formats. */ typedef enum { PP_DECRYPTEDSAMPLEFORMAT_UNKNOWN = 0, PP_DECRYPTEDSAMPLEFORMAT_U8 = 1, PP_DECRYPTEDSAMPLEFORMAT_S16 = 2, PP_DECRYPTEDSAMPLEFORMAT_S32 = 3, PP_DECRYPTEDSAMPLEFORMAT_F32 = 4, PP_DECRYPTEDSAMPLEFORMAT_PLANAR_S16 = 5, PP_DECRYPTEDSAMPLEFORMAT_PLANAR_F32 = 6 } PP_DecryptedSampleFormat; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptedSampleFormat, 4); /** * The PP_DecryptResult enum contains decryption and decoding * result constants. */ typedef enum { /** The decryption (and/or decoding) operation finished successfully. */ PP_DECRYPTRESULT_SUCCESS = 0, /** The decryptor did not have the necessary decryption key. */ PP_DECRYPTRESULT_DECRYPT_NOKEY = 1, /** The input was accepted by the decoder but no frame(s) can be produced. */ PP_DECRYPTRESULT_NEEDMOREDATA = 2, /** An unexpected error happened during decryption. */ PP_DECRYPTRESULT_DECRYPT_ERROR = 3, /** An unexpected error happened during decoding. */ PP_DECRYPTRESULT_DECODE_ERROR = 4 } PP_DecryptResult; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptResult, 4); /** * @} */ /** * @addtogroup Structs * @{ */ /** * PP_DecryptedBlockInfo struct contains the decryption result and * tracking info associated with the decrypted block. */ struct PP_DecryptedBlockInfo { /** * Result of the decryption (and/or decoding) operation. */ PP_DecryptResult result; /** * Size in bytes of decrypted data, which may be less than the size of the * corresponding buffer. */ uint32_t data_size; /** * Information needed by the client to track the block to be decrypted. */ struct PP_DecryptTrackingInfo tracking_info; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptedBlockInfo, 24); /** * @} */ /** * @addtogroup Enums * @{ */ /** * PP_DecryptedFramePlanes provides YUV plane index values for * accessing plane offsets stored in PP_DecryptedFrameInfo. */ typedef enum { PP_DECRYPTEDFRAMEPLANES_Y = 0, PP_DECRYPTEDFRAMEPLANES_U = 1, PP_DECRYPTEDFRAMEPLANES_V = 2 } PP_DecryptedFramePlanes; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptedFramePlanes, 4); /** * @} */ /** * @addtogroup Structs * @{ */ /** * PP_DecryptedFrameInfo contains the result of the * decrypt and decode operation on the associated frame, information required * to access the frame data in buffer, and tracking info. */ struct PP_DecryptedFrameInfo { /** * Result of the decrypt and decode operation. */ PP_DecryptResult result; /** * Format of the decrypted frame. */ PP_DecryptedFrameFormat format; /** * Offsets into the buffer resource for accessing video planes. */ int32_t plane_offsets[3]; /** * Stride of each plane. */ int32_t strides[3]; /** * Width of the video frame, in pixels. */ int32_t width; /** * Height of the video frame, in pixels. */ int32_t height; /** * Information needed by the client to track the decrypted frame. */ struct PP_DecryptTrackingInfo tracking_info; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptedFrameInfo, 56); /** * PP_DecryptedSampleInfo contains the result of the * decrypt and decode operation on the associated samples, information required * to access the sample data in buffer, and tracking info. */ struct PP_DecryptedSampleInfo { /** * Result of the decrypt and decode operation. */ PP_DecryptResult result; /** * Format of the decrypted samples. */ PP_DecryptedSampleFormat format; /** * Size in bytes of decrypted samples. */ uint32_t data_size; /** * 4-byte padding to make the size of PP_DecryptedSampleInfo * a multiple of 8 bytes. The value of this field should not be used. */ uint32_t padding; /** * Information needed by the client to track the decrypted samples. */ struct PP_DecryptTrackingInfo tracking_info; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptedSampleInfo, 32); /** * @} */ /** * @addtogroup Enums * @{ */ /** * PP_AudioCodec contains audio codec type constants. */ typedef enum { PP_AUDIOCODEC_UNKNOWN = 0, PP_AUDIOCODEC_VORBIS = 1, PP_AUDIOCODEC_AAC = 2 } PP_AudioCodec; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_AudioCodec, 4); /** * @} */ /** * @addtogroup Structs * @{ */ /** * PP_AudioDecoderConfig contains audio decoder configuration * information required to initialize audio decoders, and a request ID * that allows clients to associate a decoder initialization request with a * status response. Note: When codec requires extra data for * initialization, the data is sent as a PP_Resource carried * alongside PP_AudioDecoderConfig. */ struct PP_AudioDecoderConfig { /** * The audio codec to initialize. */ PP_AudioCodec codec; /** * Number of audio channels. */ int32_t channel_count; /** * Size of each audio channel. */ int32_t bits_per_channel; /** * Audio sampling rate. */ int32_t samples_per_second; /** * Client-specified identifier for the associated audio decoder initialization * request. By using this value, the client can associate a decoder * initialization status response with an initialization request. */ uint32_t request_id; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_AudioDecoderConfig, 20); /** * @} */ /** * @addtogroup Enums * @{ */ /** * PP_VideoCodec contains video codec type constants. */ typedef enum { PP_VIDEOCODEC_UNKNOWN = 0, PP_VIDEOCODEC_VP8 = 1, PP_VIDEOCODEC_H264 = 2, PP_VIDEOCODEC_VP9 = 3 } PP_VideoCodec; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoCodec, 4); /** * PP_VideoCodecProfile contains video codec profile type * constants required for video decoder configuration. *. */ typedef enum { PP_VIDEOCODECPROFILE_UNKNOWN = 0, PP_VIDEOCODECPROFILE_NOT_NEEDED = 1, PP_VIDEOCODECPROFILE_H264_BASELINE = 2, PP_VIDEOCODECPROFILE_H264_MAIN = 3, PP_VIDEOCODECPROFILE_H264_EXTENDED = 4, PP_VIDEOCODECPROFILE_H264_HIGH = 5, PP_VIDEOCODECPROFILE_H264_HIGH_10 = 6, PP_VIDEOCODECPROFILE_H264_HIGH_422 = 7, PP_VIDEOCODECPROFILE_H264_HIGH_444_PREDICTIVE = 8 } PP_VideoCodecProfile; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoCodecProfile, 4); /** * @} */ /** * @addtogroup Structs * @{ */ /** * PP_VideoDecoderConfig contains video decoder configuration * information required to initialize video decoders, and a request ID * that allows clients to associate a decoder initialization request with a * status response. Note: When codec requires extra data for * initialization, the data is sent as a PP_Resource carried * alongside PP_VideoDecoderConfig. */ struct PP_VideoDecoderConfig { /** * The video codec to initialize. */ PP_VideoCodec codec; /** * Profile to use when initializing the video codec. */ PP_VideoCodecProfile profile; /** * Output video format. */ PP_DecryptedFrameFormat format; /** * Width of decoded video frames, in pixels. */ int32_t width; /** * Height of decoded video frames, in pixels. */ int32_t height; /** * Client-specified identifier for the associated video decoder initialization * request. By using this value, the client can associate a decoder * initialization status response with an initialization request. */ uint32_t request_id; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoDecoderConfig, 24); /** * @} */ /** * @addtogroup Enums * @{ */ /** * PP_DecryptorStreamType contains stream type constants. */ typedef enum { PP_DECRYPTORSTREAMTYPE_AUDIO = 0, PP_DECRYPTORSTREAMTYPE_VIDEO = 1 } PP_DecryptorStreamType; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptorStreamType, 4); /** * PP_SessionType contains session type constants. */ typedef enum { PP_SESSIONTYPE_TEMPORARY = 0, PP_SESSIONTYPE_PERSISTENT_LICENSE = 1, PP_SESSIONTYPE_PERSISTENT_RELEASE = 2 } PP_SessionType; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_SessionType, 4); /** * PP_InitDataType contains Initialization Data Type constants. */ typedef enum { PP_INITDATATYPE_CENC = 0, PP_INITDATATYPE_KEYIDS = 1, PP_INITDATATYPE_WEBM = 2 } PP_InitDataType; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InitDataType, 4); /** * PP_CdmExceptionCode contains exception code constants. */ typedef enum { PP_CDMEXCEPTIONCODE_NOTSUPPORTEDERROR = 1, PP_CDMEXCEPTIONCODE_INVALIDSTATEERROR = 2, PP_CDMEXCEPTIONCODE_INVALIDACCESSERROR = 3, PP_CDMEXCEPTIONCODE_QUOTAEXCEEDEDERROR = 4, PP_CDMEXCEPTIONCODE_UNKNOWNERROR = 5, PP_CDMEXCEPTIONCODE_CLIENTERROR = 6, PP_CDMEXCEPTIONCODE_OUTPUTERROR = 7 } PP_CdmExceptionCode; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CdmExceptionCode, 4); /** * PP_CdmMessageType contains message type constants. */ typedef enum { PP_CDMMESSAGETYPE_LICENSE_REQUEST = 0, PP_CDMMESSAGETYPE_LICENSE_RENEWAL = 1, PP_CDMMESSAGETYPE_LICENSE_RELEASE = 2 } PP_CdmMessageType; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CdmMessageType, 4); /** * PP_CdmKeyStatus contains key status constants. */ typedef enum { PP_CDMKEYSTATUS_USABLE = 0, PP_CDMKEYSTATUS_INVALID = 1, PP_CDMKEYSTATUS_EXPIRED = 2, PP_CDMKEYSTATUS_OUTPUTRESTRICTED = 3, PP_CDMKEYSTATUS_OUTPUTDOWNSCALED = 4, PP_CDMKEYSTATUS_STATUSPENDING = 5, PP_CDMKEYSTATUS_RELEASED = 6 } PP_CdmKeyStatus; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CdmKeyStatus, 4); /** * @} */ /** * @addtogroup Structs * @{ */ /** * The PP_KeyInformation struct contains information about a * key used for decryption. */ struct PP_KeyInformation { /** * Key ID. */ uint8_t key_id[512]; uint32_t key_id_size; /** * Status of this key. */ PP_CdmKeyStatus key_status; /** * Optional error code for keys that are not usable. */ uint32_t system_code; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_KeyInformation, 524); /** * @} */ #endif /* PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/pp_file_handle.h000066400000000000000000000013061321746453100251530ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/pp_file_handle.idl modified Fri Jul 27 17:01:41 2012. */ #ifndef PPAPI_C_PRIVATE_PP_FILE_HANDLE_H_ #define PPAPI_C_PRIVATE_PP_FILE_HANDLE_H_ #include "ppapi/c/pp_macros.h" /** * @file * This file provides support for native OS file handles. */ #ifdef _WIN32 #include typedef HANDLE PP_FileHandle; static const PP_FileHandle PP_kInvalidFileHandle = NULL; #else typedef int PP_FileHandle; static const PP_FileHandle PP_kInvalidFileHandle = -1; #endif #endif /* PPAPI_C_PRIVATE_PP_FILE_HANDLE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/pp_private_font_charset.h000066400000000000000000000025011321746453100271300ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/pp_private_font_charset.idl, * modified Fri Sep 07 12:50:35 2012. */ #ifndef PPAPI_C_PRIVATE_PP_PRIVATE_FONT_CHARSET_H_ #define PPAPI_C_PRIVATE_PP_PRIVATE_FONT_CHARSET_H_ #include "ppapi/c/pp_macros.h" /** * @file */ /** * @addtogroup Enums * @{ */ typedef enum { PP_PRIVATEFONTCHARSET_ANSI = 0, PP_PRIVATEFONTCHARSET_DEFAULT = 1, PP_PRIVATEFONTCHARSET_SYMBOL = 2, PP_PRIVATEFONTCHARSET_MAC = 77, PP_PRIVATEFONTCHARSET_SHIFTJIS = 128, PP_PRIVATEFONTCHARSET_HANGUL = 129, PP_PRIVATEFONTCHARSET_JOHAB = 130, PP_PRIVATEFONTCHARSET_GB2312 = 134, PP_PRIVATEFONTCHARSET_CHINESEBIG5 = 136, PP_PRIVATEFONTCHARSET_GREEK = 161, PP_PRIVATEFONTCHARSET_TURKISH = 162, PP_PRIVATEFONTCHARSET_VIETNAMESE = 163, PP_PRIVATEFONTCHARSET_HEBREW = 177, PP_PRIVATEFONTCHARSET_ARABIC = 178, PP_PRIVATEFONTCHARSET_BALTIC = 186, PP_PRIVATEFONTCHARSET_RUSSIAN = 204, PP_PRIVATEFONTCHARSET_THAI = 222, PP_PRIVATEFONTCHARSET_EASTEUROPE = 238, PP_PRIVATEFONTCHARSET_OEM = 255 } PP_PrivateFontCharset; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_PrivateFontCharset, 4); /** * @} */ #endif /* PPAPI_C_PRIVATE_PP_PRIVATE_FONT_CHARSET_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/pp_video_capture_format.h000066400000000000000000000017331321746453100271260ustar00rootroot00000000000000/* Copyright 2015 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/pp_video_capture_format.idl, * modified Wed Feb 18 01:41:26 2015. */ #ifndef PPAPI_C_PRIVATE_PP_VIDEO_CAPTURE_FORMAT_H_ #define PPAPI_C_PRIVATE_PP_VIDEO_CAPTURE_FORMAT_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" /** * @file * This file defines the struct used to hold a video capture format. */ /** * @addtogroup Structs * @{ */ /** * The PP_VideoCaptureFormat struct represents a video capture * format. */ struct PP_VideoCaptureFormat { /** * Frame size in pixels. */ struct PP_Size frame_size; /** * Frame rate in frames per second. */ float frame_rate; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoCaptureFormat, 12); /** * @} */ #endif /* PPAPI_C_PRIVATE_PP_VIDEO_CAPTURE_FORMAT_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/pp_video_frame_private.h000066400000000000000000000027101321746453100267330ustar00rootroot00000000000000/* Copyright (c) 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/pp_video_frame_private.idl modified Wed Apr 24 11:49:01 2013. */ #ifndef PPAPI_C_PRIVATE_PP_VIDEO_FRAME_PRIVATE_H_ #define PPAPI_C_PRIVATE_PP_VIDEO_FRAME_PRIVATE_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" /** * @file * This file defines the struct used to hold a video frame. */ /** * @addtogroup Structs * @{ */ /** * The PP_VideoFrame_Private struct represents a video frame. * Video sources and destinations use frames to transfer video to and from * the browser. */ struct PP_VideoFrame_Private { /** * A timestamp placing the frame in a video stream. */ PP_TimeTicks timestamp; /** * An image data resource to hold the video frame. */ PP_Resource image_data; /** * Ensure that this struct is 16-bytes wide by padding the end. In some * compilers, PP_TimeTicks is 8-byte aligned, so those compilers align this * struct on 8-byte boundaries as well and pad it to 8 bytes even without this * padding attribute. This padding makes its size consistent across * compilers. */ int32_t padding; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoFrame_Private, 16); /** * @} */ #endif /* PPAPI_C_PRIVATE_PP_VIDEO_FRAME_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_camera_capabilities_private.h000066400000000000000000000052701321746453100305620ustar00rootroot00000000000000/* Copyright 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_camera_capabilities_private.idl, * modified Thu Feb 19 09:06:18 2015. */ #ifndef PPAPI_C_PRIVATE_PPB_CAMERA_CAPABILITIES_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_CAMERA_CAPABILITIES_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/private/pp_video_capture_format.h" #define PPB_CAMERACAPABILITIES_PRIVATE_INTERFACE_0_1 \ "PPB_CameraCapabilities_Private;0.1" #define PPB_CAMERACAPABILITIES_PRIVATE_INTERFACE \ PPB_CAMERACAPABILITIES_PRIVATE_INTERFACE_0_1 /** * @file * This file defines the PPB_CameraCapabilities_Private interface for * establishing an image capture configuration resource within the browser. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_CameraCapabilities_Private interface contains pointers * to several functions for getting the image capture capabilities within the * browser. */ struct PPB_CameraCapabilities_Private_0_1 { /** * IsCameraCapabilities() determines if the given resource is a * PPB_CameraCapabilities_Private. * * @param[in] resource A PP_Resource corresponding to an image * capture capabilities resource. * * @return A PP_Bool containing PP_TRUE if the given * resource is an PP_CameraCapabilities_Private resource, * otherwise PP_FALSE. */ PP_Bool (*IsCameraCapabilities)(PP_Resource resource); /** * GetSupportedVideoCaptureFormats() returns the supported video capture * formats for the given PPB_CameraCapabilities_Private. * * @param[in] capabilities A PP_Resource corresponding to an * image capture capabilities resource. * @param[out] array_size The size of preview size array. * @param[out] formats An array of PP_VideoCaptureFormat * corresponding to the supported video capture formats. The ownership of the * array belongs to PPB_CameraCapabilities_Private and the caller * should not free it. When a PPB_CameraCapabilities_Private is deleted, the * array returning from this is no longer valid. */ void (*GetSupportedVideoCaptureFormats)( PP_Resource capabilities, uint32_t* array_size, struct PP_VideoCaptureFormat** formats); }; typedef struct PPB_CameraCapabilities_Private_0_1 PPB_CameraCapabilities_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_CAMERA_CAPABILITIES_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_camera_device_private.h000066400000000000000000000100051321746453100273600ustar00rootroot00000000000000/* Copyright 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_camera_device_private.idl, * modified Fri Feb 20 13:48:52 2015. */ #ifndef PPAPI_C_PRIVATE_PPB_CAMERA_DEVICE_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_CAMERA_DEVICE_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_CAMERADEVICE_PRIVATE_INTERFACE_0_1 "PPB_CameraDevice_Private;0.1" #define PPB_CAMERADEVICE_PRIVATE_INTERFACE \ PPB_CAMERADEVICE_PRIVATE_INTERFACE_0_1 /** * @file * Defines the PPB_CameraDevice_Private interface. Used for * manipulating a camera device. */ /** * @addtogroup Interfaces * @{ */ /** * To query camera capabilities: * 1. Get a PPB_CameraDevice_Private object by Create(). * 2. Open() camera device with track id of MediaStream video track. * 3. Call GetCameraCapabilities() to get a * PPB_CameraCapabilities_Private object, which can be used to * query camera capabilities. */ struct PPB_CameraDevice_Private_0_1 { /** * Creates a PPB_CameraDevice_Private resource. * * @param[in] instance A PP_Instance identifying one instance * of a module. * * @return A PP_Resource corresponding to a * PPB_CameraDevice_Private resource if successful, 0 if failed. */ PP_Resource (*Create)(PP_Instance instance); /** * Determines if a resource is a camera device resource. * * @param[in] resource The PP_Resource to test. * * @return A PP_Bool with PP_TRUE if the given * resource is a camera device resource or PP_FALSE * otherwise. */ PP_Bool (*IsCameraDevice)(PP_Resource resource); /** * Opens a camera device. * * @param[in] camera_device A PP_Resource corresponding to a * camera device resource. * @param[in] device_id A PP_Var identifying a camera device. The * type is string. The ID can be obtained from MediaStreamTrack.getSources() * or MediaStreamVideoTrack.id. * @param[in] callback A PP_CompletionCallback to be called upon * completion of Open(). * * @return An error code from pp_errors.h. */ int32_t (*Open)(PP_Resource camera_device, struct PP_Var device_id, struct PP_CompletionCallback callback); /** * Disconnects from the camera and cancels all pending requests. * After this returns, no callbacks will be called. If * PPB_CameraDevice_Private is destroyed and is not closed yet, this * function will be automatically called. Calling this more than once has no * effect. * * @param[in] camera_device A PP_Resource corresponding to a * camera device resource. */ void (*Close)(PP_Resource camera_device); /** * Gets the camera capabilities. * * The camera capabilities do not change for a given camera source. * * @param[in] camera_device A PP_Resource corresponding to a * camera device resource. * @param[out] capabilities A PPB_CameraCapabilities_Private for * storing the camera capabilities on success. Otherwise, the value will not * be changed. * @param[in] callback PP_CompletionCallback to be called upon * completion of GetCameraCapabilities(). * * @return An int32_t containing a result code from pp_errors.h. */ int32_t (*GetCameraCapabilities)(PP_Resource camera_device, PP_Resource* capabilities, struct PP_CompletionCallback callback); }; typedef struct PPB_CameraDevice_Private_0_1 PPB_CameraDevice_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_CAMERA_DEVICE_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_content_decryptor_private.h000066400000000000000000000317111321746453100303650ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_content_decryptor_private.idl, * modified Mon Mar 30 22:35:33 2015. */ #ifndef PPAPI_C_PRIVATE_PPB_CONTENT_DECRYPTOR_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_CONTENT_DECRYPTOR_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/private/pp_content_decryptor.h" #define PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_14 \ "PPB_ContentDecryptor_Private;0.14" #define PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE \ PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_14 /** * @file * This file defines the PPB_ContentDecryptor_Private * interface. Note: This is a special interface, only to be used for Content * Decryption Modules, not normal plugins. */ /** * @addtogroup Interfaces * @{ */ /** * PPB_ContentDecryptor_Private structure contains the function * pointers the browser must implement to support plugins implementing the * PPP_ContentDecryptor_Private interface. This interface provides * browser side support for the Content Decryption Module (CDM) for Encrypted * Media Extensions: http://www.w3.org/TR/encrypted-media/ */ struct PPB_ContentDecryptor_Private_0_14 { /** * A promise has been resolved by the CDM. * * @param[in] promise_id Identifies the promise that the CDM resolved. */ void (*PromiseResolved)(PP_Instance instance, uint32_t promise_id); /** * A promise that resulted in a new session has been resolved by the CDM. * * @param[in] promise_id Identifies the promise that the CDM resolved. * * @param[in] session_id A PP_Var of type * PP_VARTYPE_STRING containing the session's ID attribute. */ void (*PromiseResolvedWithSession)(PP_Instance instance, uint32_t promise_id, struct PP_Var session_id); /** * A promise has been rejected by the CDM due to an error. * * @param[in] promise_id Identifies the promise that the CDM rejected. * * @param[in] exception_code A PP_CdmExceptionCode containing * the exception code. * * @param[in] system_code A system error code. * * @param[in] error_description A PP_Var of type * PP_VARTYPE_STRING containing the error description. */ void (*PromiseRejected)(PP_Instance instance, uint32_t promise_id, PP_CdmExceptionCode exception_code, uint32_t system_code, struct PP_Var error_description); /** * A message or request has been generated for key_system in the CDM, and * must be sent to the web application. * * For example, when the browser invokes CreateSession() * on the PPP_ContentDecryptor_Private interface, the plugin * must send a message containing the license request. * * Note that SessionMessage() can be used for purposes other than * responses to CreateSession() calls. See also the text * in the comment for SessionReady(), which describes a sequence * of UpdateSession() and SessionMessage() calls * required to prepare for decryption. * * @param[in] session_id A PP_Var of type * PP_VARTYPE_STRING containing the ID of a session for * which this message is intended. * * @param[in] message_type A PP_CdmMessageType containing the * message type. * * @param[in] message A PP_Var of type * PP_VARTYPE_ARRAY_BUFFER that contains the message. * * @param[in] legacy_destination_url A PP_Var of type * PP_VARTYPE_STRING containing the destination URL for the * message. */ void (*SessionMessage)(PP_Instance instance, struct PP_Var session_id, PP_CdmMessageType message_type, struct PP_Var message, struct PP_Var legacy_destination_url); /** * The keys for a session have changed. * * @param[in] session_id A PP_Var of type * PP_VARTYPE_STRING containing the ID of the session that has * a change in keys. * * @param[in] has_additional_usable_key A PP_Bool indicating if * a new usable key has been added. * * @param[in] key_count The number of arguments contained in * key_information * * @param[in] key_information An array of type PP_KeyInformation * that are the session's key IDs and their status. */ void (*SessionKeysChange)(PP_Instance instance, struct PP_Var session_id, PP_Bool has_additional_usable_key, uint32_t key_count, const struct PP_KeyInformation key_information[]); /** * The expiration time for a session has changed. * * @param[in] session_id A PP_Var of type * PP_VARTYPE_STRING containing the ID of the session that has * a new expiration time. * * @param[in] new_expiry_time A PP_Time indicating the new * expiry time of the session. The value is defined as the number of seconds * since the Epoch (00:00:00 UTC, January 1, 1970). */ void (*SessionExpirationChange)(PP_Instance instance, struct PP_Var session_id, PP_Time new_expiry_time); /** * The session has been closed as the result of a call to the * ReleaseSession() method on the * PPP_ContentDecryptor_Private interface, or due to other * factors as determined by the CDM. * * @param[in] session_id A PP_Var of type * PP_VARTYPE_STRING containing the session's ID attribute of * the session that is now closed. */ void (*SessionClosed)(PP_Instance instance, struct PP_Var session_id); /** * An error occurred in a PPP_ContentDecryptor_Private method, * or within the plugin implementing the interface. * * @param[in] session_id A PP_Var of type * PP_VARTYPE_STRING containing the session's ID attribute of * the session that caused the error. * * @param[in] exception_code A PP_CdmExceptionCode containing * the exception code. * * @param[in] system_code A system error code. * * @param[in] error_description A PP_Var of type * PP_VARTYPE_STRING containing the error description. */ void (*LegacySessionError)(PP_Instance instance, struct PP_Var session_id, PP_CdmExceptionCode exception_code, uint32_t system_code, struct PP_Var error_description); /** * Called after the Decrypt() method on the * PPP_ContentDecryptor_Private interface completes to * deliver decrypted_block to the browser for decoding and rendering. * * The plugin must not hold a reference to the encrypted buffer resource * provided to Decrypt() when it calls this method. The browser * will reuse the buffer in a subsequent Decrypt() call. * * @param[in] decrypted_block A PP_Resource corresponding to a * PPB_Buffer_Dev resource that contains a decrypted data * block. * * @param[in] decrypted_block_info A PP_DecryptedBlockInfo that * contains the result code and tracking info associated with the * decrypted_block. */ void (*DeliverBlock)( PP_Instance instance, PP_Resource decrypted_block, const struct PP_DecryptedBlockInfo* decrypted_block_info); /** * Called after the InitializeAudioDecoder() or * InitializeVideoDecoder() method on the * PPP_ContentDecryptor_Private interface completes to report * decoder initialization status to the browser. * * @param[in] success A PP_Bool that is set to * PP_TRUE when the decoder initialization request associated * with request_id was successful. * * @param[in] decoder_type A PP_DecryptorStreamType identifying * the decoder type for which this initialization status response was sent. * * @param[in] request_id The request_id value passed to * InitializeAudioDecoder or InitializeVideoDecoder * in PP_AudioDecoderConfig or * PP_VideoDecoderConfig. */ void (*DecoderInitializeDone)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id, PP_Bool success); /** * Called after the DeinitializeDecoder() method on the * PPP_ContentDecryptor_Private interface completes to report * decoder de-initialization completion to the browser. * * @param[in] decoder_type The PP_DecryptorStreamType passed to * DeinitializeDecoder(). * * @param[in] request_id The request_id value passed to * DeinitializeDecoder(). */ void (*DecoderDeinitializeDone)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id); /** * Called after the ResetDecoder() method on the * PPP_ContentDecryptor_Private interface completes to report * decoder reset completion to the browser. * * @param[in] decoder_type The PP_DecryptorStreamType passed to * ResetDecoder(). * * @param[in] request_id The request_id value passed to * ResetDecoder(). */ void (*DecoderResetDone)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id); /** * Called after the DecryptAndDecode() method on the * PPP_ContentDecryptor_Private interface completes to deliver * a decrypted and decoded video frame to the browser for rendering. * * The plugin must not hold a reference to the encrypted buffer resource * provided to DecryptAndDecode() when it calls this method. The * browser will reuse the buffer in a subsequent * DecryptAndDecode() call. * * @param[in] decrypted_frame A PP_Resource corresponding to a * PPB_Buffer_Dev resource that contains a video frame. * * @param[in] decrypted_frame_info A PP_DecryptedFrameInfo that * contains the result code, tracking info, and buffer format associated with * decrypted_frame. */ void (*DeliverFrame)( PP_Instance instance, PP_Resource decrypted_frame, const struct PP_DecryptedFrameInfo* decrypted_frame_info); /** * Called after the DecryptAndDecode() method on the * PPP_ContentDecryptor_Private interface completes to deliver * a buffer of decrypted and decoded audio samples to the browser for * rendering. * * The plugin must not hold a reference to the encrypted buffer resource * provided to DecryptAndDecode() when it calls this method. The * browser will reuse the buffer in a subsequent * DecryptAndDecode() call. * * audio_frames can contain multiple audio output buffers. Each * buffer is serialized in this format: * * |<------------------- serialized audio buffer ------------------->| * | int64_t timestamp | int64_t length | length bytes of audio data | * * For example, with three audio output buffers, |audio_frames| will look * like this: * * |<---------------- audio_frames ------------------>| * | audio buffer 0 | audio buffer 1 | audio buffer 2 | * * @param[in] audio_frames A PP_Resource corresponding to a * PPB_Buffer_Dev resource that contains a decrypted buffer * of decoded audio samples. * * @param[in] decrypted_sample_info A PP_DecryptedSampleInfo that * contains the tracking info and result code associated with the decrypted * samples. */ void (*DeliverSamples)( PP_Instance instance, PP_Resource audio_frames, const struct PP_DecryptedSampleInfo* decrypted_sample_info); }; typedef struct PPB_ContentDecryptor_Private_0_14 PPB_ContentDecryptor_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_CONTENT_DECRYPTOR_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_display_color_profile_private.h000066400000000000000000000111661321746453100312050ustar00rootroot00000000000000/* Copyright 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_display_color_profile_private.idl, * modified Mon Dec 16 20:53:23 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_DISPLAY_COLOR_PROFILE_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_DISPLAY_COLOR_PROFILE_PRIVATE_H_ #include "ppapi/c/pp_array_output.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_DISPLAYCOLORPROFILE_PRIVATE_INTERFACE_0_1 \ "PPB_DisplayColorProfile_Private;0.1" #define PPB_DISPLAYCOLORPROFILE_PRIVATE_INTERFACE \ PPB_DISPLAYCOLORPROFILE_PRIVATE_INTERFACE_0_1 /** * @file * This file defines the PPB_DisplayColorProfile struct used for * getting the color profile of the display. */ /** * @addtogroup Interfaces * @{ */ /** * PPB_DisplayColorProfile_Private defines the methods for getting * the display color profile and monitoring its changes. * * Setup: * @code * PP_ArrayOutput output = { MyAllocatorFunction, color_profile_data }; * PP_Resource display_cp = display_cp_interface->Create(instance); * display_cp_interface->GetColorProfile(display_cp, * output, * completion_callback); * @endcode */ struct PPB_DisplayColorProfile_Private_0_1 { /** * Create() creates a display color profile resource. * * @param[in] instance The module instance. * @return A PP_Resource containing a display color profile * resource. */ PP_Resource (*Create)(PP_Instance instance); /** * IsDisplayColorProfile() determines if the given resource is a valid * DisplayColorProfile resource. * * @param[in] resource A DisplayColorProfile context resource. * @return Returns: * - PP_TRUE if the given resource is a valid * DisplayColorProfile * - PP_FALSE if it is an invalid resource or is a resource * of another type. */ PP_Bool (*IsDisplayColorProfile)(PP_Resource resource); /** * GetColorProfile() enqueues a request for the current display color profile. * * This method is intended for getting the color profile data of the display * on which the browser window resides. [However currently Chrome only * considers the system's primary display color profile when doing its color * management. For consistency this method will also return the color profile * that Chrome uses for its browser window.] * * @param[in] display_color_profile_res The display color profile resource. * @param[in] color_profile A PP_OutputArray which on success * will receive a byte array containing the ICC color profile data (see * www.color.org for a reference to the ICC color profile specification * and versions). The returned color profile version is the one supported by * the host system. * @param[in] callback The completion callback to be called once the display * color profile data is available. * * @return Returns an error code from pp_errors.h. */ int32_t (*GetColorProfile)(PP_Resource display_color_profile_res, struct PP_ArrayOutput color_profile, struct PP_CompletionCallback callback); /** * RegisterColorProfileChangeCallback() registers a callback to be called next * time the color profile for the browser window in which the plugin resides * changes. In order to get notifications for all color profile changes a call * to RegisterColorProfileChangeCallback() function should be done when the * previous notification was fired. * * There might be 2 scenarios in which the color profile for a window changes: * a) The window is moved from one display to another; * b) The user changes the display color space from the system settings. * * @param[in] display_color_profile_res The display color profile resource. * @param[in] callback The callback to be invoked next time the display * color profile changes. * * @return Returns an error code from pp_errors.h. */ int32_t (*RegisterColorProfileChangeCallback)( PP_Resource display_color_profile_res, struct PP_CompletionCallback callback); }; typedef struct PPB_DisplayColorProfile_Private_0_1 PPB_DisplayColorProfile_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_DISPLAY_COLOR_PROFILE_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_ext_crx_file_system_private.h000066400000000000000000000034441321746453100307010ustar00rootroot00000000000000/* Copyright (c) 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_ext_crx_file_system_private.idl, * modified Fri Nov 1 12:23:59 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_EXT_CRX_FILE_SYSTEM_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_EXT_CRX_FILE_SYSTEM_PRIVATE_H_ #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_EXT_CRXFILESYSTEM_PRIVATE_INTERFACE_0_1 \ "PPB_Ext_CrxFileSystem_Private;0.1" #define PPB_EXT_CRXFILESYSTEM_PRIVATE_INTERFACE \ PPB_EXT_CRXFILESYSTEM_PRIVATE_INTERFACE_0_1 /** * @file * This file contains the PPB_Ext_CrxFileSystem_Private interface. */ /** * @addtogroup Interfaces * @{ */ /* PPB_Ext_CrxFileSystem_Private interface */ struct PPB_Ext_CrxFileSystem_Private_0_1 { /** * Open() opens the CRX file system for the current extension. It will fail * when called from non-extension context. * * @param[in] crxfs A PP_Resource corresponding to a * CrxFileSystem. * @param[out] file_system An output PP_Resource corresponding * to a PPB_FileSystem. * @param[in] callback A PP_CompletionCallback to be called upon * completion of Open. * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*Open)(PP_Instance instance, PP_Resource* file_system, struct PP_CompletionCallback callback); }; typedef struct PPB_Ext_CrxFileSystem_Private_0_1 PPB_Ext_CrxFileSystem_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_EXT_CRX_FILE_SYSTEM_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_file_io_private.h000066400000000000000000000025251321746453100262270ustar00rootroot00000000000000/* Copyright (c) 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_file_io_private.idl modified Wed Mar 27 14:43:25 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_FILE_IO_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_FILE_IO_PRIVATE_H_ #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_FILEIO_PRIVATE_INTERFACE_0_1 "PPB_FileIO_Private;0.1" #define PPB_FILEIO_PRIVATE_INTERFACE PPB_FILEIO_PRIVATE_INTERFACE_0_1 /** * @file */ #include "ppapi/c/private/pp_file_handle.h" /** * @addtogroup Interfaces * @{ */ /* PPB_FileIO_Private interface */ struct PPB_FileIO_Private_0_1 { /** * Returns a file handle corresponding to the given FileIO * object. The FileIO object must have been opened with a * successful call to FileIO::Open. The caller gets the ownership * of the returned file handle and must close it. */ int32_t (*RequestOSFileHandle)(PP_Resource file_io, PP_FileHandle* handle, struct PP_CompletionCallback callback); }; typedef struct PPB_FileIO_Private_0_1 PPB_FileIO_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_FILE_IO_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_file_ref_private.h000066400000000000000000000023761321746453100264000ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_file_ref_private.idl modified Fri Dec 16 17:34:59 2011. */ #ifndef PPAPI_C_PRIVATE_PPB_FILE_REF_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_FILE_REF_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_FILEREFPRIVATE_INTERFACE_0_1 "PPB_FileRefPrivate;0.1" #define PPB_FILEREFPRIVATE_INTERFACE PPB_FILEREFPRIVATE_INTERFACE_0_1 /** * @file * This file contains the PPB_FileRefPrivate interface. */ /** * @addtogroup Interfaces * @{ */ /* PPB_FileRefPrivate interface */ struct PPB_FileRefPrivate_0_1 { /** * GetAbsolutePath() returns the absolute path of the file. * * @param[in] file_ref A PP_Resource corresponding to a file * reference. * * @return A PP_Var containing the absolute path of the file. */ struct PP_Var (*GetAbsolutePath)(PP_Resource file_ref); }; typedef struct PPB_FileRefPrivate_0_1 PPB_FileRefPrivate; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_FILE_REF_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_find_private.h000066400000000000000000000053561321746453100255460ustar00rootroot00000000000000/* Copyright 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_find_private.idl modified Wed Mar 19 13:42:13 2014. */ #ifndef PPAPI_C_PRIVATE_PPB_FIND_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_FIND_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #define PPB_FIND_PRIVATE_INTERFACE_0_3 "PPB_Find_Private;0.3" #define PPB_FIND_PRIVATE_INTERFACE PPB_FIND_PRIVATE_INTERFACE_0_3 /** * @file * This file defines the PPB_Find_Private interface. */ /** * @addtogroup Interfaces * @{ */ /** * This is a private interface for doing browser Find in the PDF plugin. */ struct PPB_Find_Private_0_3 { /** * Sets the instance of this plugin as the mechanism that will be used to * handle find requests in the renderer. This will only succeed if the plugin * is embedded within the content of the top level frame. Note that this will * result in the renderer handing over all responsibility for doing find to * the plugin and content from the rest of the page will not be searched. * * * In the case that the plugin is loaded directly as the top level document, * this function does not need to be called. In that case the plugin is * assumed to handle find requests. * * There can only be one plugin which handles find requests. If a plugin calls * this while an existing plugin is registered, the existing plugin will be * de-registered and will no longer receive any requests. */ void (*SetPluginToHandleFindRequests)(PP_Instance instance); /** * Updates the number of find results for the current search term. If * there are no matches 0 should be passed in. Only when the plugin has * finished searching should it pass in the final count with final_result set * to PP_TRUE. */ void (*NumberOfFindResultsChanged)(PP_Instance instance, int32_t total, PP_Bool final_result); /** * Updates the index of the currently selected search item. */ void (*SelectedFindResultChanged)(PP_Instance instance, int32_t index); /** * Updates the tickmarks on the scrollbar for the find request. |tickmarks| * contains |count| PP_Rects indicating the tickmark ranges. */ void (*SetTickmarks)(PP_Instance instance, const struct PP_Rect tickmarks[], uint32_t count); }; typedef struct PPB_Find_Private_0_3 PPB_Find_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_FIND_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_flash.h000066400000000000000000000311601321746453100241610ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_flash.idl modified Thu Apr 18 15:06:12 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_FLASH_H_ #define PPAPI_C_PRIVATE_PPB_FLASH_H_ #include "ppapi/c/pp_array_output.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/trusted/ppb_browser_font_trusted.h" #define PPB_FLASH_INTERFACE_12_4 "PPB_Flash;12.4" #define PPB_FLASH_INTERFACE_12_5 "PPB_Flash;12.5" #define PPB_FLASH_INTERFACE_12_6 "PPB_Flash;12.6" #define PPB_FLASH_INTERFACE_13_0 "PPB_Flash;13.0" #define PPB_FLASH_INTERFACE PPB_FLASH_INTERFACE_13_0 /** * @file * This file contains the PPB_Flash interface. */ /** * @addtogroup Enums * @{ */ typedef enum { /** * No restrictions on Flash LSOs. */ PP_FLASHLSORESTRICTIONS_NONE = 1, /** * Don't allow access to Flash LSOs. */ PP_FLASHLSORESTRICTIONS_BLOCK = 2, /** * Store Flash LSOs in memory only. */ PP_FLASHLSORESTRICTIONS_IN_MEMORY = 3 } PP_FlashLSORestrictions; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FlashLSORestrictions, 4); typedef enum { /** * Specifies if the system likely supports 3D hardware acceleration. * * The result is a boolean PP_Var, depending on the supported nature of 3D * acceleration. If querying this function returns true, the 3D system will * normally use the native hardware for rendering which will be much faster. * * Having this set to true only means that 3D should be used to draw 2D and * video elements. PP_FLASHSETTING_STAGE3D_ENABLED should be checked to * determine if it's ok to use 3D for arbitrary content. * * In rare cases (depending on the platform) this value will be true but a * created 3D context will use emulation because context initialization * failed. */ PP_FLASHSETTING_3DENABLED = 1, /** * Specifies if the given instance is in private/incognito/off-the-record mode * (returns true) or "regular" mode (returns false). Returns an undefined * PP_Var on invalid instance. */ PP_FLASHSETTING_INCOGNITO = 2, /** * Specifies if arbitrary 3d commands are supported (returns true), or if 3d * should only be used for drawing 2d and video (returns false). * * This should only be enabled if PP_FLASHSETTING_3DENABLED is true. */ PP_FLASHSETTING_STAGE3DENABLED = 3, /** * Specifies the string for the language code of the UI of the browser. * * For example: "en-US" or "de". * * Returns an undefined PP_Var on invalid instance. */ PP_FLASHSETTING_LANGUAGE = 4, /** * Specifies the number of CPU cores that are present on the system. */ PP_FLASHSETTING_NUMCORES = 5, /** * Specifies restrictions on how flash should handle LSOs. The result is an * int from PP_FlashLSORestrictions. */ PP_FLASHSETTING_LSORESTRICTIONS = 6, /** * Specifies if the driver is reliable enough to use Shader Model 3 commands * with it. * * This should only be enabled if PP_FLASHSETTING_STAGE3DENABLED is true. */ PP_FLASHSETTING_STAGE3DBASELINEENABLED = 7 } PP_FlashSetting; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FlashSetting, 4); /** * This enum provides keys for setting breakpad crash report data. */ typedef enum { /** * Specifies the document URL which contains the flash instance. */ PP_FLASHCRASHKEY_URL = 1, /** * Specifies the URL of the current swf. */ PP_FLASHCRASHKEY_RESOURCE_URL = 2 } PP_FlashCrashKey; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FlashCrashKey, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_Flash interface contains pointers to various functions * that are only needed to support Pepper Flash. */ struct PPB_Flash_13_0 { /** * Sets or clears the rendering hint that the given plugin instance is always * on top of page content. Somewhat more optimized painting can be used in * this case. */ void (*SetInstanceAlwaysOnTop)(PP_Instance instance, PP_Bool on_top); /** * Draws the given pre-laid-out text. It is almost equivalent to Windows' * ExtTextOut with the addition of the transformation (a 3x3 matrix given the * transform to apply before drawing). It also adds the allow_subpixel_aa * flag which when true, will use subpixel antialiasing if enabled in the * system settings. For this to work properly, the graphics layer that the * text is being drawn into must be opaque. */ PP_Bool (*DrawGlyphs)( PP_Instance instance, PP_Resource pp_image_data, const struct PP_BrowserFont_Trusted_Description* font_desc, uint32_t color, const struct PP_Point* position, const struct PP_Rect* clip, const float transformation[3][3], PP_Bool allow_subpixel_aa, uint32_t glyph_count, const uint16_t glyph_indices[], const struct PP_Point glyph_advances[]); /** * Retrieves the proxy that will be used for the given URL. The result will * be a string in PAC format, or an undefined var on error. */ struct PP_Var (*GetProxyForURL)(PP_Instance instance, const char* url); /** * Navigate to the URL given by the given URLRequestInfo. (This supports GETs, * POSTs, and javascript: URLs.) May open a new tab if target is not "_self". */ int32_t (*Navigate)(PP_Resource request_info, const char* target, PP_Bool from_user_action); /** * Retrieves the local time zone offset from GM time for the given UTC time. */ double (*GetLocalTimeZoneOffset)(PP_Instance instance, PP_Time t); /** * Gets a (string) with "command-line" options for Flash; used to pass * run-time debugging parameters, etc. */ struct PP_Var (*GetCommandLineArgs)(PP_Module module); /** * Loads the given font in a more privileged process on Windows. Call this if * Windows is giving errors for font calls. See * content/renderer/font_cache_dispatcher_win.cc * * The parameter is a pointer to a LOGFONTW structure. * * On non-Windows platforms, this function does nothing. */ void (*PreloadFontWin)(const void* logfontw); /** * Returns whether the given rectangle (in the plugin) is topmost, i.e., above * all other web content. */ PP_Bool (*IsRectTopmost)(PP_Instance instance, const struct PP_Rect* rect); /** * Indicates that there's activity and, e.g., the screensaver shouldn't kick * in. */ void (*UpdateActivity)(PP_Instance instance); /** * Returns the value associated with the given setting. Invalid enums will * result in an undefined PP_Var return value. */ struct PP_Var (*GetSetting)(PP_Instance instance, PP_FlashSetting setting); /** * Allows setting breakpad crash data which will be included in plugin crash * reports. Returns PP_FALSE if crash data could not be set. */ PP_Bool (*SetCrashData)(PP_Instance instance, PP_FlashCrashKey key, struct PP_Var value); /** * Enumerates video capture devices. |video_capture| is a valid * PPB_VideoCapture_Dev resource. Once the operation has completed * successfully, |devices| will be set up with an array of * PPB_DeviceRef_Dev resources. * * PP_OK is returned on success and different pepper error code on failure. * The ref count of the returned |devices| has already been increased by 1 for * the caller. * * NOTE: This method is a synchronous version of |EnumerateDevices| in * PPB_VideoCapture_Dev. */ int32_t (*EnumerateVideoCaptureDevices)(PP_Instance instance, PP_Resource video_capture, struct PP_ArrayOutput devices); }; typedef struct PPB_Flash_13_0 PPB_Flash; struct PPB_Flash_12_4 { void (*SetInstanceAlwaysOnTop)(PP_Instance instance, PP_Bool on_top); PP_Bool (*DrawGlyphs)( PP_Instance instance, PP_Resource pp_image_data, const struct PP_BrowserFont_Trusted_Description* font_desc, uint32_t color, const struct PP_Point* position, const struct PP_Rect* clip, const float transformation[3][3], PP_Bool allow_subpixel_aa, uint32_t glyph_count, const uint16_t glyph_indices[], const struct PP_Point glyph_advances[]); struct PP_Var (*GetProxyForURL)(PP_Instance instance, const char* url); int32_t (*Navigate)(PP_Resource request_info, const char* target, PP_Bool from_user_action); void (*RunMessageLoop)(PP_Instance instance); void (*QuitMessageLoop)(PP_Instance instance); double (*GetLocalTimeZoneOffset)(PP_Instance instance, PP_Time t); struct PP_Var (*GetCommandLineArgs)(PP_Module module); void (*PreloadFontWin)(const void* logfontw); PP_Bool (*IsRectTopmost)(PP_Instance instance, const struct PP_Rect* rect); int32_t (*InvokePrinting)(PP_Instance instance); void (*UpdateActivity)(PP_Instance instance); struct PP_Var (*GetDeviceID)(PP_Instance instance); int32_t (*GetSettingInt)(PP_Instance instance, PP_FlashSetting setting); struct PP_Var (*GetSetting)(PP_Instance instance, PP_FlashSetting setting); }; struct PPB_Flash_12_5 { void (*SetInstanceAlwaysOnTop)(PP_Instance instance, PP_Bool on_top); PP_Bool (*DrawGlyphs)( PP_Instance instance, PP_Resource pp_image_data, const struct PP_BrowserFont_Trusted_Description* font_desc, uint32_t color, const struct PP_Point* position, const struct PP_Rect* clip, const float transformation[3][3], PP_Bool allow_subpixel_aa, uint32_t glyph_count, const uint16_t glyph_indices[], const struct PP_Point glyph_advances[]); struct PP_Var (*GetProxyForURL)(PP_Instance instance, const char* url); int32_t (*Navigate)(PP_Resource request_info, const char* target, PP_Bool from_user_action); void (*RunMessageLoop)(PP_Instance instance); void (*QuitMessageLoop)(PP_Instance instance); double (*GetLocalTimeZoneOffset)(PP_Instance instance, PP_Time t); struct PP_Var (*GetCommandLineArgs)(PP_Module module); void (*PreloadFontWin)(const void* logfontw); PP_Bool (*IsRectTopmost)(PP_Instance instance, const struct PP_Rect* rect); int32_t (*InvokePrinting)(PP_Instance instance); void (*UpdateActivity)(PP_Instance instance); struct PP_Var (*GetDeviceID)(PP_Instance instance); int32_t (*GetSettingInt)(PP_Instance instance, PP_FlashSetting setting); struct PP_Var (*GetSetting)(PP_Instance instance, PP_FlashSetting setting); PP_Bool (*SetCrashData)(PP_Instance instance, PP_FlashCrashKey key, struct PP_Var value); }; struct PPB_Flash_12_6 { void (*SetInstanceAlwaysOnTop)(PP_Instance instance, PP_Bool on_top); PP_Bool (*DrawGlyphs)( PP_Instance instance, PP_Resource pp_image_data, const struct PP_BrowserFont_Trusted_Description* font_desc, uint32_t color, const struct PP_Point* position, const struct PP_Rect* clip, const float transformation[3][3], PP_Bool allow_subpixel_aa, uint32_t glyph_count, const uint16_t glyph_indices[], const struct PP_Point glyph_advances[]); struct PP_Var (*GetProxyForURL)(PP_Instance instance, const char* url); int32_t (*Navigate)(PP_Resource request_info, const char* target, PP_Bool from_user_action); void (*RunMessageLoop)(PP_Instance instance); void (*QuitMessageLoop)(PP_Instance instance); double (*GetLocalTimeZoneOffset)(PP_Instance instance, PP_Time t); struct PP_Var (*GetCommandLineArgs)(PP_Module module); void (*PreloadFontWin)(const void* logfontw); PP_Bool (*IsRectTopmost)(PP_Instance instance, const struct PP_Rect* rect); int32_t (*InvokePrinting)(PP_Instance instance); void (*UpdateActivity)(PP_Instance instance); struct PP_Var (*GetDeviceID)(PP_Instance instance); int32_t (*GetSettingInt)(PP_Instance instance, PP_FlashSetting setting); struct PP_Var (*GetSetting)(PP_Instance instance, PP_FlashSetting setting); PP_Bool (*SetCrashData)(PP_Instance instance, PP_FlashCrashKey key, struct PP_Var value); int32_t (*EnumerateVideoCaptureDevices)(PP_Instance instance, PP_Resource video_capture, struct PP_ArrayOutput devices); }; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_FLASH_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_flash_clipboard.h000066400000000000000000000163361321746453100262100ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_flash_clipboard.idl modified Thu Jan 23 10:16:39 2014. */ #ifndef PPAPI_C_PRIVATE_PPB_FLASH_CLIPBOARD_H_ #define PPAPI_C_PRIVATE_PPB_FLASH_CLIPBOARD_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_FLASH_CLIPBOARD_INTERFACE_4_0 "PPB_Flash_Clipboard;4.0" #define PPB_FLASH_CLIPBOARD_INTERFACE_5_0 "PPB_Flash_Clipboard;5.0" #define PPB_FLASH_CLIPBOARD_INTERFACE_5_1 "PPB_Flash_Clipboard;5.1" #define PPB_FLASH_CLIPBOARD_INTERFACE PPB_FLASH_CLIPBOARD_INTERFACE_5_1 /** * @file * This file defines the private PPB_Flash_Clipboard API used by * Pepper Flash for reading and writing to the clipboard. */ /** * @addtogroup Enums * @{ */ /** * This enumeration contains the types of clipboards that can be accessed. * These types correspond to clipboard types in WebKit. */ typedef enum { /** The standard clipboard. */ PP_FLASH_CLIPBOARD_TYPE_STANDARD = 0, /** The selection clipboard (e.g., on Linux). */ PP_FLASH_CLIPBOARD_TYPE_SELECTION = 1 } PP_Flash_Clipboard_Type; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Flash_Clipboard_Type, 4); /** * This enumeration contains the predefined clipboard data formats. */ typedef enum { /** Indicates an invalid or unsupported clipboard data format. */ PP_FLASH_CLIPBOARD_FORMAT_INVALID = 0, /** * Indicates plaintext clipboard data. The format expected/returned is a * PP_VARTYPE_STRING. */ PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT = 1, /** * Indicates HTML clipboard data. The format expected/returned is a * PP_VARTYPE_STRING. */ PP_FLASH_CLIPBOARD_FORMAT_HTML = 2, /** * Indicates RTF clipboard data. The format expected/returned is a * PP_VARTYPE_ARRAY_BUFFER. */ PP_FLASH_CLIPBOARD_FORMAT_RTF = 3 } PP_Flash_Clipboard_Format; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Flash_Clipboard_Format, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_Flash_Clipboard interface contains pointers to functions * used by Pepper Flash to access the clipboard. * */ struct PPB_Flash_Clipboard_5_1 { /** * Registers a custom clipboard format. The format is identified by a * string. An id identifying the format will be returned if the format is * successfully registered, which can be used to read/write data of that * format. If the format has already been registered, the id associated with * that format will be returned. If the format fails to be registered * PP_FLASH_CLIPBOARD_FORMAT_INVALID will be returned. * * All custom data should be read/written as PP_Var array * buffers. The clipboard format is pepper-specific meaning that although the * data will be stored on the system clipboard, it can only be accessed in a * sensible way by using the pepper API. Data stored in custom formats can * be safely shared between different applications that use pepper. */ uint32_t (*RegisterCustomFormat)(PP_Instance instance_id, const char* format_name); /** * Checks whether a given data format is available from the given clipboard. * Returns true if the given format is available from the given clipboard. */ PP_Bool (*IsFormatAvailable)(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t format); /** * Reads data in the given format from the clipboard. An * undefined PP_Var is returned if there is an error in reading * the clipboard data and a null PP_Var is returned if there is * no data of the specified format to read. */ struct PP_Var (*ReadData)(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t format); /** * Writes the given array of data items to the clipboard. All existing * clipboard data in any format is erased before writing this data. Thus, * passing an array of size 0 has the effect of clearing the clipboard without * writing any data. Each data item in the array should have a different * PP_Flash_Clipboard_Format. If multiple data items have the * same format, only the last item with that format will be written. * If there is an error writing any of the items in the array to the * clipboard, none will be written and an error code is returned. * The error code will be PP_ERROR_NOSPACE if the value is * too large to be written, PP_ERROR_BADARGUMENT if a PP_Var * cannot be converted into the format supplied or PP_FAILED * if the format is not supported. */ int32_t (*WriteData)(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t data_item_count, const uint32_t formats[], const struct PP_Var data_items[]); /** * Gets a sequence number which uniquely identifies clipboard state. This can * be used to version the data on the clipboard and determine whether it has * changed. The sequence number will be placed in |sequence_number| and * PP_TRUE returned if the sequence number was retrieved successfully. */ PP_Bool (*GetSequenceNumber)(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint64_t* sequence_number); }; typedef struct PPB_Flash_Clipboard_5_1 PPB_Flash_Clipboard; struct PPB_Flash_Clipboard_4_0 { PP_Bool (*IsFormatAvailable)(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, PP_Flash_Clipboard_Format format); struct PP_Var (*ReadData)(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, PP_Flash_Clipboard_Format format); int32_t (*WriteData)(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t data_item_count, const PP_Flash_Clipboard_Format formats[], const struct PP_Var data_items[]); }; struct PPB_Flash_Clipboard_5_0 { uint32_t (*RegisterCustomFormat)(PP_Instance instance_id, const char* format_name); PP_Bool (*IsFormatAvailable)(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t format); struct PP_Var (*ReadData)(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t format); int32_t (*WriteData)(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t data_item_count, const uint32_t formats[], const struct PP_Var data_items[]); }; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_FLASH_CLIPBOARD_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_flash_device_id.h000066400000000000000000000030301321746453100261470ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_flash_device_id.idl modified Tue May 14 10:55:27 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_FLASH_DEVICE_ID_H_ #define PPAPI_C_PRIVATE_PPB_FLASH_DEVICE_ID_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_FLASH_DEVICEID_INTERFACE_1_0 "PPB_Flash_DeviceID;1.0" #define PPB_FLASH_DEVICEID_INTERFACE PPB_FLASH_DEVICEID_INTERFACE_1_0 /** * @file * This file contains the PPB_Flash_DeviceID interface. */ /** * @addtogroup Interfaces * @{ */ /* TODO(raymes): This is deprecated by the PPB_Flash_DRM interface. Remove this * interface after a few versions of Chrome have passed. */ struct PPB_Flash_DeviceID_1_0 { PP_Resource (*Create)(PP_Instance instance); /** * Asynchronously computes the device ID. When available, it will place the * string in |*id| and will call the completion callback. On failure the * given var will be PP_VARTYPE_UNDEFINED. */ int32_t (*GetDeviceID)(PP_Resource device_id, struct PP_Var* id, struct PP_CompletionCallback callback); }; typedef struct PPB_Flash_DeviceID_1_0 PPB_Flash_DeviceID; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_FLASH_DEVICE_ID_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_flash_drm.h000066400000000000000000000061401321746453100250230ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_flash_drm.idl modified Mon Nov 11 14:49:53 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_FLASH_DRM_H_ #define PPAPI_C_PRIVATE_PPB_FLASH_DRM_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_FLASH_DRM_INTERFACE_1_0 "PPB_Flash_DRM;1.0" #define PPB_FLASH_DRM_INTERFACE_1_1 "PPB_Flash_DRM;1.1" #define PPB_FLASH_DRM_INTERFACE PPB_FLASH_DRM_INTERFACE_1_1 /** * @file * This file contains the PPB_Flash_DRM interface. */ /** * @addtogroup Interfaces * @{ */ /** * A resource for performing Flash DRM-related operations. */ struct PPB_Flash_DRM_1_1 { /** * Creates a PPB_Flash_DRM resource for performing DRM-related operations in * Flash. */ PP_Resource (*Create)(PP_Instance instance); /** * Asynchronously computes the device ID. When available, it will place the * string in |*id| and will call the completion callback. On failure the * given var will be PP_VARTYPE_UNDEFINED. */ int32_t (*GetDeviceID)(PP_Resource drm, struct PP_Var* id, struct PP_CompletionCallback callback); /** * Windows and Mac only. Synchronously outputs the HMONITOR or * CGDirectDisplayID corresponding to the monitor on which the plugin instance * is displayed in |hmonitor|. This value is queried asynchronously and this * will return PP_FALSE if the value is not yet available or an error * occurred. PP_TRUE is returned on success. */ PP_Bool (*GetHmonitor)(PP_Resource drm, int64_t* hmonitor); /** * Asynchronously returns a PPB_FileRef resource in |file_ref| which points to * the Voucher file for performing DRM verification. |callback| will be called * upon completion. */ int32_t (*GetVoucherFile)(PP_Resource drm, PP_Resource* file_ref, struct PP_CompletionCallback callback); /** * Asynchronously returns a value indicating whether the monitor on which the * plugin instance is displayed is external. |callback| will be called upon * completion. */ int32_t (*MonitorIsExternal)(PP_Resource drm, PP_Bool* is_external, struct PP_CompletionCallback callback); }; typedef struct PPB_Flash_DRM_1_1 PPB_Flash_DRM; struct PPB_Flash_DRM_1_0 { PP_Resource (*Create)(PP_Instance instance); int32_t (*GetDeviceID)(PP_Resource drm, struct PP_Var* id, struct PP_CompletionCallback callback); PP_Bool (*GetHmonitor)(PP_Resource drm, int64_t* hmonitor); int32_t (*GetVoucherFile)(PP_Resource drm, PP_Resource* file_ref, struct PP_CompletionCallback callback); }; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_FLASH_DRM_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_flash_file.h000066400000000000000000000110131321746453100251530ustar00rootroot00000000000000// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef PPAPI_C_PRIVATE_PPB_FLASH_FILE_H_ #define PPAPI_C_PRIVATE_PPB_FLASH_FILE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/private/pp_file_handle.h" struct PP_FileInfo; struct PP_DirEntry_Dev { const char* name; PP_Bool is_dir; }; struct PP_DirContents_Dev { int32_t count; struct PP_DirEntry_Dev* entries; }; // PPB_Flash_File_ModuleLocal -------------------------------------------------- #define PPB_FLASH_FILE_MODULELOCAL_INTERFACE_3_0 "PPB_Flash_File_ModuleLocal;3" #define PPB_FLASH_FILE_MODULELOCAL_INTERFACE \ PPB_FLASH_FILE_MODULELOCAL_INTERFACE_3_0 // This interface provides (for Flash) synchronous access to module-local files. // Module-local file paths are '/'-separated UTF-8 strings, relative to a // module-specific root. struct PPB_Flash_File_ModuleLocal_3_0 { // Deprecated. Returns true. bool (*CreateThreadAdapterForInstance)(PP_Instance instance); // Deprecated. Does nothing. void (*ClearThreadAdapterForInstance)(PP_Instance instance); // Opens a file, returning a file descriptor (posix) or a HANDLE (win32) into // file. The return value is the ppapi error, PP_OK if success, one of the // PP_ERROR_* in case of failure. int32_t (*OpenFile)(PP_Instance instance, const char* path, int32_t mode, PP_FileHandle* file); // Renames a file. The return value is the ppapi error, PP_OK if success, one // of the PP_ERROR_* in case of failure. int32_t (*RenameFile)(PP_Instance instance, const char* path_from, const char* path_to); // Deletes a file or directory. If recursive is set and the path points to a // directory, deletes all the contents of the directory. The return value is // the ppapi error, PP_OK if success, one of the PP_ERROR_* in case of // failure. int32_t (*DeleteFileOrDir)(PP_Instance instance, const char* path, PP_Bool recursive); // Creates a directory. The return value is the ppapi error, PP_OK if success, // one of the PP_ERROR_* in case of failure. int32_t (*CreateDir)(PP_Instance instance, const char* path); // Queries information about a file. The return value is the ppapi error, // PP_OK if success, one of the PP_ERROR_* in case of failure. int32_t (*QueryFile)(PP_Instance instance, const char* path, struct PP_FileInfo* info); // Gets the list of files contained in a directory. The return value is the // ppapi error, PP_OK if success, one of the PP_ERROR_* in case of failure. If // non-NULL, the returned contents should be freed with FreeDirContents. int32_t (*GetDirContents)(PP_Instance instance, const char* path, struct PP_DirContents_Dev** contents); // Frees the data allocated by GetDirContents. void (*FreeDirContents)(PP_Instance instance, struct PP_DirContents_Dev* contents); // Creates a temporary file. The file will be automatically deleted when all // handles to it are closed. // Returns PP_OK if successful, one of the PP_ERROR_* values in case of // failure. // // If successful, |file| is set to a file descriptor (posix) or a HANDLE // (win32) to the file. If failed, |file| is not touched. int32_t (*CreateTemporaryFile)(PP_Instance instance, PP_FileHandle* file); }; typedef struct PPB_Flash_File_ModuleLocal_3_0 PPB_Flash_File_ModuleLocal; // PPB_Flash_File_FileRef ------------------------------------------------------ #define PPB_FLASH_FILE_FILEREF_INTERFACE "PPB_Flash_File_FileRef;2" // This interface provides (for Flash) synchronous access to files whose paths // are given by a Pepper FileRef. Such FileRefs are typically obtained via the // Pepper file chooser. struct PPB_Flash_File_FileRef { // The functions below correspond exactly to their module-local counterparts // (except in taking FileRefs instead of paths, of course). We omit the // functionality which we do not provide for FileRefs. int32_t (*OpenFile)(PP_Resource file_ref_id, int32_t mode, PP_FileHandle* file); int32_t (*QueryFile)(PP_Resource file_ref_id, struct PP_FileInfo* info); }; #endif // PPAPI_C_PRIVATE_PPB_FLASH_FILE_H_ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_flash_font_file.h000066400000000000000000000051641321746453100262130ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_flash_font_file.idl modified Fri Oct 23 10:34:57 2015. */ #ifndef PPAPI_C_PRIVATE_PPB_FLASH_FONT_FILE_H_ #define PPAPI_C_PRIVATE_PPB_FLASH_FONT_FILE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/private/pp_private_font_charset.h" #include "ppapi/c/trusted/ppb_browser_font_trusted.h" #define PPB_FLASH_FONTFILE_INTERFACE_0_1 "PPB_Flash_FontFile;0.1" #define PPB_FLASH_FONTFILE_INTERFACE_0_2 "PPB_Flash_FontFile;0.2" #define PPB_FLASH_FONTFILE_INTERFACE PPB_FLASH_FONTFILE_INTERFACE_0_2 /** * @file * This file contains the PPB_Flash_FontFile interface. */ /** * @addtogroup Interfaces * @{ */ struct PPB_Flash_FontFile_0_2 { /* Returns a resource identifying a font file corresponding to the given font * request after applying the browser-specific fallback. */ PP_Resource (*Create)( PP_Instance instance, const struct PP_BrowserFont_Trusted_Description* description, PP_PrivateFontCharset charset); /* Determines if a given resource is Flash font file. */ PP_Bool (*IsFlashFontFile)(PP_Resource resource); /* Returns the requested font table. * |output_length| should pass in the size of |output|. And it will return * the actual length of returned data. |output| could be NULL in order to * query the size of the buffer size needed. In that case, the input value of * |output_length| is ignored. * Note: it is Linux only and fails directly on other platforms. */ PP_Bool (*GetFontTable)(PP_Resource font_file, uint32_t table, void* output, uint32_t* output_length); /** * Returns whether PPB_Flash_FontFile is supported on Windows. */ PP_Bool (*IsSupportedForWindows)(void); }; typedef struct PPB_Flash_FontFile_0_2 PPB_Flash_FontFile; struct PPB_Flash_FontFile_0_1 { PP_Resource (*Create)( PP_Instance instance, const struct PP_BrowserFont_Trusted_Description* description, PP_PrivateFontCharset charset); PP_Bool (*IsFlashFontFile)(PP_Resource resource); PP_Bool (*GetFontTable)(PP_Resource font_file, uint32_t table, void* output, uint32_t* output_length); }; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_FLASH_FONT_FILE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_flash_fullscreen.h000066400000000000000000000042401321746453100264020ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_flash_fullscreen.idl modified Tue Sep 11 13:52:24 2012. */ #ifndef PPAPI_C_PRIVATE_PPB_FLASH_FULLSCREEN_H_ #define PPAPI_C_PRIVATE_PPB_FLASH_FULLSCREEN_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #define PPB_FLASHFULLSCREEN_INTERFACE_0_1 "PPB_FlashFullscreen;0.1" #define PPB_FLASHFULLSCREEN_INTERFACE_1_0 "PPB_FlashFullscreen;1.0" #define PPB_FLASHFULLSCREEN_INTERFACE PPB_FLASHFULLSCREEN_INTERFACE_1_0 /** * @file * This file defines the PPB_FlashFullscreen interface. */ /** * @addtogroup Interfaces * @{ */ struct PPB_FlashFullscreen_1_0 { /** * Checks whether the plugin instance is currently in fullscreen mode. */ PP_Bool (*IsFullscreen)(PP_Instance instance); /** * Switches the plugin instance to/from fullscreen mode. Returns PP_TRUE on * success, PP_FALSE on failure. * * This does not unbind the current Graphics2D or Graphics3D. Pending flushes * and swapbuffers will execute as if the resource was off-screen. The * transition is asynchronous. During the transition, IsFullscreen will * return PP_FALSE, and no Graphics2D or Graphics3D can be bound. The * transition ends at the next DidChangeView when going into fullscreen mode. * The transition out of fullscreen mode is synchronous. */ PP_Bool (*SetFullscreen)(PP_Instance instance, PP_Bool fullscreen); /** * Gets the size of the screen in pixels. When going fullscreen, the instance * will be resized to that size. */ PP_Bool (*GetScreenSize)(PP_Instance instance, struct PP_Size* size); }; typedef struct PPB_FlashFullscreen_1_0 PPB_FlashFullscreen; struct PPB_FlashFullscreen_0_1 { PP_Bool (*IsFullscreen)(PP_Instance instance); PP_Bool (*SetFullscreen)(PP_Instance instance, PP_Bool fullscreen); PP_Bool (*GetScreenSize)(PP_Instance instance, struct PP_Size* size); }; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_FLASH_FULLSCREEN_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_flash_menu.h000066400000000000000000000045121321746453100252060ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_flash_menu.idl modified Tue Dec 11 13:47:09 2012. */ #ifndef PPAPI_C_PRIVATE_PPB_FLASH_MENU_H_ #define PPAPI_C_PRIVATE_PPB_FLASH_MENU_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" /* Struct prototypes */ struct PP_Flash_Menu; #define PPB_FLASH_MENU_INTERFACE_0_2 "PPB_Flash_Menu;0.2" #define PPB_FLASH_MENU_INTERFACE PPB_FLASH_MENU_INTERFACE_0_2 /** * @file * This file defines the PPB_Flash_Menu interface. */ /** * @addtogroup Enums * @{ */ /* Menu item type. * * TODO(viettrungluu): Radio items not supported yet. Will also probably want * special menu items tied to clipboard access. */ typedef enum { PP_FLASH_MENUITEM_TYPE_NORMAL = 0, PP_FLASH_MENUITEM_TYPE_CHECKBOX = 1, PP_FLASH_MENUITEM_TYPE_SEPARATOR = 2, PP_FLASH_MENUITEM_TYPE_SUBMENU = 3 } PP_Flash_MenuItem_Type; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Flash_MenuItem_Type, 4); /** * @} */ /** * @addtogroup Structs * @{ */ struct PP_Flash_MenuItem { PP_Flash_MenuItem_Type type; char* name; int32_t id; PP_Bool enabled; PP_Bool checked; struct PP_Flash_Menu* submenu; }; struct PP_Flash_Menu { uint32_t count; struct PP_Flash_MenuItem *items; }; /** * @} */ /** * @addtogroup Interfaces * @{ */ struct PPB_Flash_Menu_0_2 { PP_Resource (*Create)(PP_Instance instance_id, const struct PP_Flash_Menu* menu_data); PP_Bool (*IsFlashMenu)(PP_Resource resource_id); /* Display a context menu at the given location. If the user selects an item, * |selected_id| will be set to its |id| and the callback called with |PP_OK|. * If the user dismisses the menu without selecting an item, * |PP_ERROR_USERCANCEL| will be indicated. */ int32_t (*Show)(PP_Resource menu_id, const struct PP_Point* location, int32_t* selected_id, struct PP_CompletionCallback callback); }; typedef struct PPB_Flash_Menu_0_2 PPB_Flash_Menu; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_FLASH_MENU_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_flash_message_loop.h000066400000000000000000000063241321746453100267220ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_flash_message_loop.idl modified Tue Jan 17 17:48:30 2012. */ #ifndef PPAPI_C_PRIVATE_PPB_FLASH_MESSAGE_LOOP_H_ #define PPAPI_C_PRIVATE_PPB_FLASH_MESSAGE_LOOP_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_FLASH_MESSAGELOOP_INTERFACE_0_1 "PPB_Flash_MessageLoop;0.1" #define PPB_FLASH_MESSAGELOOP_INTERFACE PPB_FLASH_MESSAGELOOP_INTERFACE_0_1 /** * @file * This file contains the PPB_Flash_MessageLoop interface. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_Flash_MessageLoop interface supports Pepper Flash to run * nested message loops. */ struct PPB_Flash_MessageLoop_0_1 { /** * Allocates a Flash message loop resource. * * @param[in] instance A PP_Instance identifying one instance * of a module. * * @return A PP_Resource that can be used to run a nested message * loop if successful; 0 if failed. */ PP_Resource (*Create)(PP_Instance instance); /** * Determines if a given resource is a Flash message loop. * * @param[in] resource A PP_Resource corresponding to a generic * resource. * * @return A PP_Bool that is PP_TRUE if the given * resource is a Flash message loop, otherwise PP_FALSE. */ PP_Bool (*IsFlashMessageLoop)(PP_Resource resource); /** * Runs a nested message loop. The plugin will be reentered from this call. * This function is used in places where Flash would normally enter a nested * message loop (e.g., when displaying context menus), but Pepper provides * only an asynchronous call. After performing that asynchronous call, call * Run(). In the callback, call Quit(). * * For a given message loop resource, only the first call to * Run() will start a nested message loop. The subsequent calls * will return PP_ERROR_FAILED immediately. * * @param[in] flash_message_loop The Flash message loop. * * @return PP_ERROR_ABORTED if the message loop quits because the * resource is destroyed; PP_OK if the message loop quits because * of other reasons (e.g., Quit() is called); * PP_ERROR_FAILED if this is not the first call to * Run(). */ int32_t (*Run)(PP_Resource flash_message_loop); /** * Signals to quit the outermost nested message loop. Use this to exit and * return back to the caller after you call Run(). * * If Quit() is not called to balance the call to * Run(), the outermost nested message loop will be quit * implicitly when the resource is destroyed. * * @param[in] flash_message_loop The Flash message loop. */ void (*Quit)(PP_Resource flash_message_loop); }; typedef struct PPB_Flash_MessageLoop_0_1 PPB_Flash_MessageLoop; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_FLASH_MESSAGE_LOOP_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_flash_print.h000066400000000000000000000020311321746453100253700ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_flash_print.idl modified Tue Apr 24 16:55:10 2012. */ #ifndef PPAPI_C_PRIVATE_PPB_FLASH_PRINT_H_ #define PPAPI_C_PRIVATE_PPB_FLASH_PRINT_H_ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #define PPB_FLASH_PRINT_INTERFACE_1_0 "PPB_Flash_Print;1.0" #define PPB_FLASH_PRINT_INTERFACE PPB_FLASH_PRINT_INTERFACE_1_0 /** * @file * This file contains the PPB_Flash_Print interface. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_Flash_Print interface contains Flash-specific printing * functionality. */ struct PPB_Flash_Print_1_0 { /** * Invokes printing on the given plugin instance. */ void (*InvokePrinting)(PP_Instance instance); }; typedef struct PPB_Flash_Print_1_0 PPB_Flash_Print; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_FLASH_PRINT_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_host_resolver_private.h000066400000000000000000000063331321746453100275200ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_host_resolver_private.idl, * modified Mon Jun 24 09:49:40 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_HOST_RESOLVER_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_HOST_RESOLVER_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/private/ppb_net_address_private.h" #define PPB_HOSTRESOLVER_PRIVATE_INTERFACE_0_1 "PPB_HostResolver_Private;0.1" #define PPB_HOSTRESOLVER_PRIVATE_INTERFACE \ PPB_HOSTRESOLVER_PRIVATE_INTERFACE_0_1 /** * @file * This file defines the PPB_HostResolver_Private interface. */ /** * @addtogroup Enums * @{ */ /** * The PP_HostResolver_Flags is an enumeration of the * different types of flags, that can be OR-ed and passed to host * resolver. */ typedef enum { /** * AI_CANONNAME */ PP_HOST_RESOLVER_PRIVATE_FLAGS_CANONNAME = 1 << 0, /** * Hint to the resolver that only loopback addresses are configured. */ PP_HOST_RESOLVER_PRIVATE_FLAGS_LOOPBACK_ONLY = 1 << 1 } PP_HostResolver_Private_Flags; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_HostResolver_Private_Flags, 4); /** * @} */ /** * @addtogroup Structs * @{ */ struct PP_HostResolver_Private_Hint { PP_NetAddressFamily_Private family; int32_t flags; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_HostResolver_Private_Hint, 8); /** * @} */ /** * @addtogroup Interfaces * @{ */ struct PPB_HostResolver_Private_0_1 { /** * Allocates a Host Resolver resource. */ PP_Resource (*Create)(PP_Instance instance); /** * Determines if a given resource is a Host Resolver. */ PP_Bool (*IsHostResolver)(PP_Resource resource); /** * Creates a new request to Host Resolver. |callback| is invoked * when request is processed and a list of network addresses is * obtained. These addresses can be be used in Connect, Bind or * Listen calls to connect to a given |host| and |port|. */ int32_t (*Resolve)(PP_Resource host_resolver, const char* host, uint16_t port, const struct PP_HostResolver_Private_Hint* hint, struct PP_CompletionCallback callback); /** * Returns canonical name of host. */ struct PP_Var (*GetCanonicalName)(PP_Resource host_resolver); /** * Returns number of network addresses obtained after Resolve call. */ uint32_t (*GetSize)(PP_Resource host_resolver); /** * Stores in the |addr| |index|-th network address. |addr| can't be * NULL. Returns PP_TRUE if success or PP_FALSE if the given * resource is not a Host Resolver or |index| exceeds number of * available addresses. */ PP_Bool (*GetNetAddress)(PP_Resource host_resolver, uint32_t index, struct PP_NetAddress_Private* addr); }; typedef struct PPB_HostResolver_Private_0_1 PPB_HostResolver_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_HOST_RESOLVER_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_instance_private.h000066400000000000000000000065631321746453100264330ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_instance_private.idl modified Tue Jul 23 13:19:04 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_INSTANCE_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_INSTANCE_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_INSTANCE_PRIVATE_INTERFACE_0_1 "PPB_Instance_Private;0.1" #define PPB_INSTANCE_PRIVATE_INTERFACE PPB_INSTANCE_PRIVATE_INTERFACE_0_1 /** * @file * This file defines the PPB_Instance_Private interface implemented by the * browser and containing pointers to functions available only to trusted plugin * instances. */ /** * @addtogroup Enums * @{ */ /** * The PP_ExternalPluginResult enum contains result codes from * launching an external plugin. */ typedef enum { /** Successful external plugin call */ PP_EXTERNAL_PLUGIN_OK = 0, /** Unspecified external plugin error */ PP_EXTERNAL_PLUGIN_FAILED = 1, /** Error creating the module */ PP_EXTERNAL_PLUGIN_ERROR_MODULE = 2, /** Error creating and initializing the instance */ PP_EXTERNAL_PLUGIN_ERROR_INSTANCE = 3 } PP_ExternalPluginResult; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_ExternalPluginResult, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_Instance_Private interface contains functions available only to * trusted plugin instances. * */ struct PPB_Instance_Private_0_1 { /** * GetWindowObject is a pointer to a function that determines * the DOM window containing this module instance. * * @param[in] instance A PP_Instance whose WindowObject should be retrieved. * @return A PP_Var containing window object on success. */ struct PP_Var (*GetWindowObject)(PP_Instance instance); /** * GetOwnerElementObject is a pointer to a function that determines * the DOM element containing this module instance. * * @param[in] instance A PP_Instance whose WindowObject should be retrieved. * @return A PP_Var containing DOM element on success. */ struct PP_Var (*GetOwnerElementObject)(PP_Instance instance); /** * ExecuteScript is a pointer to a function that executes the given * script in the context of the frame containing the module. * * The exception, if any, will be returned in *exception. As with the PPB_Var * interface, the exception parameter, if non-NULL, must be initialized * to a "void" var or the function will immediately return. On success, * the exception parameter will be set to a "void" var. On failure, the * return value will be a "void" var. * * @param[in] script A string containing the JavaScript to execute. * @param[in/out] exception PP_Var containing the exception. Initialize * this to NULL if you don't want exception info; initialize this to a void * exception if want exception info. * * @return The result of the script execution, or a "void" var * if execution failed. */ struct PP_Var (*ExecuteScript)(PP_Instance instance, struct PP_Var script, struct PP_Var* exception); }; typedef struct PPB_Instance_Private_0_1 PPB_Instance_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_INSTANCE_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_isolated_file_system_private.h000066400000000000000000000050161321746453100310260ustar00rootroot00000000000000/* Copyright 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_isolated_file_system_private.idl, * modified Fri Nov 8 02:21:15 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_ISOLATED_FILE_SYSTEM_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_ISOLATED_FILE_SYSTEM_PRIVATE_H_ #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_ISOLATEDFILESYSTEM_PRIVATE_INTERFACE_0_2 \ "PPB_IsolatedFileSystem_Private;0.2" #define PPB_ISOLATEDFILESYSTEM_PRIVATE_INTERFACE \ PPB_ISOLATEDFILESYSTEM_PRIVATE_INTERFACE_0_2 /** * @file */ /** * @addtogroup Enums * @{ */ /** * The PP_IsolatedFileSystemType_Private values indicate the type * of isolated file systems. */ typedef enum { /** Type for invalid file systems */ PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_INVALID = 0, /** Type for CRX file systems */ PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_CRX = 1, /** Type for PluginPrivate file systems */ PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_PLUGINPRIVATE = 2 } PP_IsolatedFileSystemType_Private; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_IsolatedFileSystemType_Private, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /* PPB_IsolatedFileSystem_Private interface */ struct PPB_IsolatedFileSystem_Private_0_2 { /** * Open() opens a file system corresponding the given file system type. * * When opening the CRX file system, this should be called from an extension * context, otherwise it will fail. * * @param[in] instance A PP_Instance identifying the instance * with the file system. * @param[in] type A file system type as defined by * PP_IsolatedFileSystemType_Private enum. * @param[out] file_system An output PP_Resource corresponding * to a PPB_FileSystem. * @param[in] callback A PP_CompletionCallback to be called upon * completion of Open. * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*Open)(PP_Instance instance, PP_IsolatedFileSystemType_Private type, PP_Resource* file_system, struct PP_CompletionCallback callback); }; typedef struct PPB_IsolatedFileSystem_Private_0_2 PPB_IsolatedFileSystem_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_ISOLATED_FILE_SYSTEM_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_net_address_private.h000066400000000000000000000146011321746453100271120ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_net_address_private.idl, * modified Mon Jun 24 09:52:39 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_NET_ADDRESS_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_NET_ADDRESS_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_NETADDRESS_PRIVATE_INTERFACE_0_1 "PPB_NetAddress_Private;0.1" #define PPB_NETADDRESS_PRIVATE_INTERFACE_1_0 "PPB_NetAddress_Private;1.0" #define PPB_NETADDRESS_PRIVATE_INTERFACE_1_1 "PPB_NetAddress_Private;1.1" #define PPB_NETADDRESS_PRIVATE_INTERFACE PPB_NETADDRESS_PRIVATE_INTERFACE_1_1 /** * @file * This file defines the PPB_NetAddress_Private interface. */ /** * @addtogroup Enums * @{ */ typedef enum { /** * The address family is unspecified. */ PP_NETADDRESSFAMILY_PRIVATE_UNSPECIFIED = 0, /** * The Internet Protocol version 4 (IPv4) address family. */ PP_NETADDRESSFAMILY_PRIVATE_IPV4 = 1, /** * The Internet Protocol version 6 (IPv6) address family. */ PP_NETADDRESSFAMILY_PRIVATE_IPV6 = 2 } PP_NetAddressFamily_Private; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_NetAddressFamily_Private, 4); /** * @} */ /** * @addtogroup Structs * @{ */ /** * This is an opaque type holding a network address. Plugins must * never access members of this struct directly. */ struct PP_NetAddress_Private { uint32_t size; char data[128]; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_NetAddress_Private, 132); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_NetAddress_Private interface provides operations on * network addresses. */ struct PPB_NetAddress_Private_1_1 { /** * Returns PP_TRUE if the two addresses are equal (host and port). */ PP_Bool (*AreEqual)(const struct PP_NetAddress_Private* addr1, const struct PP_NetAddress_Private* addr2); /** * Returns PP_TRUE if the two addresses refer to the same host. */ PP_Bool (*AreHostsEqual)(const struct PP_NetAddress_Private* addr1, const struct PP_NetAddress_Private* addr2); /** * Returns a human-readable description of the network address, optionally * including the port (e.g., "192.168.0.1", "192.168.0.1:99", or "[::1]:80"), * or an undefined var on failure. */ struct PP_Var (*Describe)(PP_Module module, const struct PP_NetAddress_Private* addr, PP_Bool include_port); /** * Replaces the port in the given source address. Returns PP_TRUE on success. */ PP_Bool (*ReplacePort)(const struct PP_NetAddress_Private* src_addr, uint16_t port, struct PP_NetAddress_Private* addr_out); /** * Gets the "any" address (for IPv4 or IPv6); for use with UDP Bind. */ void (*GetAnyAddress)(PP_Bool is_ipv6, struct PP_NetAddress_Private* addr); /** * Gets the address family. */ PP_NetAddressFamily_Private (*GetFamily)( const struct PP_NetAddress_Private* addr); /** * Gets the port. The port is returned in host byte order. */ uint16_t (*GetPort)(const struct PP_NetAddress_Private* addr); /** * Gets the address. The output, address, must be large enough for the * current socket family. The output will be the binary representation of an * address for the current socket family. For IPv4 and IPv6 the address is in * network byte order. PP_TRUE is returned if the address was successfully * retrieved. */ PP_Bool (*GetAddress)(const struct PP_NetAddress_Private* addr, void* address, uint16_t address_size); /** * Returns ScopeID for IPv6 addresses or 0 for IPv4. */ uint32_t (*GetScopeID)(const struct PP_NetAddress_Private* addr); /** * Creates NetAddress with the specified IPv4 address and port * number. */ void (*CreateFromIPv4Address)(const uint8_t ip[4], uint16_t port, struct PP_NetAddress_Private* addr_out); /** * Creates NetAddress with the specified IPv6 address, scope_id and * port number. */ void (*CreateFromIPv6Address)(const uint8_t ip[16], uint32_t scope_id, uint16_t port, struct PP_NetAddress_Private* addr_out); }; typedef struct PPB_NetAddress_Private_1_1 PPB_NetAddress_Private; struct PPB_NetAddress_Private_0_1 { PP_Bool (*AreEqual)(const struct PP_NetAddress_Private* addr1, const struct PP_NetAddress_Private* addr2); PP_Bool (*AreHostsEqual)(const struct PP_NetAddress_Private* addr1, const struct PP_NetAddress_Private* addr2); struct PP_Var (*Describe)(PP_Module module, const struct PP_NetAddress_Private* addr, PP_Bool include_port); PP_Bool (*ReplacePort)(const struct PP_NetAddress_Private* src_addr, uint16_t port, struct PP_NetAddress_Private* addr_out); void (*GetAnyAddress)(PP_Bool is_ipv6, struct PP_NetAddress_Private* addr); }; struct PPB_NetAddress_Private_1_0 { PP_Bool (*AreEqual)(const struct PP_NetAddress_Private* addr1, const struct PP_NetAddress_Private* addr2); PP_Bool (*AreHostsEqual)(const struct PP_NetAddress_Private* addr1, const struct PP_NetAddress_Private* addr2); struct PP_Var (*Describe)(PP_Module module, const struct PP_NetAddress_Private* addr, PP_Bool include_port); PP_Bool (*ReplacePort)(const struct PP_NetAddress_Private* src_addr, uint16_t port, struct PP_NetAddress_Private* addr_out); void (*GetAnyAddress)(PP_Bool is_ipv6, struct PP_NetAddress_Private* addr); PP_NetAddressFamily_Private (*GetFamily)( const struct PP_NetAddress_Private* addr); uint16_t (*GetPort)(const struct PP_NetAddress_Private* addr); PP_Bool (*GetAddress)(const struct PP_NetAddress_Private* addr, void* address, uint16_t address_size); }; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_NET_ADDRESS_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_output_protection_private.h000066400000000000000000000141741321746453100304320ustar00rootroot00000000000000/* Copyright 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_output_protection_private.idl, * modified Tue Oct 8 13:22:13 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_OUTPUT_PROTECTION_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_OUTPUT_PROTECTION_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_OUTPUTPROTECTION_PRIVATE_INTERFACE_0_1 \ "PPB_OutputProtection_Private;0.1" #define PPB_OUTPUTPROTECTION_PRIVATE_INTERFACE \ PPB_OUTPUTPROTECTION_PRIVATE_INTERFACE_0_1 /** * @file * This file defines the API for output protection. Currently, it only supports * Chrome OS. */ /** * @addtogroup Enums * @{ */ /** * Content protection methods applied on video output link. */ typedef enum { PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE = 0, PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP = 1 << 0 } PP_OutputProtectionMethod_Private; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_OutputProtectionMethod_Private, 4); /** * Video output link types. */ typedef enum { PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NONE = 0, PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_UNKNOWN = 1 << 0, PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_INTERNAL = 1 << 1, PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_VGA = 1 << 2, PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_HDMI = 1 << 3, PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DVI = 1 << 4, PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DISPLAYPORT = 1 << 5, PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NETWORK = 1 << 6 } PP_OutputProtectionLinkType_Private; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_OutputProtectionLinkType_Private, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_OutputProtection_Private interface allows controlling * output protection. * * Example: * * @code * op = output_protection->Create(instance); * output_protection->QueryStatus(op, &link_mask, &protection_mask, * done_callback); * @endcode * * In this example, the plugin wants to enforce HDCP for HDMI link. * @code * if (link_mask & PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_HDMI) { * output_protection->EnableProtection( * op, PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP, done_callback); * } * @endcode * * After EnableProtection() completes, the plugin has to query protection * status periodically to make sure the protection is enabled and remains * enabled. */ struct PPB_OutputProtection_Private_0_1 { /** * Create() creates a new PPB_OutputProtection_Private object. * * @pram[in] instance A PP_Instance identifying one instance of * a module. * * @return A PP_Resource corresponding to a * PPB_OutputProtection_Private if successful, 0 if creation * failed. */ PP_Resource (*Create)(PP_Instance instance); /** * IsOutputProtection() determines if the provided resource is a * PPB_OutputProtection_Private. * * @param[in] resource A PP_Resource corresponding to a * PPB_OutputProtection_Private. * * @return PP_TRUE if the resource is a * PPB_OutputProtection_Private, PP_FALSE if the * resource is invalid or some type other than * PPB_OutputProtection_Private. */ PP_Bool (*IsOutputProtection)(PP_Resource resource); /** * Query link status and protection status. * Clients have to query status periodically in order to detect changes. * * @param[in] resource A PP_Resource corresponding to a * PPB_OutputProtection_Private. * @param[out] link_mask The type of connected output links, which is a * bit-mask of the PP_OutputProtectionLinkType_Private values. * @param[out] protection_mask Enabled protection methods, which is a * bit-mask of the PP_OutputProtectionMethod_Private values. * @param[in] callback A PP_CompletionCallback to run on * asynchronous completion of QueryStatus(). This callback will only run if * QueryStatus() returns PP_OK_COMPLETIONPENDING. * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*QueryStatus)(PP_Resource resource, uint32_t* link_mask, uint32_t* protection_mask, struct PP_CompletionCallback callback); /** * Set desired protection methods. * * When the desired protection method(s) have been applied to all applicable * output links, the relevant bit(s) of the protection_mask returned by * QueryStatus() will be set. Otherwise, the relevant bit(s) of * protection_mask will not be set; there is no separate error code or * callback. * * Protections will be disabled if no longer desired by all instances. * * @param[in] resource A PP_Resource corresponding to a * PPB_OutputProtection_Private. * @param[in] desired_protection_mask The desired protection methods, which * is a bit-mask of the PP_OutputProtectionMethod_Private * values. * @param[in] callback A PP_CompletionCallback to be called with * PP_OK when the protection request has been made. This may be * before the protection have actually been applied. Call QueryStatus to get * protection status. If it failed to make the protection request, the * callback is called with PP_ERROR_FAILED and there is no need * to call QueryStatus(). * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*EnableProtection)(PP_Resource resource, uint32_t desired_protection_mask, struct PP_CompletionCallback callback); }; typedef struct PPB_OutputProtection_Private_0_1 PPB_OutputProtection_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_OUTPUT_PROTECTION_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_pdf.h000066400000000000000000000067561321746453100236520ustar00rootroot00000000000000// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef PPAPI_C_PRIVATE_PPB_PDF_H_ #define PPAPI_C_PRIVATE_PPB_PDF_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/private/pp_private_font_charset.h" #define PPB_PDF_INTERFACE "PPB_PDF;1" typedef enum { PP_PDFFEATURE_HIDPI = 0, PP_PDFFEATURE_PRINTING = 1 } PP_PDFFeature; struct PP_PrivateFontFileDescription { const char* face; uint32_t weight; bool italic; }; struct PP_PrivateFindResult { int start_index; int length; }; struct PPB_PDF { // Returns a resource identifying a font file corresponding to the given font // request after applying the browser-specific fallback. // // Currently Linux-only. PP_Resource (*GetFontFileWithFallback)( PP_Instance instance, const struct PP_BrowserFont_Trusted_Description* description, PP_PrivateFontCharset charset); // Given a resource previously returned by GetFontFileWithFallback, returns // a pointer to the requested font table. Linux only. bool (*GetFontTableForPrivateFontFile)(PP_Resource font_file, uint32_t table, void* output, uint32_t* output_length); // Search the given string using ICU. Use PPB_Core's MemFree on results when // done. void (*SearchString)( PP_Instance instance, const unsigned short* string, const unsigned short* term, bool case_sensitive, struct PP_PrivateFindResult** results, int* count); // Since WebFrame doesn't know about PPAPI requests, it'll think the page has // finished loading even if there are outstanding requests by the plugin. // Take this out once WebFrame knows about requests by PPAPI plugins. void (*DidStartLoading)(PP_Instance instance); void (*DidStopLoading)(PP_Instance instance); // Sets content restriction for a full-page plugin (i.e. can't copy/print). // The value is a bitfield of ContentRestriction enums. void (*SetContentRestriction)(PP_Instance instance, int restrictions); // Notifies the browser that the given action has been performed. void (*UserMetricsRecordAction)(PP_Instance instance, struct PP_Var action); // Notifies the browser that the PDF has an unsupported feature. void (*HasUnsupportedFeature)(PP_Instance instance); // Invoke SaveAs... dialog, similar to the right-click or wrench menu. void (*SaveAs)(PP_Instance instance); // Invoke Print dialog for plugin. void (*Print)(PP_Instance instance); PP_Bool(*IsFeatureEnabled)(PP_Instance instance, PP_PDFFeature feature); // Sets the selected text of the plugin. void(*SetSelectedText)(PP_Instance instance, const char* selected_text); // Sets the link currently under the cursor. void (*SetLinkUnderCursor)(PP_Instance instance, const char* url); // Gets pointers to both the mmap'd V8 snapshot files and their sizes. // This is needed when loading V8's initial snapshot from external files. void (*GetV8ExternalSnapshotData)(PP_Instance instance, const char** natives_data_out, int* natives_size_out, const char** snapshot_data_out, int* snapshot_size_out); }; #endif // PPAPI_C_PRIVATE_PPB_PDF_H_ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_platform_verification_private.h000066400000000000000000000076711321746453100312160ustar00rootroot00000000000000/* Copyright 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_platform_verification_private.idl, * modified Fri Oct 18 15:02:09 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_PLATFORM_VERIFICATION_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_PLATFORM_VERIFICATION_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_2 \ "PPB_PlatformVerification_Private;0.2" #define PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE \ PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_2 /** * @file * This file defines the API for platform verification. Currently, it only * supports Chrome OS. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_PlatformVerification_Private interface allows authorized * services to verify that the underlying platform is trusted. An example of a * trusted platform is a Chrome OS device in verified boot mode. */ struct PPB_PlatformVerification_Private_0_2 { /** * Create() creates a PPB_PlatformVerification_Private object. * * @pram[in] instance A PP_Instance identifying one instance of * a module. * * @return A PP_Resource corresponding to a * PPB_PlatformVerification_Private if successful, 0 if creation * failed. */ PP_Resource (*Create)(PP_Instance instance); /** * IsPlatformVerification() determines if the provided resource is a * PPB_PlatformVerification_Private. * * @param[in] resource A PP_Resource corresponding to a * PPB_PlatformVerification_Private. * * @return PP_TRUE if the resource is a * PPB_PlatformVerification_Private, PP_FALSE if the * resource is invalid or some type other than * PPB_PlatformVerification_Private. */ PP_Bool (*IsPlatformVerification)(PP_Resource resource); /** * Requests a platform challenge for a given service id. * * @param[in] service_id A PP_Var of type * PP_VARTYPE_STRING containing the service_id for the challenge. * * @param[in] challenge A PP_Var of type * PP_VARTYPE_ARRAY_BUFFER that contains the challenge data. * * @param[out] signed_data A PP_Var of type * PP_VARTYPE_ARRAY_BUFFER that contains the data signed by the * platform. * * @param[out] signed_data_signature A PP_Var of type * PP_VARTYPE_ARRAY_BUFFER that contains the signature of the * signed data block. * * @param[out] platform_key_certificate A PP_Var of type * PP_VARTYPE_STRING that contains the device specific * certificate for the requested service_id. * * @param[in] callback A PP_CompletionCallback to be called after * the platform challenge has been completed. This callback will only run if * the return code is PP_OK_COMPLETIONPENDING. * * @return An int32_t containing an error code from pp_errors.h. */ int32_t (*ChallengePlatform)(PP_Resource instance, struct PP_Var service_id, struct PP_Var challenge, struct PP_Var* signed_data, struct PP_Var* signed_data_signature, struct PP_Var* platform_key_certificate, struct PP_CompletionCallback callback); }; typedef struct PPB_PlatformVerification_Private_0_2 PPB_PlatformVerification_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_PLATFORM_VERIFICATION_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_proxy_private.h000066400000000000000000000035601321746453100260020ustar00rootroot00000000000000// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef PPAPI_C_PRIVATE_PROXY_PRIVATE_H_ #define PPAPI_C_PRIVATE_PROXY_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #define PPB_PROXY_PRIVATE_INTERFACE "PPB_Proxy_Private;6" // Exposes functions needed by the out-of-process proxy to call into the // renderer PPAPI implementation. struct PPB_Proxy_Private { // Called when the given plugin process has crashed. void (*PluginCrashed)(PP_Module module); // Returns the instance for the given resource, or 0 on failure. PP_Instance (*GetInstanceForResource)(PP_Resource resource); // Sets a callback that will be used to make sure that PP_Instance IDs // are unique in the plugin. // // Since the plugin may be shared between several browser processes, we need // to do extra work to make sure that an instance ID is globally unqiue. The // given function will be called and will return true if the given // PP_Instance is OK to use in the plugin. It will then be marked as "in use" // On failure (returns false), the host implementation will generate a new // instance ID and try again. void (*SetReserveInstanceIDCallback)( PP_Module module, PP_Bool (*is_seen)(PP_Module, PP_Instance)); // Allows adding additional refcounts to the PluginModule that owns the // proxy dispatcher (and all interface proxies). For every AddRef call // there must be a corresponding release call. void (*AddRefModule)(PP_Module module); void (*ReleaseModule)(PP_Module module); // Allows asserts to be written for some bad conditions while cleaning up. PP_Bool (*IsInModuleDestructor)(PP_Module module); }; #endif // PPAPI_C_PRIVATE_PROXY_PRIVATE_H_ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_tcp_server_socket_private.h000066400000000000000000000074621321746453100303520ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_tcp_server_socket_private.idl, * modified Mon May 20 12:45:38 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_TCP_SERVER_SOCKET_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_TCP_SERVER_SOCKET_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/private/ppb_net_address_private.h" #define PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE_0_1 \ "PPB_TCPServerSocket_Private;0.1" #define PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE_0_2 \ "PPB_TCPServerSocket_Private;0.2" #define PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE \ PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE_0_2 /** * @file * This file defines the PPB_TCPServerSocket_Private interface. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_TCPServerSocket_Private interface provides TCP * server socket operations. */ struct PPB_TCPServerSocket_Private_0_2 { /** * Allocates a TCP server socket resource. */ PP_Resource (*Create)(PP_Instance instance); /** * Determines if a given resource is TCP server socket. */ PP_Bool (*IsTCPServerSocket)(PP_Resource resource); /** * Binds |tcp_server_socket| to the address given by |addr| and * starts listening. The |backlog| argument defines the maximum * length to which the queue of pending connections may * grow. |callback| is invoked when |tcp_server_socket| is ready to * accept incoming connections or in the case of failure. Returns * PP_ERROR_NOSPACE if socket can't be initialized, or * PP_ERROR_FAILED in the case of Listen failure. Otherwise, returns * PP_OK. */ int32_t (*Listen)(PP_Resource tcp_server_socket, const struct PP_NetAddress_Private* addr, int32_t backlog, struct PP_CompletionCallback callback); /** * Accepts single connection, creates instance of * PPB_TCPSocket_Private and stores reference to it in * |tcp_socket|. |callback| is invoked when connection is accepted * or in the case of failure. This method can be called only after * successful Listen call on |tcp_server_socket|. */ int32_t (*Accept)(PP_Resource tcp_server_socket, PP_Resource* tcp_socket, struct PP_CompletionCallback callback); /** * Returns the current address to which the socket is bound, in the * buffer pointed to by |addr|. This method can be called only after * successful Listen() call and before StopListening() call. */ int32_t (*GetLocalAddress)(PP_Resource tcp_server_socket, struct PP_NetAddress_Private* addr); /** * Cancels all pending callbacks reporting PP_ERROR_ABORTED and * closes the socket. Note: this method is implicitly called when * server socket is destroyed. */ void (*StopListening)(PP_Resource tcp_server_socket); }; typedef struct PPB_TCPServerSocket_Private_0_2 PPB_TCPServerSocket_Private; struct PPB_TCPServerSocket_Private_0_1 { PP_Resource (*Create)(PP_Instance instance); PP_Bool (*IsTCPServerSocket)(PP_Resource resource); int32_t (*Listen)(PP_Resource tcp_server_socket, const struct PP_NetAddress_Private* addr, int32_t backlog, struct PP_CompletionCallback callback); int32_t (*Accept)(PP_Resource tcp_server_socket, PP_Resource* tcp_socket, struct PP_CompletionCallback callback); void (*StopListening)(PP_Resource tcp_server_socket); }; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_TCP_SERVER_SOCKET_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_tcp_socket_private.h000066400000000000000000000237541321746453100267660ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_tcp_socket_private.idl modified Mon Jun 24 09:53:12 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_TCP_SOCKET_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_TCP_SOCKET_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/private/ppb_net_address_private.h" #define PPB_TCPSOCKET_PRIVATE_INTERFACE_0_3 "PPB_TCPSocket_Private;0.3" #define PPB_TCPSOCKET_PRIVATE_INTERFACE_0_4 "PPB_TCPSocket_Private;0.4" #define PPB_TCPSOCKET_PRIVATE_INTERFACE_0_5 "PPB_TCPSocket_Private;0.5" #define PPB_TCPSOCKET_PRIVATE_INTERFACE PPB_TCPSOCKET_PRIVATE_INTERFACE_0_5 /** * @file * This file defines the PPB_TCPSocket_Private interface. */ /** * @addtogroup Enums * @{ */ typedef enum { /* Special value used for testing. Guaranteed to fail SetOption(). */ PP_TCPSOCKETOPTION_PRIVATE_INVALID = 0, /* Disable coalescing of small writes to make TCP segments, and instead * deliver data immediately. For SSL sockets, this option must be set before * SSLHandshake() is called. Value type is PP_VARTYPE_BOOL. */ PP_TCPSOCKETOPTION_PRIVATE_NO_DELAY = 1 } PP_TCPSocketOption_Private; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TCPSocketOption_Private, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_TCPSocket_Private interface provides TCP socket * operations. */ struct PPB_TCPSocket_Private_0_5 { /** * Allocates a TCP socket resource. */ PP_Resource (*Create)(PP_Instance instance); /** * Determines if a given resource is TCP socket. */ PP_Bool (*IsTCPSocket)(PP_Resource resource); /** * Connects to a TCP port given as a host-port pair. * When a proxy server is used, |host| and |port| refer to the proxy server * instead of the destination server. */ int32_t (*Connect)(PP_Resource tcp_socket, const char* host, uint16_t port, struct PP_CompletionCallback callback); /** * Same as Connect(), but connecting to the address given by |addr|. A typical * use-case would be for reconnections. */ int32_t (*ConnectWithNetAddress)(PP_Resource tcp_socket, const struct PP_NetAddress_Private* addr, struct PP_CompletionCallback callback); /** * Gets the local address of the socket, if it has been connected. * Returns PP_TRUE on success. */ PP_Bool (*GetLocalAddress)(PP_Resource tcp_socket, struct PP_NetAddress_Private* local_addr); /** * Gets the remote address of the socket, if it has been connected. * Returns PP_TRUE on success. */ PP_Bool (*GetRemoteAddress)(PP_Resource tcp_socket, struct PP_NetAddress_Private* remote_addr); /** * Does SSL handshake and moves to sending and receiving encrypted data. The * socket must have been successfully connected. |server_name| will be * compared with the name(s) in the server's certificate during the SSL * handshake. |server_port| is only used to identify an SSL server in the SSL * session cache. * When a proxy server is used, |server_name| and |server_port| refer to the * destination server. * If the socket is not connected, or there are pending read/write requests, * SSLHandshake() will fail without starting a handshake. Otherwise, any * failure during the handshake process will cause the socket to be * disconnected. */ int32_t (*SSLHandshake)(PP_Resource tcp_socket, const char* server_name, uint16_t server_port, struct PP_CompletionCallback callback); /** * Returns the server's PPB_X509Certificate_Private for a socket * connection if an SSL connection has been established using * SSLHandshake. If no SSL connection has been established, a * null resource is returned. */ PP_Resource (*GetServerCertificate)(PP_Resource tcp_socket); /** * NOTE: This function is not implemented and will return * PP_FALSE. * Adds a trusted/untrusted chain building certificate to be used for this * connection. The certificate must be a * PPB_X509Certificate_Private. PP_TRUE is returned * upon success. */ PP_Bool (*AddChainBuildingCertificate)(PP_Resource tcp_socket, PP_Resource certificate, PP_Bool is_trusted); /** * Reads data from the socket. The size of |buffer| must be at least as large * as |bytes_to_read|. May perform a partial read. Returns the number of bytes * read or an error code. If the return value is 0, then it indicates that * end-of-file was reached. * This method won't return more than 1 megabyte, so if |bytes_to_read| * exceeds 1 megabyte, it will always perform a partial read. * Multiple outstanding read requests are not supported. */ int32_t (*Read)(PP_Resource tcp_socket, char* buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback); /** * Writes data to the socket. May perform a partial write. Returns the number * of bytes written or an error code. * This method won't write more than 1 megabyte, so if |bytes_to_write| * exceeds 1 megabyte, it will always perform a partial write. * Multiple outstanding write requests are not supported. */ int32_t (*Write)(PP_Resource tcp_socket, const char* buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback); /** * Cancels any IO that may be pending, and disconnects the socket. Any pending * callbacks will still run, reporting PP_Error_Aborted if pending IO was * interrupted. It is NOT valid to call Connect() again after a call to this * method. Note: If the socket is destroyed when it is still connected, then * it will be implicitly disconnected, so you are not required to call this * method. */ void (*Disconnect)(PP_Resource tcp_socket); /** * Sets an option on |tcp_socket|. Supported |name| and |value| parameters * are as described for PP_TCPSocketOption_Private. |callback| will be * invoked with PP_OK if setting the option succeeds, or an error code * otherwise. The socket must be connection before SetOption is called. */ int32_t (*SetOption)(PP_Resource tcp_socket, PP_TCPSocketOption_Private name, struct PP_Var value, struct PP_CompletionCallback callback); }; typedef struct PPB_TCPSocket_Private_0_5 PPB_TCPSocket_Private; struct PPB_TCPSocket_Private_0_3 { PP_Resource (*Create)(PP_Instance instance); PP_Bool (*IsTCPSocket)(PP_Resource resource); int32_t (*Connect)(PP_Resource tcp_socket, const char* host, uint16_t port, struct PP_CompletionCallback callback); int32_t (*ConnectWithNetAddress)(PP_Resource tcp_socket, const struct PP_NetAddress_Private* addr, struct PP_CompletionCallback callback); PP_Bool (*GetLocalAddress)(PP_Resource tcp_socket, struct PP_NetAddress_Private* local_addr); PP_Bool (*GetRemoteAddress)(PP_Resource tcp_socket, struct PP_NetAddress_Private* remote_addr); int32_t (*SSLHandshake)(PP_Resource tcp_socket, const char* server_name, uint16_t server_port, struct PP_CompletionCallback callback); int32_t (*Read)(PP_Resource tcp_socket, char* buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback); int32_t (*Write)(PP_Resource tcp_socket, const char* buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback); void (*Disconnect)(PP_Resource tcp_socket); }; struct PPB_TCPSocket_Private_0_4 { PP_Resource (*Create)(PP_Instance instance); PP_Bool (*IsTCPSocket)(PP_Resource resource); int32_t (*Connect)(PP_Resource tcp_socket, const char* host, uint16_t port, struct PP_CompletionCallback callback); int32_t (*ConnectWithNetAddress)(PP_Resource tcp_socket, const struct PP_NetAddress_Private* addr, struct PP_CompletionCallback callback); PP_Bool (*GetLocalAddress)(PP_Resource tcp_socket, struct PP_NetAddress_Private* local_addr); PP_Bool (*GetRemoteAddress)(PP_Resource tcp_socket, struct PP_NetAddress_Private* remote_addr); int32_t (*SSLHandshake)(PP_Resource tcp_socket, const char* server_name, uint16_t server_port, struct PP_CompletionCallback callback); PP_Resource (*GetServerCertificate)(PP_Resource tcp_socket); PP_Bool (*AddChainBuildingCertificate)(PP_Resource tcp_socket, PP_Resource certificate, PP_Bool is_trusted); int32_t (*Read)(PP_Resource tcp_socket, char* buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback); int32_t (*Write)(PP_Resource tcp_socket, const char* buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback); void (*Disconnect)(PP_Resource tcp_socket); }; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_TCP_SOCKET_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_testing_private.h000066400000000000000000000164111321746453100262750ustar00rootroot00000000000000/* Copyright 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_testing_private.idl modified Fri May 1 13:14:52 2015. */ #ifndef PPAPI_C_PRIVATE_PPB_TESTING_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_TESTING_PRIVATE_H_ #include "ppapi/c/dev/ppb_url_util_dev.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_TESTING_PRIVATE_INTERFACE_1_0 "PPB_Testing_Private;1.0" #define PPB_TESTING_PRIVATE_INTERFACE PPB_TESTING_PRIVATE_INTERFACE_1_0 /** * @file * This file contains interface functions used for unit testing. Do not use in * production code. They are not guaranteed to be available in normal plugin * environments so you should not depend on them. */ /** * @addtogroup Interfaces * @{ */ struct PPB_Testing_Private_1_0 { /** * Reads the bitmap data out of the backing store for the given * DeviceContext2D and into the given image. If the data was successfully * read, it will return PP_TRUE. * * This function should not generally be necessary for normal plugin * operation. If you want to update portions of a device, the expectation is * that you will either regenerate the data, or maintain a backing store * pushing updates to the device from your backing store via PaintImageData. * Using this function will introduce an extra copy which will make your * plugin slower. In some cases, this may be a very expensive operation (it * may require slow cross-process transitions or graphics card readbacks). * * Data will be read into the image starting at |top_left| in the device * context, and proceeding down and to the right for as many pixels as the * image is large. If any part of the image bound would fall outside of the * backing store of the device if positioned at |top_left|, this function * will fail and return PP_FALSE. * * The image format must be of the format * PPB_ImageData.GetNativeImageDataFormat() or this function will fail and * return PP_FALSE. * * The returned image data will represent the current status of the backing * store. This will not include any paint, scroll, or replace operations * that have not yet been flushed; these operations are only reflected in * the backing store (and hence ReadImageData) until after a Flush() * operation has completed. */ PP_Bool (*ReadImageData)(PP_Resource device_context_2d, PP_Resource image, const struct PP_Point* top_left); /** * Runs a nested message loop. The plugin will be reentered from this call. * This function is used for unit testing the API. The normal pattern is to * issue some asynchronous call that has a callback. Then you call * RunMessageLoop which will suspend the plugin and go back to processing * messages, giving the asynchronous operation time to complete. In your * callback, you save the data and call QuitMessageLoop, which will then * pop back up and continue with the test. This avoids having to write a * complicated state machine for simple tests for asynchronous APIs. */ void (*RunMessageLoop)(PP_Instance instance); /** * Posts a quit message for the outermost nested message loop. Use this to * exit and return back to the caller after you call RunMessageLoop. */ void (*QuitMessageLoop)(PP_Instance instance); /** * Returns the number of live objects (resources + strings + objects) * associated with this plugin instance. Used for detecting leaks. Returns * (uint32_t)-1 on failure. */ uint32_t (*GetLiveObjectsForInstance)(PP_Instance instance); /** * Returns PP_TRUE if the plugin is running out-of-process, PP_FALSE * otherwise. */ PP_Bool (*IsOutOfProcess)(void); /** * Posts the plugin's current Power Saver status to JavaScript. The plugin * itself does not receive anything. This is not idiomatic for Pepper, * but convenient for testing. */ void (*PostPowerSaverStatus)(PP_Instance instance); /** * Subscribes to changes to the plugin's Power Saver status. The status * changes are not forwarded to the plugin itself, but posted to JavaScript. * This is not idiomatic for Pepper, but conveienent for testing. */ void (*SubscribeToPowerSaverNotifications)(PP_Instance instance); /** * Passes the input event to the browser, which sends it back to the * plugin. The plugin should implement PPP_InputEvent and register for * the input event type. * * This method sends an input event through the browser just as if it had * come from the user. If the browser determines that it is an event for the * plugin, it will be sent to be handled by the plugin's PPP_InputEvent * interface. When generating mouse events, make sure the position is within * the plugin's area on the page. When generating a keyboard event, make sure * the plugin is focused. * * Note that the browser may generate extra input events in order to * maintain certain invariants, such as always having a "mouse enter" event * before any other mouse event. Furthermore, the event the plugin receives * after sending a simulated event will be slightly different from the * original event. The browser may change the timestamp, add modifiers, and * slightly alter the mouse position, due to coordinate transforms it * performs. */ void (*SimulateInputEvent)(PP_Instance instance, PP_Resource input_event); /** * Returns the URL for the document. This is a safe way to retrieve * window.location.href. * If the canonicalized URL is valid, the method will parse the URL * and fill in the components structure. This pointer may be NULL * to specify that no component information is necessary. */ struct PP_Var (*GetDocumentURL)(PP_Instance instance, struct PP_URLComponents_Dev* components); /** * Fetches up to |array_size| active PP_Vars in the tracker. Returns the * number of vars in the tracker. The active vars are written to |live_vars| * contiguously starting at index 0. The vars are not in any particular order. * If the number of live vars is greater than |array_size|, then an arbitrary * subset of |array_size| vars is written to |live_vars|. The reference count * of the returned PP_Vars will *not* be affected by this call. */ uint32_t (*GetLiveVars)(struct PP_Var live_vars[], uint32_t array_size); /** * Sets the threshold size at which point we switch from transmitting * array buffers in IPC messages to using shared memory. This is only used * for testing purposes where we need to transmit small buffers using shmem * (in order to have fast tests). Passing a value of 0 resets the threshold * to its default. The threshold is in bytes. */ void (*SetMinimumArrayBufferSizeForShmem)(PP_Instance instance, uint32_t threshold); /** * Run the V8 garbage collector for tests. */ void (*RunV8GC)(PP_Instance instance); }; typedef struct PPB_Testing_Private_1_0 PPB_Testing_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_TESTING_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_udp_socket_private.h000066400000000000000000000144021321746453100267560ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_udp_socket_private.idl modified Mon Jun 24 09:53:43 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_UDP_SOCKET_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_UDP_SOCKET_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/private/ppb_net_address_private.h" #define PPB_UDPSOCKET_PRIVATE_INTERFACE_0_2 "PPB_UDPSocket_Private;0.2" #define PPB_UDPSOCKET_PRIVATE_INTERFACE_0_3 "PPB_UDPSocket_Private;0.3" #define PPB_UDPSOCKET_PRIVATE_INTERFACE_0_4 "PPB_UDPSocket_Private;0.4" #define PPB_UDPSOCKET_PRIVATE_INTERFACE PPB_UDPSOCKET_PRIVATE_INTERFACE_0_4 /** * @file * This file defines the PPB_UDPSocket_Private interface. */ /** * @addtogroup Enums * @{ */ typedef enum { /* Allow the socket to share the local address to which socket will * be bound with other processes. Value's type should be * PP_VARTYPE_BOOL. */ PP_UDPSOCKETFEATURE_PRIVATE_ADDRESS_REUSE = 0, /* Allow sending and receiving packets sent to and from broadcast * addresses. Value's type should be PP_VARTYPE_BOOL. */ PP_UDPSOCKETFEATURE_PRIVATE_BROADCAST = 1, /* Special value for counting the number of available * features. Should not be passed to SetSocketFeature(). */ PP_UDPSOCKETFEATURE_PRIVATE_COUNT = 2 } PP_UDPSocketFeature_Private; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_UDPSocketFeature_Private, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ struct PPB_UDPSocket_Private_0_4 { /** * Creates a UDP socket resource. */ PP_Resource (*Create)(PP_Instance instance_id); /** * Determines if a given resource is a UDP socket. */ PP_Bool (*IsUDPSocket)(PP_Resource resource_id); /** * Sets a socket feature to |udp_socket|. Should be called before * Bind(). Possible values for |name|, |value| and |value|'s type * are described in PP_UDPSocketFeature_Private description. If no * error occurs, returns PP_OK. Otherwise, returns * PP_ERROR_BADRESOURCE (if bad |udp_socket| provided), * PP_ERROR_BADARGUMENT (if bad name/value/value's type provided) * or PP_ERROR_FAILED in the case of internal errors. */ int32_t (*SetSocketFeature)(PP_Resource udp_socket, PP_UDPSocketFeature_Private name, struct PP_Var value); /* Creates a socket and binds to the address given by |addr|. */ int32_t (*Bind)(PP_Resource udp_socket, const struct PP_NetAddress_Private* addr, struct PP_CompletionCallback callback); /* Returns the address that the socket has bound to. A successful * call to Bind must be called first. Returns PP_FALSE if Bind * fails, or if Close has been called. */ PP_Bool (*GetBoundAddress)(PP_Resource udp_socket, struct PP_NetAddress_Private* addr); /* Performs a non-blocking recvfrom call on socket. * Bind must be called first. |callback| is invoked when recvfrom * reads data. You must call GetRecvFromAddress to recover the * address the data was retrieved from. */ int32_t (*RecvFrom)(PP_Resource udp_socket, char* buffer, int32_t num_bytes, struct PP_CompletionCallback callback); /* Upon successful completion of RecvFrom, the address that the data * was received from is stored in |addr|. */ PP_Bool (*GetRecvFromAddress)(PP_Resource udp_socket, struct PP_NetAddress_Private* addr); /* Performs a non-blocking sendto call on the socket created and * bound(has already called Bind). The callback |callback| is * invoked when sendto completes. */ int32_t (*SendTo)(PP_Resource udp_socket, const char* buffer, int32_t num_bytes, const struct PP_NetAddress_Private* addr, struct PP_CompletionCallback callback); /* Cancels all pending reads and writes, and closes the socket. */ void (*Close)(PP_Resource udp_socket); }; typedef struct PPB_UDPSocket_Private_0_4 PPB_UDPSocket_Private; struct PPB_UDPSocket_Private_0_2 { PP_Resource (*Create)(PP_Instance instance_id); PP_Bool (*IsUDPSocket)(PP_Resource resource_id); int32_t (*Bind)(PP_Resource udp_socket, const struct PP_NetAddress_Private* addr, struct PP_CompletionCallback callback); int32_t (*RecvFrom)(PP_Resource udp_socket, char* buffer, int32_t num_bytes, struct PP_CompletionCallback callback); PP_Bool (*GetRecvFromAddress)(PP_Resource udp_socket, struct PP_NetAddress_Private* addr); int32_t (*SendTo)(PP_Resource udp_socket, const char* buffer, int32_t num_bytes, const struct PP_NetAddress_Private* addr, struct PP_CompletionCallback callback); void (*Close)(PP_Resource udp_socket); }; struct PPB_UDPSocket_Private_0_3 { PP_Resource (*Create)(PP_Instance instance_id); PP_Bool (*IsUDPSocket)(PP_Resource resource_id); int32_t (*Bind)(PP_Resource udp_socket, const struct PP_NetAddress_Private* addr, struct PP_CompletionCallback callback); PP_Bool (*GetBoundAddress)(PP_Resource udp_socket, struct PP_NetAddress_Private* addr); int32_t (*RecvFrom)(PP_Resource udp_socket, char* buffer, int32_t num_bytes, struct PP_CompletionCallback callback); PP_Bool (*GetRecvFromAddress)(PP_Resource udp_socket, struct PP_NetAddress_Private* addr); int32_t (*SendTo)(PP_Resource udp_socket, const char* buffer, int32_t num_bytes, const struct PP_NetAddress_Private* addr, struct PP_CompletionCallback callback); void (*Close)(PP_Resource udp_socket); }; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_UDP_SOCKET_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_uma_private.h000066400000000000000000000056211321746453100254030ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_uma_private.idl modified Fri Mar 14 16:59:33 2014. */ #ifndef PPAPI_C_PRIVATE_PPB_UMA_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_UMA_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_UMA_PRIVATE_INTERFACE_0_3 "PPB_UMA_Private;0.3" #define PPB_UMA_PRIVATE_INTERFACE PPB_UMA_PRIVATE_INTERFACE_0_3 /** * @file * This file defines the PPB_UMA_Private interface. */ /** * @addtogroup Interfaces * @{ */ /** * Contains functions for plugins to report UMA usage stats. */ struct PPB_UMA_Private_0_3 { /** * HistogramCustomTimes is a pointer to a function which records a time * sample given in milliseconds in the histogram given by |name|, possibly * creating the histogram if it does not exist. */ void (*HistogramCustomTimes)(PP_Instance instance, struct PP_Var name, int64_t sample, int64_t min, int64_t max, uint32_t bucket_count); /** * HistogramCustomCounts is a pointer to a function which records a sample * in the histogram given by |name|, possibly creating the histogram if it * does not exist. */ void (*HistogramCustomCounts)(PP_Instance instance, struct PP_Var name, int32_t sample, int32_t min, int32_t max, uint32_t bucket_count); /** * HistogramEnumeration is a pointer to a function which records a sample * in the histogram given by |name|, possibly creating the histogram if it * does not exist. The sample represents a value in an enumeration bounded * by |boundary_value|, that is, sample < boundary_value always. */ void (*HistogramEnumeration)(PP_Instance instance, struct PP_Var name, int32_t sample, int32_t boundary_value); /** * IsCrashReportingEnabled returns PP_OK to the completion callback to * indicate that the current user has opted-in to crash reporting, or * PP_ERROR_* on failure or when a user has not opted-in. This can be used to * gate other reporting processes such as analytics and crash reporting. */ int32_t (*IsCrashReportingEnabled)(PP_Instance instance, struct PP_CompletionCallback callback); }; typedef struct PPB_UMA_Private_0_3 PPB_UMA_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_UMA_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_video_destination_private.h000066400000000000000000000103671321746453100303330ustar00rootroot00000000000000/* Copyright (c) 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_video_destination_private.idl, * modified Thu Apr 25 11:51:30 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_VIDEO_DESTINATION_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_VIDEO_DESTINATION_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/private/pp_video_frame_private.h" #define PPB_VIDEODESTINATION_PRIVATE_INTERFACE_0_1 \ "PPB_VideoDestination_Private;0.1" #define PPB_VIDEODESTINATION_PRIVATE_INTERFACE \ PPB_VIDEODESTINATION_PRIVATE_INTERFACE_0_1 /** * @file * This file defines the PPB_VideoDestination_Private interface * for a video destination resource, which sends video frames to a MediaStream * video track in the browser. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_VideoDestination_Private interface contains pointers to * several functions for creating video destination resources and using them to * send video frames to a MediaStream video track in the browser. */ struct PPB_VideoDestination_Private_0_1 { /** * Creates a video destination resource. * * @param[in] instance A PP_Instance identifying an instance of * a module. * * @return A PP_Resource with a nonzero ID on success or zero on * failure. Failure means the instance was invalid. */ PP_Resource (*Create)(PP_Instance instance); /** * Determines if a resource is a video destination resource. * * @param[in] resource The PP_Resource to test. * * @return A PP_Bool with PP_TRUE if the given * resource is a video destination resource or PP_FALSE * otherwise. */ PP_Bool (*IsVideoDestination)(PP_Resource resource); /** * Opens a video destination for putting frames. * * @param[in] destination A PP_Resource corresponding to a video * destination resource. * @param[in] stream_url A PP_Var string holding a URL * identifying a MediaStream. * @param[in] callback A PP_CompletionCallback to be called upon * completion of Open(). * * @return An int32_t containing a result code from pp_errors.h. * Returns PP_ERROR_BADRESOURCE if destination isn't a valid video * destination. * Returns PP_ERROR_INPROGRESS if destination is already open. * Returns PP_ERROR_FAILED if the MediaStream doesn't exist or if there is * some other browser error. */ int32_t (*Open)(PP_Resource destination, struct PP_Var stream_url, struct PP_CompletionCallback callback); /** * Puts a frame to the video destination. * * After this call, you should take care to release your references to the * image embedded in the video frame. If you paint to the image after * PutFame(), there is the possibility of artifacts because the browser may * still be copying the frame to the stream. * * @param[in] destination A PP_Resource corresponding to a video * destination resource. * @param[in] frame A PP_VideoFrame_Private holding the video * frame to send to the destination. * * @return An int32_t containing a result code from pp_errors.h. * Returns PP_ERROR_BADRESOURCE if destination isn't a valid video * destination. * Returns PP_ERROR_FAILED if destination is not open, if the video frame has * an invalid image data resource, or if some other browser error occurs. */ int32_t (*PutFrame)(PP_Resource destination, const struct PP_VideoFrame_Private* frame); /** * Closes the video destination. * * @param[in] destination A PP_Resource corresponding to a video * destination. */ void (*Close)(PP_Resource destination); }; typedef struct PPB_VideoDestination_Private_0_1 PPB_VideoDestination_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_VIDEO_DESTINATION_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_video_source_private.h000066400000000000000000000101501321746453100273000ustar00rootroot00000000000000/* Copyright (c) 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_video_source_private.idl, * modified Mon Oct 27 16:13:24 2014. */ #ifndef PPAPI_C_PRIVATE_PPB_VIDEO_SOURCE_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_VIDEO_SOURCE_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/private/pp_video_frame_private.h" #define PPB_VIDEOSOURCE_PRIVATE_INTERFACE_0_1 "PPB_VideoSource_Private;0.1" #define PPB_VIDEOSOURCE_PRIVATE_INTERFACE PPB_VIDEOSOURCE_PRIVATE_INTERFACE_0_1 /** * @file * This file defines the PPB_VideoSource_Private interface for a * video source resource, which receives video frames from a MediaStream video * track in the browser. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_VideoSource_Private interface contains pointers to * several functions for creating video source resources and using them to * receive video frames from a MediaStream video track in the browser. */ struct PPB_VideoSource_Private_0_1 { /** * Creates a video source resource. * * @param[in] instance A PP_Instance identifying an instance of * a module. * * @return A PP_Resource with a nonzero ID on success or zero on * failure. Failure means the instance was invalid. */ PP_Resource (*Create)(PP_Instance instance); /** * Determines if a resource is a video source resource. * * @param[in] resource The PP_Resource to test. * * @return A PP_Bool with PP_TRUE if the given * resource is a video source resource or PP_FALSE otherwise. */ PP_Bool (*IsVideoSource)(PP_Resource resource); /** * Opens a video source for getting frames. * * @param[in] source A PP_Resource corresponding to a video * source resource. * @param[in] stream_url A PP_Var string holding a URL * identifying a MediaStream. * @param[in] callback A PP_CompletionCallback to be called upon * completion of Open(). * * @return An int32_t containing a result code from pp_errors.h. * Returns PP_ERROR_BADRESOURCE if source isn't a valid video source. * Returns PP_ERROR_INPROGRESS if source is already open. * Returns PP_ERROR_FAILED if the MediaStream doesn't exist or if there is * some other browser error. */ int32_t (*Open)(PP_Resource source, struct PP_Var stream_url, struct PP_CompletionCallback callback); /** * Gets a frame from the video source. The returned image data is only valid * until the next call to GetFrame. * The image data resource inside the returned frame will have its reference * count incremented by one and must be managed by the plugin. * * @param[in] source A PP_Resource corresponding to a video * source resource. * @param[out] frame A PP_VideoFrame_Private to hold a video * frame from the source. * @param[in] callback A PP_CompletionCallback to be called upon * completion of GetNextFrame(). * * @return An int32_t containing a result code from pp_errors.h. * Returns PP_ERROR_BADRESOURCE if source isn't a valid video source. * Returns PP_ERROR_FAILED if the source is not open, or if some other * browser error occurs. */ int32_t (*GetFrame)(PP_Resource source, struct PP_VideoFrame_Private* frame, struct PP_CompletionCallback callback); /** * Closes the video source. * * @param[in] source A PP_Resource corresponding to a video * source resource. */ void (*Close)(PP_Resource source); }; typedef struct PPB_VideoSource_Private_0_1 PPB_VideoSource_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPB_VIDEO_SOURCE_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppb_x509_certificate_private.h000066400000000000000000000152111321746453100276640ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppb_x509_certificate_private.idl, * modified Wed Apr 11 17:11:26 2012. */ #ifndef PPAPI_C_PRIVATE_PPB_X509_CERTIFICATE_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_X509_CERTIFICATE_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_X509CERTIFICATE_PRIVATE_INTERFACE_0_1 \ "PPB_X509Certificate_Private;0.1" #define PPB_X509CERTIFICATE_PRIVATE_INTERFACE \ PPB_X509CERTIFICATE_PRIVATE_INTERFACE_0_1 /** * @file * This file defines the PPB_X509Certificate_Private interface for * an X509 certificate. */ /** * @addtogroup Enums * @{ */ /** * This enumeration corresponds to fields of an X509 certificate. Refer to * PPP_ContentDecryptor_Private * interface. Note: This is a special interface, only to be used for Content * Decryption Modules, not normal plugins. */ /** * @addtogroup Interfaces * @{ */ /** * PPP_ContentDecryptor_Private structure contains the function * pointers the decryption plugin must implement to provide services needed by * the browser. This interface provides the plugin side support for the Content * Decryption Module (CDM) for Encrypted Media Extensions: * http://www.w3.org/TR/encrypted-media/ */ struct PPP_ContentDecryptor_Private_0_16 { /** * Initialize for the specified key system. * * @param[in] promise_id A reference for the promise that gets resolved or * rejected depending upon the success or failure of initialization. * * @param[in] key_system A PP_Var of type * PP_VARTYPE_STRING containing the name of the key system. * @param[in] allow_distinctive_identifier Inform the CDM that it may use a * distinctive identifier. * @param[in] allow_persistent_state Inform the CDM that it may use persistent * state. */ void (*Initialize)(PP_Instance instance, uint32_t promise_id, struct PP_Var key_system, PP_Bool allow_distinctive_identifier, PP_Bool allow_persistent_state); /** * Provides a server certificate to be used to encrypt messages to the * license server. * * @param[in] promise_id A reference for the promise that gets resolved or * rejected depending upon the success or failure of setting the certificate. * * @param[in] server_certificate A PP_Var of type * PP_VARTYPE_ARRAYBUFFER containing the certificate to be used. */ void (*SetServerCertificate)(PP_Instance instance, uint32_t promise_id, struct PP_Var server_certificate); /** * Creates a session and subsequently generates a request for a license. * init_data_type contains the MIME type of * init_data. init_data is a data buffer * containing data for use in generating the request. * * Note: CreateSessionAndGenerateRequest() must create a * session ID and provide it to the browser via SessionCreated() * on the PPB_ContentDecryptor_Private interface. * * @param[in] promise_id A reference for the promise that gets resolved or * rejected depending upon the success or failure when creating the session. * * @param[in] session_type A PP_SessionType that indicates the * type of session to be created. * * @param[in] init_data_type A PP_InitDataType that indicates * the Initialization Data Type for init_data. * * @param[in] init_data A PP_Var of type * PP_VARTYPE_ARRAYBUFFER containing container specific * initialization data. */ void (*CreateSessionAndGenerateRequest)(PP_Instance instance, uint32_t promise_id, PP_SessionType session_type, PP_InitDataType init_data_type, struct PP_Var init_data); /** * Loads a session whose session ID is session_id. * * Note: After the session is successfully loaded, the CDM must call * SessionCreated() with session_id on the * PPB_ContentDecryptor_Private interface. * * @param[in] promise_id A reference for the promise that gets resolved or * rejected depending upon the success or failure of loading the session. * * @param[in] session_type A PP_SessionType that indicates the * type of session to be loaded. * * @param[in] session_id A PP_Var of type * PP_VARTYPE_STRING containing the session ID of the session * to load. */ void (*LoadSession)(PP_Instance instance, uint32_t promise_id, PP_SessionType session_type, struct PP_Var session_id); /** * Provides a license or other message to the decryptor. * * When the CDM needs more information, it must call * SessionMessage() on the * PPB_ContentDecryptor_Private interface, and the browser * must notify the web application. When the CDM has finished processing * response and needs no more information, it must call * SessionReady() on the * PPB_ContentDecryptor_Private interface, and the browser * must notify the web application. * * @param[in] promise_id A reference for the promise that gets resolved or * rejected depending upon the success or failure of updating the session. * * @param[in] session_id A PP_Var of type * PP_VARTYPE_STRING containing the session ID of the session * to be updated. * * @param[in] response A PP_Var of type * PP_VARTYPE_ARRAYBUFFER containing the license or other * message for the given session ID. */ void (*UpdateSession)(PP_Instance instance, uint32_t promise_id, struct PP_Var session_id, struct PP_Var response); /** * Close the specified session and related resources. * * @param[in] promise_id A reference for the promise that gets resolved or * rejected depending upon the success or failure of closing the session. * * @param[in] session_id A PP_Var of type * PP_VARTYPE_STRING containing the session ID of the session * to be closed. * */ void (*CloseSession)(PP_Instance instance, uint32_t promise_id, struct PP_Var session_id); /** * Remove stored data associated with this session. * * @param[in] promise_id A reference for the promise that gets resolved or * rejected depending upon the success or failure of removing the session * data. * * @param[in] session_id A PP_Var of type * PP_VARTYPE_STRING containing the session ID of the session * to be removed. * */ void (*RemoveSession)(PP_Instance instance, uint32_t promise_id, struct PP_Var session_id); /** * Decrypts the block and returns the unencrypted block via * DeliverBlock() on the * PPB_ContentDecryptor_Private interface. The returned block * contains encoded data. * * @param[in] resource A PP_Resource corresponding to a * PPB_Buffer_Dev resource that contains an encrypted data * block. * * @param[in] encrypted_block_info A PP_EncryptedBlockInfo that * contains all auxiliary information needed for decryption of the * encrypted_block. */ void (*Decrypt)(PP_Instance instance, PP_Resource encrypted_block, const struct PP_EncryptedBlockInfo* encrypted_block_info); /** * Initializes the audio decoder using codec and settings in * decoder_config, and returns the result of the initialization * request to the browser using the DecoderInitializeDone( ) method * on the PPB_ContentDecryptor_Private interface. * * @param[in] decoder_config A PP_AudioDecoderConfig that * contains audio decoder settings and a request ID. The request ID is passed * to the DecoderInitializeDone() method on the * PPB_ContentDecryptor_Private interface to allow clients to * associate the result with a audio decoder initialization request. * * @param[in] codec_extra_data A PP_Resource corresponding to a * PPB_Buffer_Dev resource containing codec setup data required * by some codecs. It should be set to 0 when the codec being initialized * does not require it. */ void (*InitializeAudioDecoder)( PP_Instance instance, const struct PP_AudioDecoderConfig* decoder_config, PP_Resource codec_extra_data); /** * Initializes the video decoder using codec and settings in * decoder_config, and returns the result of the initialization * request to the browser using the DecoderInitializeDone() * method on the PPB_ContentDecryptor_Private interface. * * @param[in] decoder_config A PP_VideoDecoderConfig that * contains video decoder settings and a request ID. The request ID is passed * to the DecoderInitializeDone() method on the * PPB_ContentDecryptor_Private interface to allow clients to * associate the result with a video decoder initialization request. * * @param[in] codec_extra_data A PP_Resource corresponding to a * PPB_Buffer_Dev resource containing codec setup data required * by some codecs. It should be set to 0 when the codec being initialized * does not require it. */ void (*InitializeVideoDecoder)( PP_Instance instance, const struct PP_VideoDecoderConfig* decoder_config, PP_Resource codec_extra_data); /** * De-initializes the decoder for the PP_DecryptorStreamType * specified by decoder_type and sets it to an uninitialized * state. The decoder can be re-initialized after de-initialization completes * by calling InitializeAudioDecoder or * InitializeVideoDecoder. * * De-initialization completion is reported to the browser using the * DecoderDeinitializeDone() method on the * PPB_ContentDecryptor_Private interface. * * @param[in] decoder_type A PP_DecryptorStreamType that * specifies the decoder to de-initialize. * * @param[in] request_id A request ID that allows the browser to associate a * request to de-initialize a decoder with the corresponding call to the * DecoderDeinitializeDone() method on the * PPB_ContentDecryptor_Private interface. */ void (*DeinitializeDecoder)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id); /** * Resets the decoder for the PP_DecryptorStreamType specified * by decoder_type to an initialized clean state. Reset * completion is reported to the browser using the * DecoderResetDone() method on the * PPB_ContentDecryptor_Private interface. This method can be * used to signal a discontinuity in the encoded data stream, and is safe to * call multiple times. * * @param[in] decoder_type A PP_DecryptorStreamType that * specifies the decoder to reset. * * @param[in] request_id A request ID that allows the browser to associate a * request to reset the decoder with a corresponding call to the * DecoderResetDone() method on the * PPB_ContentDecryptor_Private interface. */ void (*ResetDecoder)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id); /** * Decrypts encrypted_buffer, decodes it, and returns the unencrypted * uncompressed (decoded) data to the browser via the * DeliverFrame() or DeliverSamples() method on the * PPB_ContentDecryptor_Private interface. * * @param[in] decoder_type A PP_DecryptorStreamType that * specifies the decoder to use after encrypted_buffer is * decrypted. * * @param[in] encrypted_buffer A PP_Resource corresponding to a * PPB_Buffer_Dev resource that contains encrypted media data. * * @param[in] encrypted_block_info A PP_EncryptedBlockInfo that * contains all auxiliary information needed for decryption of the * encrypted_block. */ void (*DecryptAndDecode)( PP_Instance instance, PP_DecryptorStreamType decoder_type, PP_Resource encrypted_buffer, const struct PP_EncryptedBlockInfo* encrypted_block_info); }; typedef struct PPP_ContentDecryptor_Private_0_16 PPP_ContentDecryptor_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPP_CONTENT_DECRYPTOR_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppp_find_private.h000066400000000000000000000031351321746453100255550ustar00rootroot00000000000000/* Copyright 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppp_find_private.idl modified Thu Mar 20 11:34:17 2014. */ #ifndef PPAPI_C_PRIVATE_PPP_FIND_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPP_FIND_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #define PPP_FIND_PRIVATE_INTERFACE_0_3 "PPP_Find_Private;0.3" #define PPP_FIND_PRIVATE_INTERFACE PPP_FIND_PRIVATE_INTERFACE_0_3 /** * @file */ /** * @addtogroup Interfaces * @{ */ struct PPP_Find_Private_0_3 { /** * Finds the given UTF-8 text starting at the current selection. The number of * results will be updated asynchronously via NumberOfFindResultsChanged in * PPB_Find. Note that multiple StartFind calls can happen before StopFind is * called in the case of the search term changing. * * Return PP_FALSE if the plugin doesn't support find in page. Consequently, * it won't call any callbacks. */ PP_Bool (*StartFind)(PP_Instance instance, const char* text, PP_Bool case_sensitive); /** * Go to the next/previous result. */ void (*SelectFindResult)(PP_Instance instance, PP_Bool forward); /** * Tells the plugin that the find operation has stopped, so it should clear * any highlighting. */ void (*StopFind)(PP_Instance instance); }; typedef struct PPP_Find_Private_0_3 PPP_Find_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPP_FIND_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppp_flash_browser_operations.h000066400000000000000000000201531321746453100302050ustar00rootroot00000000000000/* Copyright 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppp_flash_browser_operations.idl, * modified Fri Aug 22 11:10:06 2014. */ #ifndef PPAPI_C_PRIVATE_PPP_FLASH_BROWSER_OPERATIONS_H_ #define PPAPI_C_PRIVATE_PPP_FLASH_BROWSER_OPERATIONS_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #define PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_0 \ "PPP_Flash_BrowserOperations;1.0" #define PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_2 \ "PPP_Flash_BrowserOperations;1.2" #define PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_3 \ "PPP_Flash_BrowserOperations;1.3" #define PPP_FLASH_BROWSEROPERATIONS_INTERFACE \ PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_3 /** * @file * This file contains the PPP_Flash_BrowserOperations interface. */ /** * @addtogroup Enums * @{ */ typedef enum { PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC = 0, PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_PEERNETWORKING = 1 } PP_Flash_BrowserOperations_SettingType; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Flash_BrowserOperations_SettingType, 4); typedef enum { /* This value is only used with SetSitePermission(). */ PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT = 0, PP_FLASH_BROWSEROPERATIONS_PERMISSION_ALLOW = 1, PP_FLASH_BROWSEROPERATIONS_PERMISSION_BLOCK = 2, PP_FLASH_BROWSEROPERATIONS_PERMISSION_ASK = 3 } PP_Flash_BrowserOperations_Permission; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Flash_BrowserOperations_Permission, 4); /** * @} */ /** * @addtogroup Structs * @{ */ struct PP_Flash_BrowserOperations_SiteSetting { const char* site; PP_Flash_BrowserOperations_Permission permission; }; /** * @} */ /** * @addtogroup Typedefs * @{ */ typedef void (*PPB_Flash_BrowserOperations_GetSettingsCallback)( void* user_data, PP_Bool success, PP_Flash_BrowserOperations_Permission default_permission, uint32_t site_count, const struct PP_Flash_BrowserOperations_SiteSetting sites[]); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * This interface allows the browser to request the plugin do things. */ struct PPP_Flash_BrowserOperations_1_3 { /** * This function allows the plugin to implement the "Clear site data" feature. * * @param[in] plugin_data_path String containing the directory where the * plugin data is * stored. On UTF16 systems (Windows), this will be encoded as UTF-8. It will * be an absolute path and will not have a directory separator (slash) at the * end. * @param[in] site String specifying which site to clear the data for. This * will be null to clear data for all sites. * @param[in] flags Currently always 0 in Chrome to clear all data. This may * be extended in the future to clear only specific types of data. * @param[in] max_age The maximum age in seconds to clear data for. This * allows the plugin to implement "clear past hour" and "clear past data", * etc. * * @return PP_TRUE on success, PP_FALSE on failure. * * See also the NPP_ClearSiteData function in NPAPI. * https://wiki.mozilla.org/NPAPI:ClearSiteData */ PP_Bool (*ClearSiteData)(const char* plugin_data_path, const char* site, uint64_t flags, uint64_t max_age); /** * Requests the plugin to deauthorize content licenses. It prevents Flash from * playing protected content, such as movies and music the user may have * rented or purchased. * * @param[in] plugin_data_path String containing the directory where the * plugin settings are stored. * * @return PP_TRUE on success, PP_FALSE on failure. */ PP_Bool (*DeauthorizeContentLicenses)(const char* plugin_data_path); /** * Gets permission settings. callback will be called exactly once * to return the settings. * * @param[in] plugin_data_path String containing the directory where the * plugin settings are stored. * @param[in] setting_type What type of setting to retrieve. * @param[in] callback The callback to return retrieved data. * @param[inout] user_data An opaque pointer that will be passed to * callback. */ void (*GetPermissionSettings)( const char* plugin_data_path, PP_Flash_BrowserOperations_SettingType setting_type, PPB_Flash_BrowserOperations_GetSettingsCallback callback, void* user_data); /** * Sets default permission. It applies to all sites except those with * site-specific settings. * * @param[in] plugin_data_path String containing the directory where the * plugin settings are stored. * @param[in] setting_type What type of setting to set. * @param[in] permission The default permission. * @param[in] clear_site_specific Whether to remove all site-specific * settings. * * @return PP_TRUE on success, PP_FALSE on failure. */ PP_Bool (*SetDefaultPermission)( const char* plugin_data_path, PP_Flash_BrowserOperations_SettingType setting_type, PP_Flash_BrowserOperations_Permission permission, PP_Bool clear_site_specific); /** * Sets site-specific permission. If a site has already got site-specific * permission and it is not in sites, it won't be affected. * * @param[in] plugin_data_path String containing the directory where the * plugin settings are stored. * @param[in] setting_type What type of setting to set. * @param[in] site_count How many items are there in sites. * @param[in] sites The site-specific settings. If a site is specified with * PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT permission, it * will be removed from the site-specific list. * * @return PP_TRUE on success, PP_FALSE on failure. */ PP_Bool (*SetSitePermission)( const char* plugin_data_path, PP_Flash_BrowserOperations_SettingType setting_type, uint32_t site_count, const struct PP_Flash_BrowserOperations_SiteSetting sites[]); /** * Returns a list of sites that have stored data, for use with the * "Clear site data" feature. * * @param[in] plugin_data_path String containing the directory where the * plugin data is stored. * @param[out] sites A NULL-terminated array of sites that have stored data. * Use FreeSiteList on the array when done. * * See also the NPP_GetSitesWithData function in NPAPI: * https://wiki.mozilla.org/NPAPI:ClearSiteData */ void (*GetSitesWithData)(const char* plugin_data_path, char*** sites); /** * Frees the list of sites returned by GetSitesWithData. * * @param[in] sites A NULL-terminated array of strings. */ void (*FreeSiteList)(char* sites[]); }; typedef struct PPP_Flash_BrowserOperations_1_3 PPP_Flash_BrowserOperations; struct PPP_Flash_BrowserOperations_1_0 { PP_Bool (*ClearSiteData)(const char* plugin_data_path, const char* site, uint64_t flags, uint64_t max_age); }; struct PPP_Flash_BrowserOperations_1_2 { PP_Bool (*ClearSiteData)(const char* plugin_data_path, const char* site, uint64_t flags, uint64_t max_age); PP_Bool (*DeauthorizeContentLicenses)(const char* plugin_data_path); void (*GetPermissionSettings)( const char* plugin_data_path, PP_Flash_BrowserOperations_SettingType setting_type, PPB_Flash_BrowserOperations_GetSettingsCallback callback, void* user_data); PP_Bool (*SetDefaultPermission)( const char* plugin_data_path, PP_Flash_BrowserOperations_SettingType setting_type, PP_Flash_BrowserOperations_Permission permission, PP_Bool clear_site_specific); PP_Bool (*SetSitePermission)( const char* plugin_data_path, PP_Flash_BrowserOperations_SettingType setting_type, uint32_t site_count, const struct PP_Flash_BrowserOperations_SiteSetting sites[]); }; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPP_FLASH_BROWSER_OPERATIONS_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppp_instance_private.h000066400000000000000000000036251321746453100264450ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppp_instance_private.idl modified Thu Mar 28 10:22:54 2013. */ #ifndef PPAPI_C_PRIVATE_PPP_INSTANCE_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPP_INSTANCE_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPP_INSTANCE_PRIVATE_INTERFACE_0_1 "PPP_Instance_Private;0.1" #define PPP_INSTANCE_PRIVATE_INTERFACE PPP_INSTANCE_PRIVATE_INTERFACE_0_1 /** * @file * This file defines the PPP_InstancePrivate structure; a series of functions * that a trusted plugin may implement to provide capabilities only available * to trusted plugins. */ /** * @addtogroup Interfaces * @{ */ /** * The PPP_Instance_Private interface contains pointers to a series of * functions that may be implemented in a trusted plugin to provide capabilities * that aren't possible in untrusted modules. */ struct PPP_Instance_Private_0_1 { /** * GetInstanceObject returns a PP_Var representing the scriptable object for * the given instance. Normally this will be a PPP_Class_Deprecated object * that exposes methods and properties to JavaScript. * * On Failure, the returned PP_Var should be a "void" var. * * The returned PP_Var should have a reference added for the caller, which * will be responsible for Release()ing that reference. * * @param[in] instance A PP_Instance identifying the instance from which the * instance object is being requested. * @return A PP_Var containing scriptable object. */ struct PP_Var (*GetInstanceObject)(PP_Instance instance); }; typedef struct PPP_Instance_Private_0_1 PPP_Instance_Private; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPP_INSTANCE_PRIVATE_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppp_pdf.h000066400000000000000000000044071321746453100236570ustar00rootroot00000000000000// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef PPAPI_C_PRIVATE_PPP_PDF_H_ #define PPAPI_C_PRIVATE_PPP_PDF_H_ #include "ppapi/c/dev/pp_print_settings_dev.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_var.h" #define PPP_PDF_INTERFACE_1 "PPP_Pdf;1" #define PPP_PDF_INTERFACE PPP_PDF_INTERFACE_1 typedef enum { // Rotates the page 90 degrees clockwise from its current orientation. PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW, // Rotates the page 90 degrees counterclockwise from its current orientation. PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW } PP_PrivatePageTransformType; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_PrivatePageTransformType, 4); typedef enum { PP_PRIVATEDUPLEXMODE_NONE = 0, PP_PRIVATEDUPLEXMODE_SIMPLEX = 1, PP_PRIVATEDUPLEXMODE_SHORT_EDGE = 2, PP_PRIVATEDUPLEXMODE_LONG_EDGE = 3, PP_PRIVATEDUPLEXMODE_LAST = PP_PRIVATEDUPLEXMODE_LONG_EDGE } PP_PrivateDuplexMode_Dev; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_PrivateDuplexMode_Dev, 4); struct PP_PdfPrintPresetOptions_Dev { // Returns whether scaling is disabled. Returns same information as the // PPP_Printing_Dev's method IsScalingDiabled(). PP_Bool is_scaling_disabled; // Number of copies to be printed. int32_t copies; // DuplexMode to be used for printing. PP_PrivateDuplexMode_Dev duplex; // True if all the pages in the PDF are the same size. PP_Bool is_page_size_uniform; // Only valid if |is_page_size_uniform| is true. The page size. PP_Size uniform_page_size; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_PdfPrintPresetOptions_Dev, 24); struct PPP_Pdf_1_1 { // Returns an absolute URL if the position is over a link. PP_Var (*GetLinkAtPosition)(PP_Instance instance, PP_Point point); // Requests that the plugin apply the given transform to its view. void (*Transform)(PP_Instance instance, PP_PrivatePageTransformType type); // Return true if print preset options are updated from document. PP_Bool (*GetPrintPresetOptionsFromDocument)( PP_Instance instance, PP_PdfPrintPresetOptions_Dev* options); }; typedef PPP_Pdf_1_1 PPP_Pdf; #endif // PPAPI_C_PRIVATE_PPP_PDF_H_ freshplayerplugin-0.3.9/3rdparty/ppapi/c/private/ppp_pexe_stream_handler.h000066400000000000000000000034551321746453100271210ustar00rootroot00000000000000/* Copyright 2014 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From private/ppp_pexe_stream_handler.idl, * modified Wed Aug 6 13:11:06 2014. */ #ifndef PPAPI_C_PRIVATE_PPP_PEXE_STREAM_HANDLER_H_ #define PPAPI_C_PRIVATE_PPP_PEXE_STREAM_HANDLER_H_ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #define PPP_PEXESTREAMHANDLER_INTERFACE_1_0 "PPP_PexeStreamHandler;1.0" #define PPP_PEXESTREAMHANDLER_INTERFACE PPP_PEXESTREAMHANDLER_INTERFACE_1_0 /** * @file * This file contains NaCl private interfaces. This interface is not versioned * and is for internal Chrome use. It may change without notice. */ #include "ppapi/c/private/pp_file_handle.h" /** * @addtogroup Interfaces * @{ */ struct PPP_PexeStreamHandler_1_0 { /** * Invoked as a result of a cache hit for a translated pexe. */ void (*DidCacheHit)(void* user_data, PP_FileHandle nexe_file_handle); /** * Invoked as a result of a cache miss for a translated pexe. * Provides the expected length of the pexe, as read from HTTP headers. */ void (*DidCacheMiss)(void* user_data, int64_t expected_total_length, PP_FileHandle temp_nexe_file); /** * Invoked when a block of data has been downloaded. * Only invoked after DidCacheMiss(). */ void (*DidStreamData)(void* user_data, const void* data, int32_t length); /** * Invoked when the stream has finished downloading, regardless of whether it * succeeded. Not invoked if DidCacheHit() was called. */ void (*DidFinishStream)(void* user_data, int32_t pp_error); }; typedef struct PPP_PexeStreamHandler_1_0 PPP_PexeStreamHandler; /** * @} */ #endif /* PPAPI_C_PRIVATE_PPP_PEXE_STREAM_HANDLER_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/trusted/000077500000000000000000000000001321746453100220715ustar00rootroot00000000000000freshplayerplugin-0.3.9/3rdparty/ppapi/c/trusted/ppb_broker_trusted.h000066400000000000000000000074101321746453100261430ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From trusted/ppb_broker_trusted.idl modified Mon Dec 3 11:10:40 2012. */ #ifndef PPAPI_C_TRUSTED_PPB_BROKER_TRUSTED_H_ #define PPAPI_C_TRUSTED_PPB_BROKER_TRUSTED_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_BROKER_TRUSTED_INTERFACE_0_2 "PPB_BrokerTrusted;0.2" #define PPB_BROKER_TRUSTED_INTERFACE_0_3 "PPB_BrokerTrusted;0.3" #define PPB_BROKER_TRUSTED_INTERFACE PPB_BROKER_TRUSTED_INTERFACE_0_3 /** * @file * This file defines the PPB_BrokerTrusted interface, which provides * access to a trusted broker with greater privileges than the plugin. */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_BrokerTrusted interface provides access to a trusted broker * with greater privileges than the plugin. The interface only supports * out-of-process plugins and is to be used by proxy implementations. All * functions should be called from the main thread only. * * A PPB_BrokerTrusted resource represents a connection to the broker. Its * lifetime controls the lifetime of the broker, regardless of whether the * handle is closed. The handle should be closed before the resource is * released. */ struct PPB_BrokerTrusted_0_3 { /** * Returns a trusted broker resource. */ PP_Resource (*CreateTrusted)(PP_Instance instance); /** * Returns true if the resource is a trusted broker. */ PP_Bool (*IsBrokerTrusted)(PP_Resource resource); /** * Connects to the trusted broker. It may have already * been launched by another instance. * The plugin takes ownership of the handle once the callback has been called * with a result of PP_OK. The plugin should immediately call GetHandle and * begin managing it. If the result is not PP_OK, the browser still owns the * handle. * * Returns PP_ERROR_WOULD_BLOCK on success, and invokes * the |connect_callback| asynchronously to complete. * As this function should always be invoked from the main thread, * do not use the blocking variant of PP_CompletionCallback. * Returns PP_ERROR_FAILED if called from an in-process plugin. */ int32_t (*Connect)(PP_Resource broker, struct PP_CompletionCallback connect_callback); /** * Gets the handle to the pipe. Use once Connect has completed. Each instance * of this interface has its own pipe. * * Returns PP_OK on success, and places the result into the given output * parameter. The handle is only set when returning PP_OK. Calling this * before connect has completed will return PP_ERROR_FAILED. */ int32_t (*GetHandle)(PP_Resource broker, int32_t* handle); /** * Returns PP_TRUE if the plugin has permission to launch the broker. A user * must explicitly grant permission to launch the broker for a particular * website. This is done through an infobar that is displayed when |Connect| * is called. This function returns PP_TRUE if the user has already granted * permission to launch the broker for the website containing this plugin * instance. Returns PP_FALSE otherwise. */ PP_Bool (*IsAllowed)(PP_Resource broker); }; typedef struct PPB_BrokerTrusted_0_3 PPB_BrokerTrusted; struct PPB_BrokerTrusted_0_2 { PP_Resource (*CreateTrusted)(PP_Instance instance); PP_Bool (*IsBrokerTrusted)(PP_Resource resource); int32_t (*Connect)(PP_Resource broker, struct PP_CompletionCallback connect_callback); int32_t (*GetHandle)(PP_Resource broker, int32_t* handle); }; /** * @} */ #endif /* PPAPI_C_TRUSTED_PPB_BROKER_TRUSTED_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/trusted/ppb_browser_font_trusted.h000066400000000000000000000236711321746453100273770ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From trusted/ppb_browser_font_trusted.idl, * modified Thu Mar 28 10:14:27 2013. */ #ifndef PPAPI_C_TRUSTED_PPB_BROWSER_FONT_TRUSTED_H_ #define PPAPI_C_TRUSTED_PPB_BROWSER_FONT_TRUSTED_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_BROWSERFONT_TRUSTED_INTERFACE_1_0 "PPB_BrowserFont_Trusted;1.0" #define PPB_BROWSERFONT_TRUSTED_INTERFACE PPB_BROWSERFONT_TRUSTED_INTERFACE_1_0 /** * @file * This file defines the PPB_BrowserFont_Trusted interface. */ /** * @addtogroup Enums * @{ */ typedef enum { /** * Uses the user's default web page font (normally either the default serif * or sans serif font). */ PP_BROWSERFONT_TRUSTED_FAMILY_DEFAULT = 0, /** * These families will use the default web page font corresponding to the * given family. */ PP_BROWSERFONT_TRUSTED_FAMILY_SERIF = 1, PP_BROWSERFONT_TRUSTED_FAMILY_SANSSERIF = 2, PP_BROWSERFONT_TRUSTED_FAMILY_MONOSPACE = 3 } PP_BrowserFont_Trusted_Family; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_BrowserFont_Trusted_Family, 4); /** * Specifies the font weight. Normally users will only use NORMAL or BOLD. */ typedef enum { PP_BROWSERFONT_TRUSTED_WEIGHT_100 = 0, PP_BROWSERFONT_TRUSTED_WEIGHT_200 = 1, PP_BROWSERFONT_TRUSTED_WEIGHT_300 = 2, PP_BROWSERFONT_TRUSTED_WEIGHT_400 = 3, PP_BROWSERFONT_TRUSTED_WEIGHT_500 = 4, PP_BROWSERFONT_TRUSTED_WEIGHT_600 = 5, PP_BROWSERFONT_TRUSTED_WEIGHT_700 = 6, PP_BROWSERFONT_TRUSTED_WEIGHT_800 = 7, PP_BROWSERFONT_TRUSTED_WEIGHT_900 = 8, PP_BROWSERFONT_TRUSTED_WEIGHT_NORMAL = PP_BROWSERFONT_TRUSTED_WEIGHT_400, PP_BROWSERFONT_TRUSTED_WEIGHT_BOLD = PP_BROWSERFONT_TRUSTED_WEIGHT_700 } PP_BrowserFont_Trusted_Weight; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_BrowserFont_Trusted_Weight, 4); /** * @} */ /** * @addtogroup Structs * @{ */ struct PP_BrowserFont_Trusted_Description { /** * Font face name as a string. This can also be an undefined var, in which * case the generic family will be obeyed. If the face is not available on * the system, the browser will attempt to do font fallback or pick a default * font. */ struct PP_Var face; /** * When Create()ing a font and the face is an undefined var, the family * specifies the generic font family type to use. If the face is specified, * this will be ignored. * * When Describe()ing a font, the family will be the value you passed in when * the font was created. In other words, if you specify a face name, the * family will not be updated to reflect whether the font name you requested * is serif or sans serif. */ PP_BrowserFont_Trusted_Family family; /** * Size in pixels. * * You can specify 0 to get the default font size. The default font size * may vary depending on the requested font. The typical example is that * the user may have a different font size for the default monospace font to * give it a similar optical size to the proportionally spaced fonts. */ uint32_t size; /** * Normally you will use either normal or bold. */ PP_BrowserFont_Trusted_Weight weight; PP_Bool italic; PP_Bool small_caps; /** * Adjustment to apply to letter and word spacing, respectively. Initialize * to 0 to get normal spacing. Negative values bring letters/words closer * together, positive values separate them. */ int32_t letter_spacing; int32_t word_spacing; /** * Ensure that this struct is 48-bytes wide by padding the end. In some * compilers, PP_Var is 8-byte aligned, so those compilers align this struct * on 8-byte boundaries as well and pad it to 16 bytes even without this * padding attribute. This padding makes its size consistent across * compilers. */ int32_t padding; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_BrowserFont_Trusted_Description, 48); struct PP_BrowserFont_Trusted_Metrics { int32_t height; int32_t ascent; int32_t descent; int32_t line_spacing; int32_t x_height; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_BrowserFont_Trusted_Metrics, 20); struct PP_BrowserFont_Trusted_TextRun { /** * This var must either be a string or a null/undefined var (which will be * treated as a 0-length string). */ struct PP_Var text; /** * Set to PP_TRUE if the text is right-to-left. */ PP_Bool rtl; /** * Set to PP_TRUE to force the directionality of the text regardless of * content */ PP_Bool override_direction; }; PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_BrowserFont_Trusted_TextRun, 24); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * Provides an interface for native browser text rendering. * * This API is "trusted" not for security reasons, but because it can not be * implemented efficiently when running out-of-process in Browser Client. In * this case, WebKit is in another process and every text call would require a * synchronous IPC to the renderer. It is, however, available to native * (non-NaCl) out-of-process PPAPI plugins since WebKit is available in the * plugin process. */ struct PPB_BrowserFont_Trusted_1_0 { /** * Returns a list of all available font families on the system. You can use * this list to decide whether to Create() a font. * * The return value will be a single string with null characters delimiting * the end of each font name. For example: "Arial\0Courier\0Times\0". * * Returns an undefined var on failure (this typically means you passed an * invalid instance). */ struct PP_Var (*GetFontFamilies)(PP_Instance instance); /** * Returns a font which best matches the given description. The return value * will have a non-zero ID on success, or zero on failure. */ PP_Resource (*Create)( PP_Instance instance, const struct PP_BrowserFont_Trusted_Description* description); /** * Returns PP_TRUE if the given resource is a Font. Returns PP_FALSE if the * resource is invalid or some type other than a Font. */ PP_Bool (*IsFont)(PP_Resource resource); /** * Loads the description and metrics of the font into the given structures. * The description will be different than the description the font was * created with since it will be filled with the real values from the font * that was actually selected. * * The PP_Var in the description should be of type Void on input. On output, * this will contain the string and will have a reference count of 1. The * plugin is responsible for calling Release on this var. * * Returns PP_TRUE on success, PP_FALSE if the font is invalid or if the Var * in the description isn't Null (to prevent leaks). */ PP_Bool (*Describe)(PP_Resource font, struct PP_BrowserFont_Trusted_Description* description, struct PP_BrowserFont_Trusted_Metrics* metrics); /** * Draws the text to the image buffer. * * The given point represents the baseline of the left edge of the font, * regardless of whether it is left-to-right or right-to-left (in the case of * RTL text, this will actually represent the logical end of the text). * * The clip is optional and may be NULL. In this case, the text will be * clipped to the image. * * The image_data_is_opaque flag indicates whether subpixel antialiasing can * be performed, if it is supported. When the image below the text is * opaque, subpixel antialiasing is supported and you should set this to * PP_TRUE to pick up the user's default preferences. If your plugin is * partially transparent, then subpixel antialiasing is not possible and * grayscale antialiasing will be used instead (assuming the user has * antialiasing enabled at all). */ PP_Bool (*DrawTextAt)(PP_Resource font, PP_Resource image_data, const struct PP_BrowserFont_Trusted_TextRun* text, const struct PP_Point* position, uint32_t color, const struct PP_Rect* clip, PP_Bool image_data_is_opaque); /** * Returns the width of the given string. If the font is invalid or the var * isn't a valid string, this will return -1. * * Note that this function handles complex scripts such as Arabic, combining * accents, etc. so that adding the width of substrings won't necessarily * produce the correct width of the entire string. * * Returns -1 on failure. */ int32_t (*MeasureText)(PP_Resource font, const struct PP_BrowserFont_Trusted_TextRun* text); /** * Returns the character at the given pixel X position from the beginning of * the string. This handles complex scripts such as Arabic, where characters * may be combined or replaced depending on the context. Returns (uint32)-1 * on failure. * * TODO(brettw) this function may be broken. See the CharPosRTL test. It * seems to tell you "insertion point" rather than painting position. This * is useful but maybe not what we intended here. */ uint32_t (*CharacterOffsetForPixel)( PP_Resource font, const struct PP_BrowserFont_Trusted_TextRun* text, int32_t pixel_position); /** * Returns the horizontal advance to the given character if the string was * placed at the given position. This handles complex scripts such as Arabic, * where characters may be combined or replaced depending on context. Returns * -1 on error. */ int32_t (*PixelOffsetForCharacter)( PP_Resource font, const struct PP_BrowserFont_Trusted_TextRun* text, uint32_t char_offset); }; typedef struct PPB_BrowserFont_Trusted_1_0 PPB_BrowserFont_Trusted; /** * @} */ #endif /* PPAPI_C_TRUSTED_PPB_BROWSER_FONT_TRUSTED_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/trusted/ppb_char_set_trusted.h000066400000000000000000000106361321746453100264530ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From trusted/ppb_char_set_trusted.idl modified Wed Feb 8 16:34:25 2012. */ #ifndef PPAPI_C_TRUSTED_PPB_CHAR_SET_TRUSTED_H_ #define PPAPI_C_TRUSTED_PPB_CHAR_SET_TRUSTED_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_CHARSET_TRUSTED_INTERFACE_1_0 "PPB_CharSet_Trusted;1.0" #define PPB_CHARSET_TRUSTED_INTERFACE PPB_CHARSET_TRUSTED_INTERFACE_1_0 /** * @file * * This file defines the PPB_CharSet_Trusted interface. */ /** * @addtogroup Enums * @{ */ typedef enum { /** * Causes the entire conversion to fail if an error is encountered. The * conversion function will return NULL. */ PP_CHARSET_TRUSTED_CONVERSIONERROR_FAIL, /** * Silently skips over errors. Unrepresentable characters and input encoding * errors will be removed from the output. */ PP_CHARSET_TRUSTED_CONVERSIONERROR_SKIP, /** * Replaces the error or unrepresentable character with a substitution * character. When converting to a Unicode character set (UTF-8 or UTF-16) it * will use the unicode "substitution character" U+FFFD. When converting to * another character set, the character will be charset-specific. For many * languages this will be the representation of the '?' character. */ PP_CHARSET_TRUSTED_CONVERSIONERROR_SUBSTITUTE } PP_CharSet_Trusted_ConversionError; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CharSet_Trusted_ConversionError, 4); /** * @} */ /** * @addtogroup Interfaces * @{ */ /** * The PPB_CharSet_Trusted interface provides functions for * converting between character sets. * * This inteface is provided for trusted plugins only since in Native Client it * would require an expensive out-of-process IPC call for each conversion, * which makes performance unacceptable. Native Client plugins should include * ICU or some other library if they need this feature. */ struct PPB_CharSet_Trusted_1_0 { /** * Converts the UTF-16 string pointed to by |*utf16| to an 8-bit string in * the specified code page. |utf16_len| is measured in UTF-16 units, not * bytes. This value may not be NULL. * * The given output buffer will be filled up to output_length bytes with the * result. output_length will be updated with the number of bytes required * for the given string. The output buffer may be null to just retrieve the * required buffer length. * * This function will return PP_FALSE if there was an error converting the * string and you requested PP_CHARSET_CONVERSIONERROR_FAIL, or the output * character set was unknown. Otherwise, it will return PP_TRUE. */ PP_Bool (*UTF16ToCharSet)(const uint16_t utf16[], uint32_t utf16_len, const char* output_char_set, PP_CharSet_Trusted_ConversionError on_error, char* output_buffer, uint32_t* output_length); /** * Same as UTF16ToCharSet except converts in the other direction. The input * is in the given charset, and the |input_len| is the number of bytes in * the |input| string. * * Note that the output_utf16_length is measured in UTF-16 characters. * * Since UTF16 can represent every Unicode character, the only time the * replacement character will be used is if the encoding in the input string * is incorrect. */ PP_Bool (*CharSetToUTF16)(const char* input, uint32_t input_len, const char* input_char_set, PP_CharSet_Trusted_ConversionError on_error, uint16_t* output_buffer, uint32_t* output_utf16_length); /** * Returns a string var representing the current multi-byte character set of * the current system. * * WARNING: You really shouldn't be using this function unless you're dealing * with legacy data. You should be using UTF-8 or UTF-16 and you don't have * to worry about the character sets. */ struct PP_Var (*GetDefaultCharSet)(PP_Instance instance); }; typedef struct PPB_CharSet_Trusted_1_0 PPB_CharSet_Trusted; /** * @} */ #endif /* PPAPI_C_TRUSTED_PPB_CHAR_SET_TRUSTED_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/trusted/ppb_file_chooser_trusted.h000066400000000000000000000051551321746453100273240ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From trusted/ppb_file_chooser_trusted.idl, * modified Fri Mar 16 10:00:48 2012. */ #ifndef PPAPI_C_TRUSTED_PPB_FILE_CHOOSER_TRUSTED_H_ #define PPAPI_C_TRUSTED_PPB_FILE_CHOOSER_TRUSTED_H_ #include "ppapi/c/pp_array_output.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" #define PPB_FILECHOOSER_TRUSTED_INTERFACE_0_5 "PPB_FileChooserTrusted;0.5" #define PPB_FILECHOOSER_TRUSTED_INTERFACE_0_6 "PPB_FileChooserTrusted;0.6" #define PPB_FILECHOOSER_TRUSTED_INTERFACE PPB_FILECHOOSER_TRUSTED_INTERFACE_0_6 /** * @file * This file defines the PPB_FileChooser_Trusted interface. */ /** * @addtogroup Interfaces * @{ */ struct PPB_FileChooserTrusted_0_6 { /** * This function displays a previously created file chooser resource as a * dialog box, prompting the user to choose a file or files to open, or a * single file for saving. The callback is called with PP_OK on successful * completion with a file (or files) selected or PP_ERROR_USERCANCEL if the * user selected no file. * * @param[in] chooser The file chooser resource. * @param[in] save_as A PP_Bool value indicating if this dialog * is choosing a file for saving. * @param[in] suggested_file_name If saving, the suggested name for the * file, otherwise, null or undefined. * @param[in] callback A CompletionCallback to be called after * the user has closed the file chooser dialog. * * @return PP_OK_COMPLETIONPENDING if request to show the dialog was * successful, another error code from pp_errors.h on failure. */ int32_t (*ShowWithoutUserGesture)(PP_Resource chooser, PP_Bool save_as, struct PP_Var suggested_file_name, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); }; typedef struct PPB_FileChooserTrusted_0_6 PPB_FileChooserTrusted; struct PPB_FileChooserTrusted_0_5 { int32_t (*ShowWithoutUserGesture)(PP_Resource chooser, PP_Bool save_as, struct PP_Var suggested_file_name, struct PP_CompletionCallback callback); }; /** * @} */ #endif /* PPAPI_C_TRUSTED_PPB_FILE_CHOOSER_TRUSTED_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/trusted/ppb_url_loader_trusted.h000066400000000000000000000043531321746453100270120ustar00rootroot00000000000000/* Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From trusted/ppb_url_loader_trusted.idl modified Wed Oct 5 14:06:02 2011. */ #ifndef PPAPI_C_TRUSTED_PPB_URL_LOADER_TRUSTED_H_ #define PPAPI_C_TRUSTED_PPB_URL_LOADER_TRUSTED_H_ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #define PPB_URLLOADERTRUSTED_INTERFACE_0_3 "PPB_URLLoaderTrusted;0.3" #define PPB_URLLOADERTRUSTED_INTERFACE PPB_URLLOADERTRUSTED_INTERFACE_0_3 /** * @file * URL loader trusted interfaces. */ /** * @addtogroup Typedefs * @{ */ /** * Callback that indicates the status of the download and upload for the * given URLLoader resource. */ typedef void (*PP_URLLoaderTrusted_StatusCallback)( PP_Instance pp_instance, PP_Resource pp_resource, int64_t bytes_sent, int64_t total_bytes_to_be_sent, int64_t bytes_received, int64_t total_bytes_to_be_received); /** * @} */ /** * @addtogroup Interfaces * @{ */ /* Available only to trusted implementations. */ struct PPB_URLLoaderTrusted_0_3 { /** * Grant this URLLoader the capability to make unrestricted cross-origin * requests. */ void (*GrantUniversalAccess)(PP_Resource loader); /** * Registers that the given function will be called when the upload or * downloaded byte count has changed. This is not exposed on the untrusted * interface because it can be quite chatty and encourages people to write * feedback UIs that update as frequently as the progress updates. * * The other serious gotcha with this callback is that the callback must not * mutate the URL loader or cause it to be destroyed. * * However, the proxy layer needs this information to push to the other * process, so we expose it here. Only one callback can be set per URL * Loader. Setting to a NULL callback will disable it. */ void (*RegisterStatusCallback)(PP_Resource loader, PP_URLLoaderTrusted_StatusCallback cb); }; typedef struct PPB_URLLoaderTrusted_0_3 PPB_URLLoaderTrusted; /** * @} */ #endif /* PPAPI_C_TRUSTED_PPB_URL_LOADER_TRUSTED_H_ */ freshplayerplugin-0.3.9/3rdparty/ppapi/c/trusted/ppp_broker.h000066400000000000000000000044231321746453100244100ustar00rootroot00000000000000/* Copyright (c) 2011 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From trusted/ppp_broker.idl modified Sat Jul 16 16:51:03 2011. */ #ifndef PPAPI_C_TRUSTED_PPP_BROKER_H_ #define PPAPI_C_TRUSTED_PPP_BROKER_H_ #include "ppapi/c/pp_macros.h" /** * @file * This file defines functions that your module must implement to support a * broker. */ // {PENDING: undefine PP_EXPORT?} #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_stdint.h" #if __GNUC__ >= 4 #define PP_EXPORT __attribute__ ((visibility("default"))) #elif defined(_MSC_VER) #define PP_EXPORT __declspec(dllexport) #endif /* We don't want name mangling for these external functions. We only need * 'extern "C"' if we're compiling with a C++ compiler. */ #ifdef __cplusplus extern "C" { #endif /** * @addtogroup Typedefs * @{ */ /** * PP_ConnectInstance_Func defines the signature that you implement to * receive notifications when a plugin instance connects to the broker. * The broker should listen on the socket before returning. * * @param[in] instance The plugin instance connecting to the broker. * @param[in] handle Handle to a socket the broker can use to communicate with * the plugin. * @return PP_OK on success. Any other value on failure. */ typedef int32_t (*PP_ConnectInstance_Func)(PP_Instance instance, int32_t handle); /** * @} */ /** * @addtogroup Functions * @{ */ /** * PPP_InitializeBroker() is the entry point for a broker and is * called by the browser when your module loads. Your code must implement this * function. * * Failure indicates to the browser that this broker can not be used. In this * case, the broker will be unloaded. * * @param[out] connect_instance_func A pointer to a connect instance function. * @return PP_OK on success. Any other value on failure. */ PP_EXPORT int32_t PPP_InitializeBroker( PP_ConnectInstance_Func* connect_instance_func); /** * @} */ /** * @addtogroup Functions * @{ */ /** PPP_ShutdownBroker() is called before the broker is unloaded. */ PP_EXPORT void PPP_ShutdownBroker(); /** * @} */ #ifdef __cplusplus } /* extern "C" */ #endif #endif /* PPAPI_C_TRUSTED_PPP_BROKER_H_ */ freshplayerplugin-0.3.9/CMakeLists.txt000066400000000000000000000120511321746453100200330ustar00rootroot00000000000000project(freshplayerplugin) cmake_minimum_required(VERSION 2.8.8) # version set(VER_MAJOR 0) set(VER_MINOR 3) set(VER_MICRO 9) # setup compiler flags set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -fPIC -pthread") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror=format-security") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -pthread") #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror=format-security") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=implicit-function-declaration") # add missing NDEBUG in RelWithDebugInfo set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG -g3") set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DNDEBUG -g3") # generate more debug info for Debug build type set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g3") # directory for auto-generated headers include_directories("${CMAKE_BINARY_DIR}") # determine software version add_custom_target(git-revision ALL COMMAND sh "${CMAKE_SOURCE_DIR}/cmake/update-version-info.sh" "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" ${VER_MAJOR} ${VER_MINOR} ${VER_MICRO} WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") # find Ragel find_program(RAGEL ragel) if (${RAGEL} STREQUAL "RAGEL-NOTFOUND") message(FATAL_ERROR "Ragel State Machine Compiler not found") endif() # dependencies find_package(PkgConfig REQUIRED) pkg_check_modules(GLIB glib-2.0 REQUIRED) pkg_check_modules(REQ alsa gio-2.0 x11 xrandr xrender xcursor gl libdrm libevent libevent_pthreads cairo pango pangocairo pangoft2 freetype2 openssl icu-uc REQUIRED) # merge glib-2.0 list(APPEND REQ_LIBRARY_DIRS ${GLIB_LIBRARY_DIRS}) list(APPEND REQ_INCLUDE_DIRS ${GLIB_INCLUDE_DIRS}) list(APPEND REQ_LIBRARIES ${GLIB_LIBRARIES}) # libdl.so, librt.so, and libm.so list(APPEND REQ_LIBRARIES dl rt m) # OpenGL ES 2 set(WITH_GLES2 FALSE CACHE BOOLEAN "use system libGLESv2") if (WITH_GLES2) pkg_check_modules(GLES2 glesv2 REQUIRED) add_definitions(-DHAVE_GLES2=1) list(APPEND REQ_LIBRARY_DIRS ${GLES2_LIBRARY_DIRS}) list(APPEND REQ_INCLUDE_DIRS ${GLES2_INCLUDE_DIRS}) list(APPEND REQ_LIBRARIES ${GLES2_LIBRARIES}) else() # otherwise ANGLE will be used for shader translation endif() # optional dependencies message(STATUS "checking for optional dependencies") pkg_check_modules(PULSEAUDIO QUIET libpulse) pkg_check_modules(JACK QUIET jack) pkg_check_modules(SOXR QUIET soxr) set(WITH_PULSEAUDIO TRUE CACHE STRING "enable PulseAudio support") set(WITH_JACK TRUE CACHE STRING "enable JACK Audio Connection Kit") if (PULSEAUDIO_FOUND AND WITH_PULSEAUDIO) add_definitions(-DHAVE_PULSEAUDIO=1) message(STATUS " found libpulse, version ${PULSEAUDIO_VERSION} (optional)") list(APPEND REQ_LIBRARY_DIRS ${PULSEAUDIO_LIBRARY_DIRS}) list(APPEND REQ_INCLUDE_DIRS ${PULSEAUDIO_INCLUDE_DIRS}) list(APPEND REQ_LIBRARIES ${PULSEAUDIO_LIBRARIES}) else() message(STATUS " no libpulse found (optional)") endif() if (JACK_FOUND AND WITH_JACK) message(STATUS " found jack, version ${JACK_VERSION} (optional)") if (SOXR_FOUND) message(STATUS " found soxr, version ${SOXR_VERSION}") add_definitions(-DHAVE_JACK=1) list(APPEND REQ_LIBRARY_DIRS "${JACK_LIBRARY_DIRS}" "${SOXR_LIBRARY_DIRS}") list(APPEND REQ_INCLUDE_DIRS "${JACK_INCLUDE_DIRS}" "${SOXR_INCLUDE_DIRS}") list(APPEND REQ_LIBRARIES "${JACK_LIBRARIES}" "${SOXR_LIBRARIES}") else() message(STATUS " no soxr found, JACK output disabled") endif() else() message(STATUS " no jack found (optional)") endif() # hw accelerated decoding set(WITH_HWDEC TRUE CACHE STRING "enable hw accelerated decoding") if (WITH_HWDEC) pkg_check_modules(HWDEC libavcodec libavutil libva libva-x11 vdpau REQUIRED) list(APPEND REQ_LIBRARY_DIRS ${HWDEC_LIBRARY_DIRS}) list(APPEND REQ_INCLUDE_DIRS ${HWDEC_INCLUDE_DIRS}) list(APPEND REQ_LIBRARIES ${HWDEC_LIBRARIES}) add_subdirectory(cmake/ffmpeg-compat) endif() # using libv4l2 for colorspace conversion set(WITH_LIBV4L2 TRUE CACHE STRING "use libv4l2 for colorspace conversion") if (WITH_LIBV4L2) add_definitions(-DHAVE_LIBV4L2=1) pkg_check_modules(LIBV4L2 libv4l2 REQUIRED) list(APPEND REQ_LIBRARY_DIRS ${LIBV4L2_LIBRARY_DIRS}) list(APPEND REQ_INCLUDE_DIRS ${LIBV4L2_INCLUDE_DIRS}) list(APPEND REQ_LIBRARIES ${LIBV4L2_LIBRARIES}) else() add_definitions(-DHAVE_LIBV4L2=0) endif() include_directories(${REQ_INCLUDE_DIRS}) link_directories(${REQ_LIBRARY_DIRS}) add_definitions(${REQ_CFLAGS_OTHER}) add_definitions(-DXP_UNIX) include_directories(3rdparty) if (NOT WITH_GLES2) include_directories(3rdparty/angle/include) list(APPEND REQ_LIBRARIES shader_translator) endif() set(SYMBOLMAP "-Wl,-version-script=\"${CMAKE_SOURCE_DIR}/src/symbolmap\"") add_subdirectory(3rdparty) add_subdirectory(src) add_subdirectory(tests) freshplayerplugin-0.3.9/COPYING000066400000000000000000000001401321746453100163220ustar00rootroot00000000000000This software is distributed under the terms of the MIT License. See LICENSE.MIT for full text. freshplayerplugin-0.3.9/ChangeLog000066400000000000000000000116101321746453100170450ustar00rootroot000000000000002017-12-23 Rinat Ibragimov * release v0.3.9 * network: stop using files with NPN_PostURL 2017-12-09 Rinat Ibragimov * release: v0.3.8 * misc: add NPN_PluginThreadAsyncCall emulation for Firefox 58 2017-05-31 Rinat Ibragimov * release: v0.3.7 * graphics: add more fullscreen _NET_WM controls * misc: drop libpdf wrapper * misc: drop NaCl wrapper * misc: search for PepperFlash in Chrome component update directories 2016-10-05 Rinat Ibragimov * release: v0.3.6 * graphics: fix off-by-one pixel issue in fullscreen scaling mode * graphics: try to flicker less * misc: use ICU for character set conversion, use WhatWG canonical encoding name conversion * misc: guess default character encoding from locale name * misc: guess GTK+ major version at run time 2016-04-12 Rinat Ibragimov * release v0.3.5 * video: try /dev/video* instead of /dev/v4l/by-path/* * network: fix byte order in PPB_NetAddress * network: partially implement PPB_HostResolver;1.0 and PPB_UDPSocket;1.2 * mics: keep task order in PPB_MessageLoop 2015-12-20 Rinat Ibragimov * release: v0.3.4 * graphics: add non-XRender fallback paths * graphics: use ANGLE GLES2 emulation layer by default * graphics: restore mouse pointer when moved outside * audio: request reduced latency when capturing via PulseAudio * input: detect and handle mouse double clicks * misc: add `make install` rule * misc: add option to show version in context menu * misc: call gdb for crash debugging * misc: stop using -fvisibility directives 2015-10-03 Rinat Ibragimov * release: v0.3.3 * graphics: update fullscreen size at the very end of transition * net: implement PPB_NetAddress;1.0 inferface * audio: add "noaudio" backend which only provide sync events * misc: track origin threads of callbacks * misc: drop libconfig dependency, use own config parser * misc: avoid calling Javascript in NPP_SetWindow() * misc: fix -fvisibility=hidden build issue * misc: rename file name to libfreshwrapper-flashplayer.so 2015-08-17 Rinat Ibragimov * release: v0.3.2 * graphics: fix fullscreen geometry issue * grpahics: sync to vblank in fullscreen mode * audio: control JACK port autoconnection and server autostart * audio: add NPAPI audio control 2015-07-05 Rinat Ibragimov * release: v0.3.1 * core: make compilable against wider range of ffmpeg/libav versions * graphics: inherit Visual from Xembed socket window * graphics: use XRender for transparent 2d explicitly * video: add decoding through VDPAU * core: fix crash on double NP_Initialize call 2015-06-10 Rinat Ibragimov * release: v0.3.0 * audio: add audio capture support * network: implement UDP sockets and host resolver interfaces * core: stop postponing already started screen saver * graphics: implement custom cursors * graphics: add GLES2 shader translator from ANGLE * graphics: add video capture support * graphics: add H.264 video decode via VA-API 2015-04-25 Rinat Ibragimov * release: v0.2.4 * graphics: use XRender for presentation, enable 3d by default * graphics: high DPI support (device_scale) * graphics: add inhibition for cinnamon-screensaver * graphics: add inhibition for X internal screen saver * core: prefer UTF8 when putting text to clipboard * core: support windowed plugin mode, both direct and XEmbed * core: support Input Method Editors * core: enable mouse wheel events * core: make GTK+ major version selectable * audio: support playing audio through JACK 2015-02-16 Rinat Ibragimov * release: v0.2.3 * graphics: use libxrandr to get fullscreen geometry * core: honor document base URL * network: add dns0x20 workaround, don't resolve numeric addresses * network: fix handling of blocked URLs * core: implement ppb_x509_certificate 2015-01-13 Rinat Ibragimov * release v0.2.2 * core: implement Flash DRM interface. (Desktop PepperFlash doesn't use it, you need one from ChromeOS.) * core: fix malfunctioning nested submenus * core: implement file chooser dialog * graphics: fullscreen fixups, stop crashing on Alt-F4 * audio: rework ALSA code, add optional PulseAudio support * core: implement screen saver inhibition interface * graphics: use GLX to create GL context, for both GL and GLES * core: fix hangs caused by wrong nested message loop handling * core: add "quiet" config option to decrease amount of output * core: fix Referer bug 2014-10-22 Rinat Ibragimov * release: v0.2.1 * core: add less-strict URI parser * core: fix/implement transparency handling for 2d/3d * core: fix early-callback-calling bug * doc: initial ChangeLog, documenting changes from v0.2.0 freshplayerplugin-0.3.9/LICENSE000066400000000000000000000020261321746453100163010ustar00rootroot00000000000000The 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. freshplayerplugin-0.3.9/README.md000066400000000000000000000130551321746453100165570ustar00rootroot00000000000000About ===== PPAPI-host NPAPI-plugin adapter. As you know, Adobe have suspended further development of Flash player plugin for GNU/Linux. Latest available as an NPAPI plugin version 11.2 will get security updates for five years (since its release on May 4th, 2012), but further development have been ceased. Fortunately or not, newer versions are still available for Linux as a part of Chrome browser, where Flash comes bundled in a form of PPAPI plugin. PPAPI or Pepper Plugin API is an interface promoted by Chromium/Chrome team for browser plugins. It's NPAPI-inspired yet significantly different API which have every conceivable function plugin may want. Two-dimensional graphics, OpenGL ES, font rendering, network access, audio, and so on. It's huge, there are 111 groups of functions, called interfaces which todays Chromium browser offers to plugins. Although specs are not final yet, and new interface versions are arising, with some older ones getting deleted; rate of change have significantly slowed down. For various reasons Firefox developers are not interested now in implementing PPAPI in Firefox. However that does not mean it cannot be done. The main goal of this project is to get PPAPI (Pepper) Flash player working in Firefox. This can be done in two ways. First one is to implement full PPAPI interface in Firefox itself. Other one is to implement a wrapper, some kind of adapter which will look like browser to PPAPI plugin and look like NPAPI plugin for browser. First approach requires strong knowledge of Firefox internals, and moreover additional effort to get the code into mainstream. Maintaining a set of patches doesn't look like a good idea. Second approach allows to concentrate on two APIs only. Yes one of them is big, but still graspable. Second way will be used for the project. It will benefit other browsers too, not only Firefox. Status ====== Mostly works. Looks like all essential APIs are implemented. Known issues ============ described [here](doc/known-issues.md). Security note ============= All available Pepper Plugin API documentation usually accompanied with assertions of enhanced security due to active sandboxing usage. It's worth to note, that API itself doesn't make any sandboxing, it's only allows sandboxed implementations. This particular implementation **doesn't implement any sandbox**. That means if any malicious code breaks through plugin security, there is no additional barriers. This is the same level of security as NPAPI Flash have. Install ======= Project is using cmake (>=2.8.8) build system. * Install prerequisites. ``` Debian/Ubuntu: $ sudo apt-get install cmake gcc g++ pkg-config ragel libasound2-dev \ libssl-dev libglib2.0-dev libpango1.0-dev libgl1-mesa-dev \ libevent-dev libgtk2.0-dev libxrandr-dev libxrender-dev \ libxcursor-dev libv4l-dev libgles2-mesa-dev libavcodec-dev \ libva-dev libvdpau-dev libdrm-dev libicu-dev Fedora: $ sudo dnf install cmake gcc gcc-c++ pkgconfig ragel alsa-lib-devel openssl-devel \ glib2-devel pango-devel mesa-libGL-devel libevent-devel gtk2-devel \ libXrandr-devel libXrender-devel libXcursor-devel libv4l-devel \ mesa-libGLES-devel ffmpeg-devel libva-devel libvdpau-devel libdrm-devel \ pulseaudio-libs-devel libicu-devel ``` * (optional) To enable PulseAudio support, install `libpulse-dev`. * (optional) To enable JACK support, install `libjack-jackd2-dev` and `libsoxr-dev` * Create a `build` subdirectory in the root directory, from that folder, call ``` $ cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. $ make ``` * Put generated `libfreshwrapper-flashplayer.so` into browser plugins directory (`~/.mozilla/plugins`) or install system-wide by calling: ``` # make install ``` By default `make install` will put plugin(s) to `${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/mozilla/plugins`. The path could be changed either by changing CMake parameter `CMAKE_INSTALL_PREFIX`, or by setting `MOZPLUGIN_INSTALL_DIR`. When loaded by browser it will search for `libpepflashplayer.so` in a directories where it can be: in Chrome (stable/beta/unstable) directory, and in `/usr/lib/pepperflashplugin-nonfree/` (pepperflashplugin-nonfree puts it there). It should be enough to get it running, but if it doesn't, specify full path in `~/.config/freshwrapper.conf`. You may find sample configuration file in `/data`. It's better to have `manifest.json` alongside with `libpepflashplayer.so`, actual Flash version will be taken from that manifest. Hardware-accelerated video decoding code requires relatively new version of libavcodec (January 2013, version 54.39.0). If you don't have it yet, code won't compile unless you disable hwdec by `WITH_HWDEC=0`. To do so, change configuration step command to: ``` $ cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_HWDEC=0 .. ``` Note, even if built, hardware-accelerated video decoding is still disabled by default. You need to explicitly enable it in configuration file. Install / OpenGL|ES 2 support ----------------------------- Although it's better to use system implementation of OpenGL|ES 2, it's still possible to leverage [ANGLE](https://code.google.com/p/angleproject/) GLES2 emulation by adding `WITH_GLES2=0` to cmake command line at configuration time (`-DWITH_GLES2=0` to be exact). Note, that requires C++11-capable compiler. License ======= The MIT License. See `LICENSE` file for full text. Directory `3rdparty/` contains source code from 3rd parties which can be distributed under other license terms. See source code for details. freshplayerplugin-0.3.9/cmake/000077500000000000000000000000001321746453100163545ustar00rootroot00000000000000freshplayerplugin-0.3.9/cmake/ffmpeg-compat/000077500000000000000000000000001321746453100211015ustar00rootroot00000000000000freshplayerplugin-0.3.9/cmake/ffmpeg-compat/CMakeLists.txt000066400000000000000000000027121321746453100236430ustar00rootroot00000000000000# FFmpeg (libav) interface changes over time. Something new arises, something getting deprecated. # This script checks some essential parts include(CheckSymbolExists) include(CheckCSourceCompiles) set(CMAKE_REQUIRED_LIBRARIES "${REQ_LIBRARIES}") set(CMAKE_REQUIRED_INCLUDES "${REQ_INCLUDE_DIRS}") macro(MACRO_C_SOURCE_CHECK FILE_NAME HAVE_variable) unset(${HAVE_variable} CACHE) file(READ ${FILE_NAME} C_SRC) CHECK_C_SOURCE_COMPILES("${C_SRC}" ${HAVE_variable}) if (NOT ${HAVE_variable}) set(${HAVE_variable} 0) endif() endmacro() macro(MACRO_SYMBOL_CHECK SYMBOL HEADER_FILE HAVE_variable) unset(${HAVE_variable} CACHE) CHECK_SYMBOL_EXISTS(${SYMBOL} ${HEADER_FILE} ${HAVE_variable}) if (NOT ${HAVE_variable}) set(${HAVE_variable} 0) endif() endmacro() MACRO_C_SOURCE_CHECK(cfg_avpixelformat.c HAVE_AVPixelFormat) MACRO_C_SOURCE_CHECK(cfg_av_pix_fmt_vdpau.c HAVE_AV_PIX_FMT_VDPAU) MACRO_C_SOURCE_CHECK(cfg_avcodecid.c HAVE_AVCodecID) MACRO_C_SOURCE_CHECK(cfg_avcodeccontext_get_buffer2.c HAVE_AVCodecContext_get_buffer2) MACRO_C_SOURCE_CHECK(cfg_AVVDPAUContext.c HAVE_AVVDPAUContext) MACRO_SYMBOL_CHECK(av_frame_alloc "libavcodec/avcodec.h" HAVE_av_frame_alloc) MACRO_SYMBOL_CHECK(av_frame_free "libavcodec/avcodec.h" HAVE_av_frame_free) MACRO_SYMBOL_CHECK(avcodec_free_context "libavcodec/avcodec.h" HAVE_avcodec_free_context) configure_file("ffmpeg_compat.h.in" "${CMAKE_BINARY_DIR}/autogenerated_ffmpeg_compat.h" @ONLY) freshplayerplugin-0.3.9/cmake/ffmpeg-compat/cfg_AVVDPAUContext.c000066400000000000000000000001371321746453100245400ustar00rootroot00000000000000#include int main(void) { AVVDPAUContext vc; return sizeof(vc); } freshplayerplugin-0.3.9/cmake/ffmpeg-compat/cfg_av_pix_fmt_vdpau.c000066400000000000000000000001201321746453100254100ustar00rootroot00000000000000#include int main(void) { return AV_PIX_FMT_VDPAU; } freshplayerplugin-0.3.9/cmake/ffmpeg-compat/cfg_avcodeccontext_get_buffer2.c000066400000000000000000000001531321746453100273460ustar00rootroot00000000000000#include int main(void) { AVCodecContext c; return sizeof(c.get_buffer2); } freshplayerplugin-0.3.9/cmake/ffmpeg-compat/cfg_avcodecid.c000066400000000000000000000001201321746453100237760ustar00rootroot00000000000000#include int main(void) { return AV_CODEC_ID_NONE; } freshplayerplugin-0.3.9/cmake/ffmpeg-compat/cfg_avpixelformat.c000066400000000000000000000001171321746453100247440ustar00rootroot00000000000000#include int main(void) { return AV_PIX_FMT_NONE; } freshplayerplugin-0.3.9/cmake/ffmpeg-compat/ffmpeg_compat.h.in000066400000000000000000000010151321746453100244630ustar00rootroot00000000000000#define HAVE_AVPixelFormat (@HAVE_AVPixelFormat@) #define HAVE_AV_PIX_FMT_VDPAU (@HAVE_AV_PIX_FMT_VDPAU@) #define HAVE_AVCodecID (@HAVE_AVCodecID@) #define HAVE_AVCodecContext_get_buffer2 (@HAVE_AVCodecContext_get_buffer2@) #define HAVE_av_frame_alloc (@HAVE_av_frame_alloc@) #define HAVE_av_frame_free (@HAVE_av_frame_free@) #define HAVE_avcodec_free_context (@HAVE_avcodec_free_context@) #define HAVE_AVVDPAUContext (@HAVE_AVVDPAUContext@) freshplayerplugin-0.3.9/cmake/update-version-info.sh000066400000000000000000000014671321746453100226160ustar00rootroot00000000000000#!/bin/sh CMAKE_SOURCE_DIR=$1 CMAKE_BINARY_DIR=$2 VER_MAJOR=$3 VER_MINOR=$4 VER_MICRO=$5 HDR_NAME="$CMAKE_BINARY_DIR/autogenerated_version_info.h" update_header() { NEW_CONTENT="const char *g_version_info = \"v$VER_MAJOR.$VER_MINOR.$VER_MICRO, $1\";" OLD_CONTENT=$(cat "$HDR_NAME" 2>/dev/null) if [ "$NEW_CONTENT" != "$OLD_CONTENT" ]; then echo "$NEW_CONTENT" > $HDR_NAME fi } GIT_COMMAND_EXISTS=1 command -v git >/dev/null 2>&1 || GIT_COMMAND_EXISTS=0 if [ ! -d "$CMAKE_SOURCE_DIR/.git" -o $GIT_COMMAND_EXISTS -eq 0 ]; then update_header "no vcs hash" exit 0 fi GIT_HASH=$(cd "$CMAKE_SOURCE_DIR"; expr substr `git rev-parse HEAD` 1 8) GIT_HAVE_CHANGES=$(cd "$CMAKE_SOURCE_DIR"; git diff --exit-code --quiet && echo || echo ", with changes") update_header "$GIT_HASH$GIT_HAVE_CHANGES" freshplayerplugin-0.3.9/data/000077500000000000000000000000001321746453100162055ustar00rootroot00000000000000freshplayerplugin-0.3.9/data/freshwrapper.conf.example000066400000000000000000000101251321746453100232150ustar00rootroot00000000000000# Configuration options for FreshPlayerPlugin # This configuration file is optional. Wrapper will search for it first # in ~/.config/freshwrapper.conf, then in /etc/freshwrapper.conf. # If wrapper fails to find configuration, it will use default values, # which you can find below # Audio buffer is used to continuously provide sound adapter with data. # Values too low may lead to buffer underruns and stuttering. Values # too high will lead to noticeable latency. Usually plugin selects size # on its own, but you may override bounds here # lower bound for audio buffer size, in milliseconds audio_buffer_min_ms = 20 # higher bound of audio buffer size, in milliseconds audio_buffer_max_ms = 500 # output sound through JACK. If enabled, only JACK will be tried, and if # your machine doesn't have it, there would be no sound, and no sync audio_use_jack = 0 # whenever to automatically connect application ports to system ones. # If you set this to one, no sound would be produces until you make # connection some way jack_autoconnect_ports = 1 # JACK server name. Omit the option to use default value # # jack_server_name = "default" # starts JACK server on demand jack_autostart_server = 1 # Path to the Pepper Flash plugin. # If the option is absent, freshwrapper will search for Pepper Flash in # a number of locations where it could be. Usually that's enough, but if # not, you should manually enter the right path. Multiple paths could # be specified, separated by colon. #pepperflash_path = "/opt/google/chrome/PepperFlash/libpepflashplayer.so" # "Command-line" arguments for Flash flash_command_line = "enable_hw_video_decode=1,enable_stagevideo_auto=1" # enable 3d and stage 3d enable_3d = 1 # enable hardware-accelerated video decoding. Requires 3d to really work enable_hwdec = 0 # when set to 1, limits output to warnings and errors only quiet = 0 # When multiple monitors with different resolutions are used, size # of fullscreen window can vary. But some Flash movies request these # parameters once at startup and rely on them to be correct. By default, # if zeros are used here, freshwrapper will select minimal width and # height across all monitors. fullscreen_width = 0 fullscreen_height = 0 # Controls whenever _NET_WM_STATE_MAXIMIZED_HORZ and # _NET_WM_STATE_MAXIMIZED_VERT will be added to _NET_WM_STATE during fullscreen # transition. If going to full screen mode doesn't work, try to set them to 0. fullscreen_horz_maximize_atom = 1 fullscreen_vert_maximize_atom = 1 # Enables DNS query case randomization to partially protect against DNS # poisoning attacks. It was reported that some Mikrotik routers do not # support this trick. Set parameter to 0 if you have an affected model randomize_dns_case = 0 # scaling factor (floating point value) used to convert screen pixels # to device independent pixels. You may need it for displays with # high DPI device_scale = 1 # method org.freedesktop.ScreenSaver.SimulateUserActivity() in KDE 5 seems # to have no effect unless GetSessionIdleTime() called afterwards. Set # parameter to 1 to call latter quirk_plasma5_screensaver = 0 # whenever to use windowed plugin mode enable_windowed_mode = 1 # whenever XEmbed used in windowed mode (if browser advertises its support) enable_xembed = 1 # if set to 1, fullscreen window will be kept always above browser, and hidden # from taskbar and pager tie_fullscreen_window_to_browser = 1 # enable using of VA-API for hardware accelerated video decoding enable_vaapi = 1 # enable using of VDPAU for hardware accelerated video decoding enable_vdpau = 1 # microseconds to wait after vsync event vsync_afterwait_us = 0 # fullscreen transition delay, in milliseconds fs_delay_ms = 300 # wait for vertical blank event before drawing on screen enable_vsync = 1 # how close in time two clicks should be to treat them as a doubleclick double_click_delay_ms = 400 # show version and git commit hash (if was available) of freshwrapper # in the context menu (right mouse button menu) show_version_info = 0 # probe video capture devices for their names and capabilities probe_video_capture_devices = 1 # use XRender to blend images enable_xrender = 1 freshplayerplugin-0.3.9/doc/000077500000000000000000000000001321746453100160415ustar00rootroot00000000000000freshplayerplugin-0.3.9/doc/debugging-guide.md000066400000000000000000000057451321746453100214240ustar00rootroot00000000000000# Debugging guide Assuming you have Firefox as a browser. ## Simplify deploy First, put a symlink of built `libfreshwrapper-flashplayer.so` to `~/.mozilla/plugins`. This step simplifies deploy step. You just rebuild, restart browser, and you are running new version. ## Use `gdb` to get a backtrace Open terminal emulator window, execute command ``` $ ulimit -c unlimited ``` to enable creating of core files. Core file is a memory dump of failed process. Then launch browser from the same terminal (`$ firefox`), navigate to the page causing crash, make it crash, close the browser. File named "core" should appear in a current directory. You then launch gdb debugger with ``` $ gdb /usr/lib/firefox/plugin-container core ``` and in gdb shell type ``` (gdb) thread apply all bt ``` `bt` (or `backtrace`) command instructs gdb to print a backtrace, chain of calls which led to crash. If you build Debug of RelWithDebInfo version, it will also print source code references based on debug info embedded into the binary. `thread apply all bt` does that for every thread. Path to plugin-container file (which is binary used by Firefox to run plugins out-of-process. It's so called plugin host) may be different on your machine, you'll need to find it yourself. ## How to put large text block in a message on GitHub GitHub uses Markdown as a format language. You start large text block with \`\`\` on a separate line and end with another \`\`\` on a separate line. ## Running under Valgrind Valgrind is a great tool which can help to find subtle bugs. Major drawback is tremendous slowdown, programs typically run 10-20 slower under Valgrind. Hopefully one can check only `plugin-container`. Trick is replacing `plugin-container` with a shell script while renaming `plugin-container` to `plugin-container.bin`. ```sh #!/bin/sh PCBIN=/usr/lib/firefox/plugin-container.bin OPTS= OPTS="$OPTS --log-file=logv.%p" OPTS="$OPTS --smc-check=all-non-file" OPTS="$OPTS --error-limit=no" OPTS="$OPTS --num-callers=20" OPTS="$OPTS $VALGRIND_OPTS" if [ -n "$USE_VALGRIND" ]; then exec valgrind $OPTS $PCBIN $@ else exec $PCBIN $@ fi ``` Then you can run firefox instrumented like that: ``` USE_VALGRIND=1 firefox ``` It's worth to rebuild valgrind-friendly version of firefox from source ([link](https://developer.mozilla.org/en-US/docs/Mozilla/Testing/Valgrind)). ## Trace PPAPI plugin calls If you need to trace which calls original plugin plugin makes while running under Chrome, you can use [ppapi-trace](https://github.com/i-rinat/ppapi-trace). It's not an easy to use tool, you'll need to dig into code if you want to use it for anything other than just printing function names to the console. ## Verbose tracing Reconfiguring project with ``` $ cmake -DTRACE_ALL=1 .. ``` and subsequent rebuild will enable verbose tracing. There will be every API call in standard output, not only unimplemented functions. Verbose tracing can be enabled on per-file basis. One need to add `#define TRACE_ALL` line at the top of a source file. freshplayerplugin-0.3.9/doc/img-missing-pepflash.png000066400000000000000000000631421321746453100226000ustar00rootroot00000000000000PNG  IHDRkpH IDATxyP[W's" -@ 6`8Hr^^'RI&I׫zUS5t']Lz{X,8vmY HUITObcT.H{,=|58 |]fT ؈((۶ lW.ƆBlƎBsjFl(2YcJef1|`Si[bbdx8"p%۷'q` c(hNp_oMNzSRΈn;T*J%e ӱ;w O0ֱ,+|vaa'$ȝc^^hSS>oϗTTFFfњLllFLN[zzFs篱4),+SBHr22Ξ:}Ѳ8|8!)I\suחpvwd2I>-4ݸBiZ)q #z}ֽ^WWZmbRR$!D$'ׯWU95#r˕۷G[nݚ6"b-6tJJJ,B))s}>̛XL'055_[kii7ouWHs`?zTCQasr: Un˖(VǣܛFONM?Yg?j ᄐ8/9jj,^ U(*]Z*SdppZ3ݾ=/z?y~յo_lQQˤ({8==Ϭ/ :`(wosxv"6&>,b&ӊg$LSߵwoLQQ(2+K&뭍C 0TAALQ,,I_֋(pa\,/WJeTF;([;>Λyndj.2Y55Ye1tȬNgx{z?;={bvXZ[툎(#)-GD^}/Ci/p挭}\M`}ۛ%:fCt4l\<61))b0WU`| 6ؘ32PURRo??ruyV?.qlX#tUV 'zMc0k:x0.+KXUa\f\!}Yzhn_WgDU۶-9OTTgWp0RIU*)<1᭩9V OFj*_IHil+Hĥs,> qVWrKۇ%Xz2Y:*tllձsnڱCۣKeoӇ5X^Lsb6O?nXW3WIx>|( ٲ%JxKJLLvFRIՖKؽGe\.ӂ5֝fIIԵd,ezz֭ɹ9ߣv{|,.ڿ?_u;]+t:wZ,{!x:7o*,Lhk4"2l5^͉d>ms!]].&'`߲%jǎ>}q||˵gOLpۣlƕ+?Yg<XL(7mZv횳tέyrdЧ|+2\bbdDH @D""BllXd$+. ;|>gBB.Ǥufg}F׶8<;M܋[):}O_rl6#xQ{{5}_^uccsCC3u߼9A/mrBQpxvy\8n6{<={bO*-~7oNu]a ,*J((Xsv8<;mO<99`s~73X,jpGgg}^Sg/눖{ҪwE'z-Ҁ}{!_+;[m੧b^CzEQmzz\ݻE==d{XmCWow=3n.QY Cgnub+]%Ącnd]1O @x]700O @y1BHBottak_ 99*xEV7rzzQR"ǩŅ[vv|/4M" 8sryxTe^{ل(6!$;[OY|ʖ-Q۷GB9*Чh >I 9`ad2LjzzQ68޾}.msW99xa7ҰٌgMx ~oۻke07?q\^&:q({=e#z{(--„o~sSx8͉SEp|ؓwYHvw+8pGoNgz}A6_'snZ4ZCq~qDW?C G\ 2,{vr"gvry\(6?8 py>Ehɻ8$, !/b6OYEZI }[ m^~9uxxo9_?%g)+Sdf.9߾=YQaZTbfYf˳ĊE\s.ll&J q--ZC׮ "#Y%%1=f錷nM]u/\\,Ώ#x<~zȺ_Zm" !Y]m̯{\HMk4DGz+"Wx̢"޽1t07N#lrJRIlA)9O";[\Z*㜽^CPCpʅi~`[CVn& }/)/ORQa\Ɔi4٠nWen߈t23 CINz뭌/_KcJl\*֬Atv:{z\Ge0(&z,QU`? (##\!-r;~)dz$7_Scnmke D"/n5++Mʓ ZMoukR3.!Id|AwNT Vs}`c2CqBsM7ʅ;; bY~~ EQ\,ɑTT'D֭QMb\\u4ZWg}EP.lP~jlj;(B^z)QSc֍(vi<;{!j>~܈Q.<i bdaaL"wӣzkcnLuE bdtO668g |HGYY"BTǍf3 OJ8v,Q.8avq ’޿eɮ(cc!ryk]4zk mkkSBHd$;Iϗt!LXRVܼy! Weil̃A<cJCټ97ϟ_(,Lؿ?sv:窪Lׯ# ~}ML!]jkN*cL#|\ݡ\x<mA 9?і.We-'I,ʴ4e``}(?sLZ`֌3gl ;0J%}x6;<99(@: qzf(*-0bf㓒h11 qΘratf;\:V]v-4RP.Ff{ݸ3Ut.Ѷm~q+ b˜%2Q.jpaIY,/W+*LoOѦM2"`C+\X3&&ۭf;"L+ۚFONMaETG:zT<<<[Qa@\XK'}p@\aaà(gO̎ZKKHnD ;7)i($/0>V+32𷾵)/Om6Lx8<61))b0WV94ʅrH%$%EF #zbee0Bcc*8g 0.,?xPdR ΝjsGsL!,9P}ʅuVV7%ǏV @& ?v,4;Y]m@o iiZ)s !Je믧56YL%*,YT$+(Oe Q.tu *Tg(z؝;'N>de^ #lC+cZ2%O|IE 1VƆi48^Ng9r>%*+ U8{vi,8|8!)}pWqWǺ\EE %\LlQe j.P"B #zǃ1X(`xW'ɤ1N(yjjlG~ xd~}X'(099bt-[Ze\Bss(əvs]U&$Bx/権LLxDDEKKb:yppZ3ݾ8g ܾ=_u[T2)-NO>yr`Qy꩘GC+B<^?xVE8~ձ2Ů]"Bj$ǏcxXAryc Bիcf78Q.v{?dɮ*%0BB鍍#zufӖ`9x8XnLn4Xz{omPU*)͠(o_͚K[}(dgKKQQ8g0`ǧ X#N ^PiiBHTM˓TT K$nEorUV=)9[|3ܹ9DGp qsN'mΞW_x0:Zfe*+M8PFFZ 9~ x j7o$_j0WUp#q q:qhhr֛?("#Yk~}/ _dRJ P|mQ.G0:zϞ"l6QYNX3#:l&Ɔ /Y0+l33Ǎv6Q.'ƆHV>?LoXu:4A4]{ɂⴴhz(r[6&c!x@ F:;eT\Fl@Je}17޿VS_}5 Ǥ4bH\xR IDAT=:܎B X(9a1a P.=|3glcHַ TʣX(y>͛#|3m ˠ^[9x8x_g0CYY"w.%CXJP.,vzhK]b1^6 xTó}sii[3=gQ*UJ%'&556e rƍ"YAAl0:gvt^7`KIkJd!ιqDb4\e63㫬4؏KT("!I~rXu)..+S%SǏ-i4\bL~SO=*f%JK. #``0}b܅8'-.P. ŋ׮)p̲2EnX3ݾ=&x6mj ?`nx&&[0:Z#$$ʶf{]ejjMDDDyy:yxxF3ݼ8g@O͛{AQ$?_}{t]َE7篯V^ܾ=:xqon˓tA xµZM qׯWU94\OOJKٴ) FAV ,*Jط/sTVnpqF7n :$ FGk|`%*+SC/p6q΀rV1g+W29O/9?_әv,$LU-}} X#FFf?7+K랔/~`khu`*TgBn s{;XǺ\EEb#GvWVЫ iiZ)s@c^o!@k쬯*TFBbO鬮6c6攕)23iqՊGru׿Ϗ).!TApF8`Pt.7|] q΀r֗@\AdgKKtafr`+WMbjj(:{K˓TTj [llFEoqWTvP.|zw)!$99ꭷ2bK:f3 2kDtt8]EEL&3YY*0u###\\.\*c@<uٮ&&%EBD"/n5++MN'Ƈ&rjeFF4֭Ih͠qñf>;7WRR"`ƒhaa2CqN(yjjbG\X@47 Ge1E8Fq<'GRQa@ukFFFO"P.,O?584LN {Զ6GMeb‹&U.*]Z*^sZ+*Lo#P.,۷'{ (!,IQdnqzz^oml\X(8Y^?؈8g@2_wt)vBxVTz{h@~۠RIy&fPٻ7&3SXScrŁ xRd?s0lsrbc^z)} Wde-4Rf6Oލ;SxDii8^xp UPST$ c%)2: F::?aaPtɄB?2ر g7V8 ĄolW_}5i:=YšӃg~:\X'}p@\aaà(gO̎šKkNErr$Gܜ~ܹaL hhjoSфַ)?_m6LBiIIatΡqFt}qFFtyB$B"x#Sȸ\Ƒ#cPؘl0 P.lHxo0A)I1qYYª*sg'7LayB Xs⋡z׋ P.l`^IkkCILN"pKwd#:zHjr۶8羾 ,!~QOvT !۶ z+aah~WsP*sv556W9Ƌd{0xلݻƞDGO|&Q"Gz+P.̌bjBDNpVW]._?NYbN!d4Y,ӿuמ=1`tΝmz…DGu o_lQeeb]Qdo\x5]s(rrE\FY"/OoݚDQIIZmb|<>ѭZ$=P.,~yTMJyx޿˶{mej _0kIDD+㜇ft:? l``wo\E>?LKJKٴ)GYL[]˜EE  qB\XY]]~J%UY,~:nNQu1*kL "|3gl Cs@x?lkh))|B~ (b0q^P.<mW))_"a,JٌgWLf'ձnGdR"?fw)!)@--zXO]sVWN_YB!LcBۓr`5Z;!LI??a~c2Cy-SS@`tt(=esr:i``M6oj`#m155nnkH<GM &XRb:fZ(֞[&ʇErr'OZ.]­%(S1GV %x<~ r` wt8;w !<SM˓?nX0ǎ%*gu`R k5?LMk4 PDzzc^o4EEXnTT{zh GOR6AQd߾؝;556&HvTsz C C@Olksm(w'0#4ĭ[-ݮJA\Xvߗ),/WB֭Qoqp} !a&8G9\sUUN'Fq9"ۿ?RID&a|7NFFZ 9~Sj) 㯩1ڵĤHBPyŭxUyll#o劌hz˭[:fe|AwNTȈNI۾bhDG3x6{!ιj8P J/6Ƌe1ElѣNg_[Fiat45Y r0==Ʀ&c2Y8!$66S55ۻ.gʳuq4;i bdaaLBHv8--Z^8r jޘ"<;뭍s@r,!c\NN.6Q.8a^7QP.p@S]Q;W_M|yβvyS1;vkkͭk,::&gI"22O=&\Nt!$2o'tơH ͛#-7n*+M3^1ط}{tyy(p7LFGC.7`ι*8(`]>S`0CYYUBfLsX9]ա*l"DGs~-]]JñZ\Z&ܼ9ә r{ť(6!$-MukFCPCm~Id(*^qޚK[q( ȕ+7Ɵ{Nwol0:gvt'3/1%*%8G>̺vg~5ofWQajiqhJ""g)WUW?#>]VصKDo1t:ٌ8g Sߵwosυ2w FV:S-*Jrtg֋GrV@46tv:+6Qree\Ng}{rMZ2!!ލXs@Ąodjqqoϗ 7l6^b*{%v~{SS(`skBXn5I>-(`m 9ۣ-nMtFmf v61))"qǫLN%L&u@\aaJc1Af\II<"Eپ=:%__?xܰχ| l*xij=yҺ\q΁in Gc(p8byNX3ݼ9SrV(vi<;[LF4itO?58ZeBB8!$.˩mmĄ.E}9 nx|z #~ vܾ=_u[T2)-NO3ŋ#@B*8WǪn_:VVصKD27Wә) $x瞓K>:~@S]UJ$a".^3 P.cGQ$;[\Z* 9{8guAWl6HAAlf@x|xZr˖(zKWpxNršV+(w/L38}(`eq8„8jsgsU23eeh!d˖7L?wn~pn(`el]^ 9~ PqΏSgo*4+KTUe~}','V+I84{ T1ON"prhgT{(+SIt:[h" kCDD+㜇ft:gYLNVJɑʃ`tχ \Xnh‚4ZWgF|U0`/.PpIEM(֛(vi<;{!j>~h2Mq`~jlj;(B^z)QScz@Q HF9zkc(LSUPST$ cRٽ[[GЍ(6"رD<>vE!<?#Wde!<SVJ7͸M( ybއي S_an_2dha<.]=y҂h@fo*"#Cp! he~áCÇlE{c2355+W Tj7/9߸᪬4!8}6V+Hw/LCC (,Lؿ?sv:窪Lׯ#Vؘ۾=\)r!7GF ˎ²2E:xkxl_s*I:$ݵKT]mv U@,ʴ4e``w1xV&r~-]]JÁ0@0J%}x6;<99f |aϝ#m[f9ckhH[@إ5eLB3fjV0NeEEݻ^ .+S%X,ɁUefƧtJXLL~rXu5RJb0آ0&^X޻qg]mz`c2۴)RQ!k F:: gaarEnt$P.,ѣg0!޿Vs^?]& mMM'OZ~:\xErs%%%{un__?x0Ú? 8E={bvZZZP Kj"-xeCjeFF4!$"om˓tF a!rq"پ} FalSUe6 9 KIJ| Fz+H),+S q_|1T_oz 0.,?xPdR ΝjsG=H$\&15Oo뛨0̢q`]z'OZ[[Mbrr!D 4+1 @B fl6YlxQ39Md,?4əzII;c82`ŀxA b?3M HO$'9!^}~{{ N'qslZ-U,V77zz\x+ kk|>!g./44XP ٌ'R2dt#"6 /3[yW:\lXn@S.%iiê*3hB3ԉ"28BیPSWܷ/yd`LL`675Y\zr׮xBH˼ .6dR11:ŵ[g'_AYZ!%feC&m:{$ʔ:NgK @0H::VW$Ebb`ypS %$kkbybb`>Mv~\@:ZF,ૉD:E^FG øñ>_E[wKWO c^}5c``vcdRǎIRpŋnL~D\SgBBѓ׮9P 22zUrrle0Hnߞii@d IW+T}`E6qꔬDl0:BsGl%abYD;;zJ.#$'aą`P'i42yyyd߼9:g(d,?99XąT!@mC?tr:T ]\&H2=EJyNzK\k9҄Q@B@T680L*Cpz&{{tK|<ʒPǂamgmgr}^w\".@|9|) ̎zd qiQW .&sBq<@KI_T+{pQ-̟+/q=ls熋ŵ6!$'Gg6;ɵ5| .NFs{d', s588**C/v`x1E }lVQX(Gm%Llu=2:mhLO;?';w\L>!g%|cl6Cթ,Vx_`E*dzzܹ"᧤YY3'f".tJzgL& `Gu i4$b'!B\)11FU eq;`g[YYol WG+ͭ65Y`r)(j [y׮9Z[qBKSp%ie_ąH9葾>wSExV8u[U!\.SSJΟZ1E (*#6z?vuaI%'Y Ъ1TEEF#eo2Du?_T$Lt#.Jޙ3Н%`H w=􍀱̺pułGȈ _*.U]5djj7DyG=t׫RRb !2Yktt̴ؗ0E HIVdu5:q6DgMJaP9x0i~asۉhą \^O g׃f׭) !<wK ID}\p'OʎIf0n:0/cyyuu CIO7/_GyuoTDž|a]B بsv: J ̎xR2A;RT$llG@Q$Nܻwytta|zz*Q\dv׫23!A+y`h8XuqbRZJ9{f[O !@^9wnX\[+ل{og6;fZt=ͯWI$@ xdG3|ЬF#;|8lƋ/8 nhh AV((#ˢ0n-hr*GH8YwzssQq.AUV&k42A[Zlo4-l>:x0Z.(+0mm_q!==^WrC/C7]h]X@W|=(JJE8V(+ / .<<F^Z*eaѣ-,}^%r !ܟdoWEbd~@Q<)]qlGΞ UGs8 "eeKiqA&WڵQij΢6S zjBBUQ[#'.25:gg4Zgdvvt:X!9&JԏPX(j Bz&f9Pju*E1ԷRP jj^RRl}2+Ox,33s|DO糿xTZdW^8؉ffV~?v|N _%"[%ɤRE;wG΋ BaVؿɓۃ ;zcE9~{&dzdRGOF"+D}x6YY։7w_vN땡,BH0H"? "C0HnUG9FMDl0X=G\ZŁbyrr9۹ ,.?t7I8Wsh["%:/</=EJJyy.n 7.qgΨ =U7@D 7nLݽjBBUeemmm;.**0>< "l~}J"B 綷OLmW Ebqm:׷>.%tJ0&2޸1}D~ɓ#GjHd4Zf7.D:E^^"=0>97 D!/lv6k\ٵb1=b/??n,'3*,em^?A>:畕u>:g/a,PEEF#eB99&gy׫8z}y"+wzNV!\.SSJ .Y]-?x0s^ihz::@?ӳArkppd'_|1`y |>[Uu`XsJ .^T(x$?s75=eG׎ UYѤq8LO7oNc`Z^ PX(Lmm_:Ņ]zeZZ9$[.Q }ߑjbuT͐e<~wt8zeJ ӟ蘹tɾ9qHiF@kSs>?{vєECѶ.Wn'Uu66ZPu^UDž{:R"^ɾ:ghdI b1NL+.?@MLJrr,X,ϏK>"ŝ9R*yrj*'z<|09:gDQ$55nϞxiz/1(ghIENDB`freshplayerplugin-0.3.9/doc/known-issues.md000066400000000000000000000072371321746453100210410ustar00rootroot00000000000000# Known issues ## Failed to load libpepflashplayer.so You see fine example of [programmer art](http://en.wikipedia.org/wiki/Programmer_art) on a screen instead of a Flash movie: ![missing libpepflashplayer.so](img-missing-pepflash.png) That means you either have no `libpepflashplayer.so` or its location is unknown to freshwrapper. This project is a shim, adapter. It has no implementation of Flash technology itself, but allows using PepperFlash bundled with Chrome browser. Usually installing Chrome (stable, beta, or unstable) is enough, those paths are searched among the others. If you do have `libpepflashplayer.so` on your machine in some non-standard location, you have to add a line to `~/.config/freshwrapper.conf` with an actual path: ``` pepperflash_path = "/usr/lib64/PepperFlash/libpepflashplayer.so" ``` ## Flash version is incorrect For example, 13.1.2.3. PepperFlash have its version separated from binary, it's stored in a file named `manifest.json`. Make sure you have up-to-date `manifest.json` near `libpepflashplayer.so`. It's worth to note this version is used only for plugin listing in browser. Various version detection scripts on the web will acquire correct version from Flash internals. ## Web pages cannot find Flash at all Firefox caches plugin verion information to avoid calling all of them at startup. Sometimes it marks Flash as non-functional and doesn't try to reload it at all. Can be fixed by removing `pluginreg.dat` file from firefox profile directory. That file will be recreated on next Firefox startup. [Here](https://support.mozilla.org/en-US/kb/profiles-where-firefox-stores-user-data) is how to find where profile directory is. ## Flash have crashed or hung It's a bug. [Create an issue](https://github.com/i-rinat/freshplayerplugin/issues) about this. I need a scenario which can be used to reproduce an issue. It would be nice if you search through open issues to avoid duplicates. ## Black screen with sound only 3d is enabled by default at the moment, and requiring working OpenGL ES 2.0. With some video adapters 3d doesn't work as intended for some reason. If you have the issue, disable 3d by adding `enable_3d = 0` line to `~/.config/freshwrapper.conf`. If 3d generally works, but fails only for some instances, try to disable 3d for transparent movies by adding `enable_3d_transparent = 0` to `~/.config/freshwrapper.conf`. ## DRM doesn't work Desktop plugin doesn't use PPB_Flash_DRM interface, but plugin from ChromeOS does. To get it, download latest version of [linux_recovery.sh](https://dl.google.com/dl/edgedl/chromeos/recovery/linux_recovery.sh). That file contains a lot of links to ChromeOS recovery images for various Chromebooks. I tested one with "zako" in the name, it's for x86_64 hardware. Other recovery images may contain x86 and/or arm versions too. After download, find Flash player in `/opt/google/chrome/pepper/` directory on partition 3. Partition have to be mounted with "ro" flag, otherwise it won't work. After you extract libpepflashplayer.so (which is the only file you need from that entire image), add or update `pepperflash_path` parameter in configuration file `~/.config/freshwrapper.conf` to point to where you put libpepflashplayer.so. ## Random network downloads fail Some routers forcefully lowercase DNS queries, which interferes with dns0x20 security trick used by libevent2's DNS client. Configuration parameter `randomize_dns_case` is used to control whenever that trick is used. If you've enabled it, and have network issues, turn it off again. (See [dns0x20](https://tools.ietf.org/html/draft-vixie-dnsext-dns0x20-00) for details). ## Where is `mms.cfg`? Try `~/.config/freshwrapper-data/Shockwave Flash/System/mms.cfg` freshplayerplugin-0.3.9/doc/source-guide.md000066400000000000000000000065201321746453100207610ustar00rootroot00000000000000# Source guide This is a introductory document to work-in-progress project. Due to its changing nature, some parts of this page may become outdated. I put here some high-level concepts used in the code. Comments about particular parts are in the code. If there are no comments, well, that part is not documented. ## Project name Despite project name is FreshPlayerPlugin, I use term freshwrapper in this document and through the code, because (i) it shorter, and (ii) most of the code is target plugin agnostic. ## Directory structure `/src` — sources
`/tests` — tests
`/3rdparty` — source code from third parties
`/3rdparty/ppapi` — PPAPI headers from Chromium source / PPAPI SDK
`/3rdparty/npapi` — NPAPI headers from Mozilla Firefox source / Plugin SDK
`/3rdparty/parson` — JSON library called "parson"
In /src, each unit which name starts with `ppb_` implement particular PPB interface. Plain, trusted and private versions go to the same file. `np_functions.c` contains NPAPI plugin part functions. Some PPAPI interfaces, notably graphics and URL fetching have their code splitted between `ppb_*.c` and `np_functions.c`. ## Interfaces Read available documentation for [NPAPI](https://developer.mozilla.org/docs/Plugins) and [PPAPI](https://developer.chrome.com/native-client/pepper_stable/c). ## Threads NPAPI plugins are originally was running inside browser process. They were integrated into browsers main loop, so intensive computation or IO waiting was slowing browser down. Now all major browsers run plugins out-of-process, but plugin host process still immitates browser. PPAPI was designed to support out-of-process operation, but hopefully Flash still uses event-driven model. Despite similarity, one of Pepper interfaces relies on access to the core message loop to operate. That's why there are two main threads: one is "browser thread", and other is "plugin thread". When browser creates plugin instance, freshwrapper creates "plugin thread" and runs message loop instance in it. Having separate message loop allows reentring it, which in turn required for context menu support. Having two threads require sophisticated inter-thread call solution. Both NPAPI and PPAPI have callback support. First does this through `NPP_PluginThreadAsyncCall()`, second through `PPP_Core.CallOnMainThread()`. Hence the name suffixes for callback functions: `_ptac` and `_comt`. They have different prototypes, but difference in names makes it easier to discern them. It's crutial to call Pepper plugin functions on plugin thread, and Xlib and browser (NPN_*) functions in browser thread. ## Inter-thread calls Some of the API are callback-based. Function of some PPAPI interface may return PP_OK_COMPLETIONPENDING instead of result to tell caller that actual result will be delivered by asynchronous callback. But there are still functions have synchronous operation. Just waiting for a barrier can create a deadlock when two threads wait for each other. The solution is to run nested message loops. Plugin thread always have running message loop. Message loop for browser thread is created if there is no any. It's also crucial to pass correct depth of loop nesting to exit loops in a correct order. Some places (p2n_proxy_class.c) use chained callbacks to ensure message loop is running before actual callback is started. freshplayerplugin-0.3.9/src/000077500000000000000000000000001321746453100160635ustar00rootroot00000000000000freshplayerplugin-0.3.9/src/CMakeLists.txt000066400000000000000000000063311321746453100206260ustar00rootroot00000000000000set(TRACE_ALL 0 CACHE BOOLEAN "Enable tracing implemented functions") if(${TRACE_ALL}) add_definitions(-DTRACE_ALL) endif() set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(MOZPLUGIN_INSTALL_DIR "lib${LIB_SUFFIX}/mozilla/plugins/" CACHE STRING "plugin install directory") add_subdirectory(uri_parser) add_subdirectory(config_parser) set(source_list async_network.c audio_thread.c audio_thread_alsa.c audio_thread_noaudio.c config.c compat.c encoding_alias.c font.c gtk_wrapper.c header_parser.c keycodeconvert.c np_asynccall.c np_entry.c np_functions.c main_thread.c reverse_constant.c tables.c trace_helpers.c trace_core.c n2p_proxy_class.c p2n_proxy_class.c pp_interface.c pp_resource.c ppb_core.c ppb_audio_config.c ppb_audio_input.c ppb_audio.c ppb_browser_font.c ppb_buffer.c ppb_char_set.c ppb_crypto.c ppb_cursor_control.c ppb_device_ref.c ppb_file_chooser.c ppb_file_io.c ppb_file_ref.c ppb_flash_clipboard.c ppb_flash_drm.c ppb_flash_file.c ppb_flash_font_file.c ppb_flash_fullscreen.c ppb_flash.c ppb_flash_menu.c ppb_flash_message_loop.c ppb_font.c ppb_graphics2d.c ppb_graphics3d.c ppb_host_resolver.c ppb_image_data.c ppb_input_event.c ppb_instance.c ppb_memory.c ppb_message_loop.c ppb_messaging.c ppb_net_address.c ppb_network_monitor.c ppb_opengles2.c ppb_pdf.c ppb_printing.c ppb_tcp_socket.c ppb_text_input_controller.c ppb_text_input.c ppb_udp_socket.c ppb_uma.c ppb_url_loader.c ppb_url_request_info.c ppb_url_response_info.c ppb_url_util.c ppb_var.c ppb_video_capture.c ppb_view.c ppb_x509_certificate.c screensaver_control.c x11_event_thread.c ) if (PULSEAUDIO_FOUND AND WITH_PULSEAUDIO) list(APPEND source_list audio_thread_pulseaudio.c) endif() if (JACK_FOUND AND SOXR_FOUND AND WITH_JACK) list(APPEND source_list audio_thread_jack.c) endif() if (NOT WITH_GLES2) list(APPEND source_list shader_translator.cc) endif() if (WITH_HWDEC) add_definitions(-DHAVE_HWDEC=1) list(APPEND source_list ppb_video_decoder.c) else() add_definitions(-DHAVE_HWDEC=0) endif() add_executable(link_check link_check.c) target_link_libraries(link_check ${REQ_LIBRARIES}) add_library(freshwrapper-obj OBJECT ${source_list}) add_dependencies(freshwrapper-obj link_check) # ensure libfreshwrapper-*.so are linked with all libraries they use add_executable(dep_check dep_check.c) link_directories(${CMAKE_CURRENT_BINARY_DIR}) set(COMMON_OBJ_LIST $ $ $ $ ) # wrapper for PepperFlash set(WITH_PEPPERFLASH TRUE CACHE STRING "generate wrapper for PepperFlash") if (WITH_PEPPERFLASH) add_library(freshwrapper-flashplayer SHARED ${COMMON_OBJ_LIST} config_pepperflash.c) target_link_libraries(freshwrapper-flashplayer ${SYMBOLMAP} ${REQ_LIBRARIES}) target_link_libraries(dep_check freshwrapper-flashplayer) install(TARGETS freshwrapper-flashplayer DESTINATION ${MOZPLUGIN_INSTALL_DIR}) endif() freshplayerplugin-0.3.9/src/async_network.c000066400000000000000000000515471321746453100211310ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "async_network.h" #include "config.h" #include "pp_resource.h" #include "ppb_host_resolver.h" #include "ppb_message_loop.h" #include "ppb_tcp_socket.h" #include "ppb_udp_socket.h" #include "trace_core.h" #include "trace_helpers.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static struct event_base *event_b = NULL; static struct evdns_base *evdns_b = NULL; static GHashTable *tasks_ht = NULL; static pthread_mutex_t lock; static const struct timeval connect_timeout = { .tv_sec = 60, .tv_usec = 0 }; static void __attribute__((constructor)) async_network_constructor(void) { tasks_ht = g_hash_table_new(g_direct_hash, g_direct_equal); pthread_mutex_init(&lock, NULL); } static void __attribute__((destructor)) async_network_destructor(void) { g_hash_table_unref(tasks_ht); pthread_mutex_destroy(&lock); } static int32_t get_pp_errno(void) { int retval = PP_ERROR_FAILED; switch (errno) { case EACCES: case EPERM: return PP_ERROR_NOACCESS; case EADDRINUSE: return PP_ERROR_ADDRESS_IN_USE; case ECONNREFUSED: return PP_ERROR_CONNECTION_REFUSED; case ENETUNREACH: return PP_ERROR_ADDRESS_UNREACHABLE; case ETIMEDOUT: return PP_ERROR_CONNECTION_TIMEDOUT; case ENOTCONN: return PP_ERROR_CONNECTION_CLOSED; case ECONNRESET: return PP_ERROR_CONNECTION_RESET; case EAGAIN: case EBADF: return PP_ERROR_FAILED; default: trace_error("%s, no conversion for %d\n", __func__, errno); } return retval; } static void add_event_mapping(struct async_network_task_s *task, struct event *ev) { pthread_mutex_lock(&lock); task->event = ev; g_hash_table_replace(tasks_ht, task, task); pthread_mutex_unlock(&lock); } struct async_network_task_s * async_network_task_create(void) { return g_slice_new0(struct async_network_task_s); } static void task_destroy(struct async_network_task_s *task) { pthread_mutex_lock(&lock); g_hash_table_remove(tasks_ht, task); if (task->event) { event_free(task->event); task->event = NULL; } free(task->host); g_slice_free(struct async_network_task_s, task); pthread_mutex_unlock(&lock); } static void handle_tcp_connect_stage3(struct async_network_task_s *task); static void handle_tcp_connect_stage4(int sock, short event_flags, void *arg) { struct async_network_task_s *task = arg; struct pp_tcp_socket_s *ts = pp_resource_acquire(task->resource, PP_RESOURCE_TCP_SOCKET); if (!ts) { trace_warning("%s, tcp socket resource was closed during request (%s:%u)\n", __func__, task->host, (unsigned int)task->port); free(task->addr); task_destroy(task); return; } char buf[200]; socklen_t len = sizeof(buf); if (event_flags & EV_TIMEOUT) ts->is_connected = 0; else ts->is_connected = (getpeername(ts->sock, (struct sockaddr *)buf, &len) == 0); if (ts->is_connected) { ppb_message_loop_post_work_with_result(task->callback_ml, task->callback, 0, PP_OK, 0, __func__); pp_resource_release(task->resource); free(task->addr); task_destroy(task); return; } // try other addresses, one by one task->addr_ptr++; if (task->addr_ptr < task->addr_count) { pp_resource_release(task->resource); handle_tcp_connect_stage3(task); return; } // no addresses left, fail gracefully trace_warning("%s, connection failed to all addresses (%s:%u)\n", __func__, task->host, (unsigned int)task->port); ppb_message_loop_post_work_with_result(task->callback_ml, task->callback, 0, get_pp_errno(), 0, __func__); pp_resource_release(task->resource); free(task->addr); task_destroy(task); } static void handle_tcp_connect_stage3(struct async_network_task_s *task) { int res = -1; if (task->addr_type == DNS_IPv4_A) { struct sockaddr_in sai; memset(&sai, 0, sizeof(sai)); sai.sin_family = AF_INET; sai.sin_addr.s_addr = *((uint32_t *)task->addr + task->addr_ptr); sai.sin_port = htons(task->port); res = connect(task->sock, (struct sockaddr *)&sai, sizeof(sai)); } else if (task->addr_type == DNS_IPv6_AAAA) { struct sockaddr_in6 sai; memset(&sai, 0, sizeof(sai)); sai.sin6_family = AF_INET6; memcpy(&sai.sin6_addr, (char*)task->addr + task->addr_ptr * sizeof(sai.sin6_addr), sizeof(sai.sin6_addr)); sai.sin6_port = htons(task->port); res = connect(task->sock, (struct sockaddr *)&sai, sizeof(sai)); } else { // handled in stage2 trace_error("%s, never reached\n", __func__); } if (res != 0 && errno != EINPROGRESS) { trace_error("%s, res = %d, errno = %d (%s:%u)\n", __func__, res, errno, task->host, (unsigned int)task->port); ppb_message_loop_post_work_with_result(task->callback_ml, task->callback, 0, get_pp_errno(), 0, __func__); free(task->addr); task_destroy(task); return; } struct event *ev = event_new(event_b, task->sock, EV_WRITE, handle_tcp_connect_stage4, task); add_event_mapping(task, ev); event_add(ev, &connect_timeout); } static void handle_tcp_connect_stage2(int result, char type, int count, int ttl, void *addresses, void *arg) { struct async_network_task_s *task = arg; if (result != DNS_ERR_NONE || count < 1) { trace_warning("%s, evdns returned code %d, count = %d (%s:%u)\n", __func__, result, count, task->host, (unsigned int)task->port); ppb_message_loop_post_work_with_result(task->callback_ml, task->callback, 0, PP_ERROR_NAME_NOT_RESOLVED, 0, __func__); task_destroy(task); return; } evutil_make_socket_nonblocking(task->sock); task->addr_count = count; task->addr_ptr = 0; task->addr_type = type; if (type == DNS_IPv4_A) { task->addr = malloc(4 * count); memcpy(task->addr, addresses, 4 * count); } else if (type == DNS_IPv6_AAAA) { task->addr = malloc(16 * count); memcpy(task->addr, addresses, 16 * count); } else { trace_error("%s, bad evdns type %d (%s:%u)\n", __func__, type, task->host, (unsigned int)task->port); ppb_message_loop_post_work_with_result(task->callback_ml, task->callback, 0, PP_ERROR_FAILED, 0, __func__); task_destroy(task); return; } handle_tcp_connect_stage3(task); } static void handle_tcp_connect_stage1(struct async_network_task_s *task) { struct evdns_request *req; struct sockaddr_in sai; memset(&sai, 0, sizeof(sai)); if (inet_pton(AF_INET, task->host, &sai.sin_addr) == 1) { // already a valid IP address handle_tcp_connect_stage2(DNS_ERR_NONE, DNS_IPv4_A, 1, 300, &sai.sin_addr, task); return; } // queue DNS request req = evdns_base_resolve_ipv4(evdns_b, task->host, DNS_QUERY_NO_SEARCH, handle_tcp_connect_stage2, task); // TODO: what about ipv6? if (!req) { trace_warning("%s, early dns resolution failure (%s:%u)\n", __func__, task->host, (unsigned int)task->port); ppb_message_loop_post_work_with_result(task->callback_ml, task->callback, 0, PP_ERROR_NAME_NOT_RESOLVED, 0, __func__); task_destroy(task); return; } } static void handle_tcp_connect_with_net_address(struct async_network_task_s *task) { if (task->netaddr.size == sizeof(struct sockaddr_in)) { struct sockaddr_in *sai = (void *)task->netaddr.data; task->port = ntohs(sai->sin_port); handle_tcp_connect_stage2(DNS_ERR_NONE, DNS_IPv4_A, 1, 3600, &sai->sin_addr, task); } else if (task->netaddr.size == sizeof(struct sockaddr_in6)) { struct sockaddr_in6 *sai = (void *)task->netaddr.data; task->port = ntohs(sai->sin6_port); handle_tcp_connect_stage2(DNS_ERR_NONE, DNS_IPv6_AAAA, 1, 3600, &sai->sin6_addr, task); } else { trace_error("%s, bad address type\n", __func__); ppb_message_loop_post_work_with_result(task->callback_ml, task->callback, 0, PP_ERROR_NAME_NOT_RESOLVED, 0, __func__); task_destroy(task); } } static void handle_tcp_read_stage2(int sock, short event_flags, void *arg) { struct async_network_task_s *task = arg; int32_t retval; retval = recv(sock, task->buffer, task->bufsize, 0); if (retval < 0) retval = get_pp_errno(); else if (retval == 0) { struct pp_tcp_socket_s *ts = pp_resource_acquire(task->resource, PP_RESOURCE_TCP_SOCKET); if (ts) { ts->seen_eof = 1; pp_resource_release(task->resource); } } ppb_message_loop_post_work_with_result(task->callback_ml, task->callback, 0, retval, 0, __func__); task_destroy(task); } static void handle_tcp_read_stage1(struct async_network_task_s *task) { struct pp_tcp_socket_s *ts = pp_resource_acquire(task->resource, PP_RESOURCE_TCP_SOCKET); if (!ts) { trace_error("%s, bad resource\n", __func__); task_destroy(task); return; } struct event *ev = event_new(event_b, ts->sock, EV_READ, handle_tcp_read_stage2, task); pp_resource_release(task->resource); add_event_mapping(task, ev); event_add(ev, NULL); } static void handle_tcp_write_stage2(int sock, short event_flags, void *arg) { struct async_network_task_s *task = arg; int32_t retval = send(sock, task->buffer, task->bufsize, 0); if (retval < 0) retval = get_pp_errno(); ppb_message_loop_post_work_with_result(task->callback_ml, task->callback, 0, retval, 0, __func__); task_destroy(task); } static void handle_tcp_write_stage1(struct async_network_task_s *task) { struct pp_tcp_socket_s *ts = pp_resource_acquire(task->resource, PP_RESOURCE_TCP_SOCKET); if (!ts) { trace_error("%s, bad resource\n", __func__); task_destroy(task); return; } struct event *ev = event_new(event_b, ts->sock, EV_WRITE, handle_tcp_write_stage2, task); pp_resource_release(task->resource); add_event_mapping(task, ev); event_add(ev, NULL); } static void handle_disconnect_stage2(int sock, short event_flags, void *arg) { struct async_network_task_s *task = arg; GHashTableIter iter; gpointer key, val; pthread_mutex_lock(&lock); g_hash_table_iter_init(&iter, tasks_ht); while (g_hash_table_iter_next(&iter, &key, &val)) { struct async_network_task_s *cur = key; if (cur == task) // skip current task continue; if (cur->resource == task->resource) { g_hash_table_iter_remove(&iter); event_free(cur->event); ppb_message_loop_post_work_with_result(cur->callback_ml, cur->callback, 0, PP_ERROR_ABORTED, 0, __func__); g_slice_free(struct async_network_task_s, cur); } } pthread_mutex_unlock(&lock); close(task->sock); task_destroy(task); } static void handle_disconnect_stage1(struct async_network_task_s *task) { struct event *ev = evtimer_new(event_b, handle_disconnect_stage2, task); struct timeval timeout = {.tv_sec = 0}; add_event_mapping(task, ev); event_add(ev, &timeout); } static void handle_udp_recv_stage2(int sock, short event_flags, void *arg) { struct async_network_task_s *task = arg; struct pp_udp_socket_s *us = pp_resource_acquire(task->resource, PP_RESOURCE_UDP_SOCKET); if (!us) { trace_error("%s, bad resource\n", __func__); task_destroy(task); return; } socklen_t len = sizeof(task->addr_from->data); int32_t retval = recvfrom(sock, task->buffer, task->bufsize, 0, (struct sockaddr *)task->addr_from->data, &len); task->addr_from->size = len; if (task->addr_from_resource) pp_resource_unref(task->addr_from_resource); if (retval < 0) retval = get_pp_errno(); else if (retval == 0) { us->seen_eof = 1; // TODO: is it needed? } pp_resource_release(task->resource); ppb_message_loop_post_work_with_result(task->callback_ml, task->callback, 0, retval, 0, __func__); task_destroy(task); } static void handle_udp_recv_stage1(struct async_network_task_s *task) { struct pp_udp_socket_s *us = pp_resource_acquire(task->resource, PP_RESOURCE_UDP_SOCKET); if (!us) { trace_error("%s, bad resource\n", __func__); task_destroy(task); return; } memset(task->addr_from, 0, sizeof(*task->addr_from)); struct event *ev = event_new(event_b, us->sock, EV_READ, handle_udp_recv_stage2, task); pp_resource_release(task->resource); add_event_mapping(task, ev); event_add(ev, NULL); } static void handle_udp_send_stage2(int sock, short event_flags, void *arg) { struct async_network_task_s *task = arg; int retval = sendto(sock, task->buffer, task->bufsize, MSG_NOSIGNAL, (struct sockaddr *)task->netaddr.data, task->netaddr.size); if (retval < 0) retval = get_pp_errno(); ppb_message_loop_post_work_with_result(task->callback_ml, task->callback, 0, retval, 0, __func__); task_destroy(task); } static void handle_udp_send_stage1(struct async_network_task_s *task) { struct pp_udp_socket_s *us = pp_resource_acquire(task->resource, PP_RESOURCE_UDP_SOCKET); if (!us) { trace_error("%s, bad resource\n", __func__); task_destroy(task); return; } // try to send immediately, but don't wait int retval = sendto(us->sock, task->buffer, task->bufsize, MSG_DONTWAIT | MSG_NOSIGNAL, (struct sockaddr *)task->netaddr.data, task->netaddr.size); pp_resource_release(task->resource); if (retval >= 0) { // successfully sent ppb_message_loop_post_work_with_result(task->callback_ml, task->callback, 0, retval, 0, __func__); task_destroy(task); return; } // need to wait struct event *ev = event_new(event_b, us->sock, EV_WRITE, handle_udp_send_stage2, task); add_event_mapping(task, ev); event_add(ev, NULL); } static void handle_host_resolve_stage2(int result, char type, int count, int ttl, void *addresses, void *arg) { struct async_network_task_s *task = arg; if (result != DNS_ERR_NONE || count < 1) { trace_warning("%s, evdns returned code %d, count = %d (%s:%u)\n", __func__, result, count, task->host, (unsigned int)task->port); ppb_message_loop_post_work_with_result(task->callback_ml, task->callback, 0, PP_ERROR_NAME_NOT_RESOLVED, 0, __func__); task_destroy(task); return; } struct pp_host_resolver_s *hr = pp_resource_acquire(task->resource, PP_RESOURCE_HOST_RESOLVER); if (!hr) { trace_error("%s, bad resource\n", __func__); task_destroy(task); return; } hr->addr_count = count; hr->addrs = calloc(count, sizeof(struct PP_NetAddress_Private)); if (type == DNS_IPv4_A) { struct in_addr *ipv4_addrs = addresses; for (int k = 0; k < count; k ++) { struct sockaddr_in sai = { .sin_family = AF_INET, .sin_port = htons(task->port), }; memcpy(&sai.sin_addr, &ipv4_addrs[k], sizeof(struct in_addr)); hr->addrs[k].size = sizeof(struct sockaddr_in); memcpy(hr->addrs[k].data, &sai, sizeof(sai)); } ppb_message_loop_post_work_with_result(task->callback_ml, task->callback, 0, PP_OK, 0, __func__); } else if (type == DNS_IPv6_AAAA) { struct in6_addr *ipv6_addrs = addresses; for (int k = 0; k < count; k ++) { struct sockaddr_in6 sai6 = { .sin6_family = AF_INET6, .sin6_port = htons(task->port), }; memcpy(&sai6.sin6_addr, &ipv6_addrs[k], sizeof(struct in6_addr)); hr->addrs[k].size = sizeof(struct sockaddr_in6); memcpy(hr->addrs[k].data, &sai6, sizeof(sai6)); } ppb_message_loop_post_work_with_result(task->callback_ml, task->callback, 0, PP_OK, 0, __func__); } else { trace_error("%s, bad evdns type %d (%s:%u)\n", __func__, type, task->host, (unsigned int)task->port); ppb_message_loop_post_work_with_result(task->callback_ml, task->callback, 0, PP_ERROR_FAILED, 0, __func__); } pp_resource_release(task->resource); task_destroy(task); } static void handle_host_resolve_stage1(struct async_network_task_s *task) { struct evdns_request *req; // queue DNS request req = evdns_base_resolve_ipv4(evdns_b, task->host, DNS_QUERY_NO_SEARCH, handle_host_resolve_stage2, task); // TODO: what about ipv6? if (!req) { trace_warning("%s, early dns resolution failure (%s:%u)\n", __func__, task->host, (unsigned int)task->port); ppb_message_loop_post_work_with_result(task->callback_ml, task->callback, 0, PP_ERROR_NAME_NOT_RESOLVED, 0, __func__); task_destroy(task); return; } } static void * network_worker_thread(void *param) { event_base_dispatch(event_b); event_base_free(event_b); trace_error("%s, thread terminated\n", __func__); return NULL; } void async_network_task_push(struct async_network_task_s *task) { static int thread_started = 0; if (!thread_started) { pthread_t t; evthread_use_pthreads(); event_b = event_base_new(); evdns_b = evdns_base_new(event_b, 0); evdns_base_resolv_conf_parse(evdns_b, DNS_OPTIONS_ALL, "/etc/resolv.conf"); if (config.randomize_dns_case == 0) evdns_base_set_option(evdns_b, "randomize-case:", "0"); pthread_create(&t, NULL, network_worker_thread, NULL); pthread_detach(t); thread_started = 1; } switch (task->type) { case ASYNC_NETWORK_TCP_CONNECT: handle_tcp_connect_stage1(task); break; case ASYNC_NETWORK_TCP_CONNECT_WITH_NETADDRESS: handle_tcp_connect_with_net_address(task); break; case ASYNC_NETWORK_DISCONNECT: handle_disconnect_stage1(task); break; case ASYNC_NETWORK_TCP_READ: handle_tcp_read_stage1(task); break; case ASYNC_NETWORK_TCP_WRITE: handle_tcp_write_stage1(task); break; case ASYNC_NETWORK_UDP_RECV: handle_udp_recv_stage1(task); break; case ASYNC_NETWORK_UDP_SEND: handle_udp_send_stage1(task); break; case ASYNC_NETWORK_HOST_RESOLVE: handle_host_resolve_stage1(task); break; } } freshplayerplugin-0.3.9/src/async_network.h000066400000000000000000000050311321746453100211210ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include #include #include enum async_network_task_type_e { ASYNC_NETWORK_TCP_CONNECT, ASYNC_NETWORK_TCP_CONNECT_WITH_NETADDRESS, ASYNC_NETWORK_TCP_READ, ASYNC_NETWORK_TCP_WRITE, ASYNC_NETWORK_UDP_RECV, ASYNC_NETWORK_UDP_SEND, ASYNC_NETWORK_DISCONNECT, ASYNC_NETWORK_HOST_RESOLVE, }; struct async_network_task_s { enum async_network_task_type_e type; struct PP_CompletionCallback callback; PP_Resource callback_ml; PP_Resource resource; char *host; uint16_t port; struct PP_NetAddress_Private netaddr; struct PP_NetAddress_Private *addr_from; PP_Resource addr_from_resource; char *buffer; int32_t bufsize; int sock; // private fields void *event; void *addr; uint32_t addr_ptr; uint32_t addr_type; uint32_t addr_count; }; void async_network_task_push(struct async_network_task_s *task); struct async_network_task_s * async_network_task_create(void); freshplayerplugin-0.3.9/src/audio_thread.c000066400000000000000000000036611321746453100206650ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "audio_thread.h" #include extern audio_stream_ops audio_alsa; extern audio_stream_ops audio_noaudio; #if HAVE_PULSEAUDIO extern audio_stream_ops audio_pulse; #endif #if HAVE_JACK extern audio_stream_ops audio_jack; #endif audio_stream_ops * audio_select_implementation(void) { #if HAVE_JACK if (audio_jack.available()) return &audio_jack; #endif #if HAVE_PULSEAUDIO if (audio_pulse.available()) return &audio_pulse; #endif if (audio_alsa.available()) return &audio_alsa; return &audio_noaudio; } void audio_capture_device_list_free(audio_device_name *list) { if (!list) return; for (uintptr_t k = 0; list[k].name != NULL; k ++) { free(list[k].name); free(list[k].longname); } free(list); } freshplayerplugin-0.3.9/src/audio_thread.h000066400000000000000000000055751321746453100207000ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include typedef enum { STREAM_PLAYBACK, STREAM_CAPTURE, } audio_stream_direction; typedef struct { char *name; char *longname; } audio_device_name; typedef struct audio_stream_s audio_stream; typedef void (audio_stream_capture_cb_f)(const void *buf, uint32_t sz, double latency, void *user_data); typedef void (audio_stream_playback_cb_f)(void *buf, uint32_t sz, double latency, void *user_data); typedef int (audio_available_f)(void); typedef audio_stream * (audio_create_playback_stream_f)(unsigned int sample_rate, unsigned int sample_frame_count, audio_stream_playback_cb_f *cb, void *cb_user_data); typedef audio_stream * (audio_create_capture_stream_f)(unsigned int sample_rate, unsigned int sample_frame_count, audio_stream_capture_cb_f *cb, void *cb_user_data, const char *device_longname); /// returns NULL-terminated array of device names /// /// caller should free memory by calling audio_capture_device_list_free() typedef audio_device_name * (audio_enumerate_capture_devices_f)(void); typedef void (audio_pause_stream_f)(audio_stream *s, int enabled); typedef void (audio_destroy_stream_f)(audio_stream *s); typedef struct { audio_available_f *available; audio_create_playback_stream_f *create_playback_stream; audio_create_capture_stream_f *create_capture_stream; audio_enumerate_capture_devices_f *enumerate_capture_devices; audio_pause_stream_f *pause; audio_destroy_stream_f *destroy; } audio_stream_ops; audio_stream_ops * audio_select_implementation(void); void audio_capture_device_list_free(audio_device_name *list); freshplayerplugin-0.3.9/src/audio_thread_alsa.c000066400000000000000000000447131321746453100216700ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "audio_thread.h" #include "config.h" #include "eintr_retry.h" #include "ppb_message_loop.h" #include "trace_core.h" #include "trace_helpers.h" #include "utils.h" #include #include #include #include #include #include #include #include #include struct audio_stream_s { audio_stream_direction direction; snd_pcm_t *pcm; struct pollfd *fds; size_t nfds; size_t sample_frame_count; audio_stream_capture_cb_f *capture_cb; audio_stream_playback_cb_f *playback_cb; void *cb_user_data; volatile int paused; }; static GHashTable *active_streams_ht = NULL; static GHashTable *stream_by_fd_ht = NULL; static GList *streams_to_delete = NULL; static volatile int rebuild_fds = 0; static volatile int audio_thread_started = 0; static volatile int terminate_thread = 0; static int notification_pipe[2]; static pthread_t audio_thread_id; static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; static pthread_barrier_t stream_list_update_barrier; static void recover_pcm(snd_pcm_t *pcm) { switch (snd_pcm_state(pcm)) { case SND_PCM_STATE_XRUN: snd_pcm_recover(pcm, -EPIPE, 1); break; case SND_PCM_STATE_SUSPENDED: snd_pcm_recover(pcm, -ESTRPIPE, 1); break; default: snd_pcm_drop(pcm); snd_pcm_prepare(pcm); break; } } static void drain_wakeup_pipe(int fd) { char buf[8]; while (RETRY_ON_EINTR(read(fd, buf, sizeof(buf))) > 0) { // cycle here doing nothing } } static void process_stream_deletions_unlocked(void) { GList *ll = streams_to_delete; while (ll) { struct audio_stream_s *as = ll->data; g_hash_table_remove(active_streams_ht, as); for (uintptr_t k = 0; k < as->nfds; k ++) g_hash_table_remove(stream_by_fd_ht, GINT_TO_POINTER(as->fds[k].fd)); snd_pcm_close(as->pcm); free(as); ll = g_list_next(ll); } g_list_free(streams_to_delete); streams_to_delete = NULL; } static nfds_t do_rebuild_fds(struct pollfd **out_fds) { GHashTableIter iter; gpointer key, val; void *tmp; nfds_t nfds; struct pollfd *fds; pthread_mutex_lock(&lock); process_stream_deletions_unlocked(); fds = *out_fds; nfds = 1; tmp = realloc(fds, sizeof(fds[0])); if (!tmp) { free(fds); fds = NULL; trace_error("%s, memory allocation failed\n", __func__); goto err; } fds = tmp; // wakeup pipe fds[0].fd = notification_pipe[0]; fds[0].events = POLLIN; fds[0].revents = 0; // audio file handles g_hash_table_iter_init(&iter, active_streams_ht); while (g_hash_table_iter_next(&iter, &key, &val)) { audio_stream *as = key; if (!as) { trace_error("%s, NULL key in active_streams_ht\n", __func__); nfds = 0; goto err; } tmp = realloc(fds, (nfds + as->nfds) * sizeof(as->fds[0])); if (!tmp) { free(fds); fds = NULL; trace_error("%s, memory allocation failed\n", __func__); nfds = 0; goto err; } fds = tmp; for (uintptr_t k = 0; k < as->nfds; k ++) fds[nfds + k] = as->fds[k]; nfds += as->nfds; } err: g_atomic_int_set(&rebuild_fds, 0); pthread_mutex_unlock(&lock); *out_fds = fds; return nfds; } static void * audio_thread(void *param) { struct pollfd *fds = NULL; nfds_t nfds = 0; static char buf[16 * 1024]; ppb_message_loop_mark_thread_unsuitable(); nfds = do_rebuild_fds(&fds); pthread_barrier_wait(&stream_list_update_barrier); if (nfds == 0) goto quit; while (1) { if (g_atomic_int_get(&terminate_thread)) goto quit; int res = poll(fds, nfds, 10 * 1000); if (res == -1) { if (errno == EINTR) continue; trace_error("%s, poll, errno=%d\n", __func__, errno); continue; } if (res == 0 || fds == NULL) continue; if (fds[0].revents) drain_wakeup_pipe(fds[0].fd); if (g_atomic_int_get(&rebuild_fds)) { nfds = do_rebuild_fds(&fds); pthread_barrier_wait(&stream_list_update_barrier); if (nfds == 0) goto quit; } for (uintptr_t k = 1; k < nfds; k ++) { unsigned short revents = 0; audio_stream *as = g_hash_table_lookup(stream_by_fd_ht, GINT_TO_POINTER(fds[k].fd)); // check if stream was deleted if (!as) continue; snd_pcm_poll_descriptors_revents(as->pcm, &fds[k], 1, &revents); if (revents & (~(POLLIN | POLLOUT))) { trace_warning("%s, revents have unexpected flags set (%u)\n", __func__, (unsigned int)revents); recover_pcm(as->pcm); } if (revents & (POLLIN | POLLOUT)) { int paused = g_atomic_int_get(&as->paused); snd_pcm_sframes_t frame_count = snd_pcm_avail(as->pcm); if (revents & POLLIN) { // POLLIN const size_t frame_size = 1 * sizeof(int16_t); // mono 16-bit const size_t max_segment_length = MIN(as->sample_frame_count * frame_size, sizeof(buf)); size_t to_process = frame_count * frame_size; while (to_process > 0) { snd_pcm_sframes_t frames_read; const size_t segment_length = MIN(to_process, max_segment_length); frames_read = snd_pcm_readi(as->pcm, buf, segment_length / frame_size); if (frames_read < 0) { trace_warning("%s, snd_pcm_readi error %d\n", __func__, (int)frames_read); recover_pcm(as->pcm); continue; } if (!paused && as->capture_cb) as->capture_cb(buf, frames_read * frame_size, 0, as->cb_user_data); to_process -= frames_read * frame_size; } } else { // POLLOUT const size_t frame_size = 2 * sizeof(int16_t); // stereo 16-bit const size_t max_segment_length = MIN(as->sample_frame_count * frame_size, sizeof(buf)); size_t to_process = frame_count * frame_size; while (to_process > 0) { snd_pcm_sframes_t frames_written; const size_t segment_length = MIN(to_process, max_segment_length); if (paused || !as->playback_cb) memset(buf, 0, segment_length); else as->playback_cb(buf, segment_length, 0, as->cb_user_data); frames_written = snd_pcm_writei(as->pcm, buf, segment_length / frame_size); if (frames_written < 0) { trace_warning("%s, snd_pcm_writei error %d\n", __func__, (int)frames_written); recover_pcm(as->pcm); continue; } to_process -= frames_written * frame_size; } } } } } quit: free(fds); return NULL; } static void __attribute__((constructor)) constructor_audio_thread_alsa(void) { active_streams_ht = g_hash_table_new(g_direct_hash, g_direct_equal); stream_by_fd_ht = g_hash_table_new(g_direct_hash, g_direct_equal); if (pipe(notification_pipe) != 0) { trace_error("%s, pipe creation failed\n", __func__); notification_pipe[0] = -1; notification_pipe[1] = -1; return; } make_nonblock(notification_pipe[0]); make_nonblock(notification_pipe[1]); } static void __attribute__((destructor)) destructor_audio_thread_alsa(void) { if (g_atomic_int_get(&audio_thread_started)) { g_atomic_int_set(&terminate_thread, 1); pthread_join(audio_thread_id, NULL); } g_hash_table_unref(active_streams_ht); g_hash_table_unref(stream_by_fd_ht); close(notification_pipe[0]); close(notification_pipe[1]); } static void wakeup_audio_thread(void) { g_atomic_int_set(&rebuild_fds, 1); RETRY_ON_EINTR(write(notification_pipe[1], "+", 1)); pthread_barrier_wait(&stream_list_update_barrier); } static audio_stream * alsa_create_stream(audio_stream_direction direction, unsigned int sample_rate, unsigned int sample_frame_count, const char *pcm_name) { audio_stream *as; snd_pcm_hw_params_t *hw_params; snd_pcm_sw_params_t *sw_params; int dir; if (!g_atomic_int_get(&audio_thread_started)) { pthread_barrier_init(&stream_list_update_barrier, NULL, 2); pthread_create(&audio_thread_id, NULL, audio_thread, NULL); g_atomic_int_set(&audio_thread_started, 1); pthread_barrier_wait(&stream_list_update_barrier); } as = calloc(1, sizeof(*as)); if (!as) goto err; as->sample_frame_count = sample_frame_count; g_atomic_int_set(&as->paused, 1); #define CHECK_A(funcname, params) \ do { \ int errcode___ = funcname params; \ if (errcode___ < 0) { \ trace_error("%s, " #funcname ", %s\n", __func__, snd_strerror(errcode___)); \ goto err; \ } \ } while (0) if (direction == STREAM_PLAYBACK) CHECK_A(snd_pcm_open, (&as->pcm, pcm_name, SND_PCM_STREAM_PLAYBACK, 0)); else CHECK_A(snd_pcm_open, (&as->pcm, pcm_name, SND_PCM_STREAM_CAPTURE, 0)); CHECK_A(snd_pcm_hw_params_malloc, (&hw_params)); CHECK_A(snd_pcm_hw_params_any, (as->pcm, hw_params)); CHECK_A(snd_pcm_hw_params_set_access, (as->pcm, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)); CHECK_A(snd_pcm_hw_params_set_format, (as->pcm, hw_params, SND_PCM_FORMAT_S16_LE)); dir = 0; unsigned int rate = sample_rate; CHECK_A(snd_pcm_hw_params_set_rate_near, (as->pcm, hw_params, &rate, &dir)); const int channel_count = (direction == STREAM_PLAYBACK) ? 2 : 1; CHECK_A(snd_pcm_hw_params_set_channels, (as->pcm, hw_params, channel_count)); unsigned int period_time = (long long)sample_frame_count * 1000 * 1000 / sample_rate; period_time = CLAMP(period_time, 1000 * (unsigned int)config.audio_buffer_min_ms, 1000 * (unsigned int)config.audio_buffer_max_ms); dir = 1; CHECK_A(snd_pcm_hw_params_set_period_time_near, (as->pcm, hw_params, &period_time, &dir)); unsigned int buffer_time = 4 * period_time; dir = 1; CHECK_A(snd_pcm_hw_params_set_buffer_time_near, (as->pcm, hw_params, &buffer_time, &dir)); dir = 0; CHECK_A(snd_pcm_hw_params_get_buffer_time, (hw_params, &buffer_time, &dir)); CHECK_A(snd_pcm_hw_params, (as->pcm, hw_params)); snd_pcm_hw_params_free(hw_params); CHECK_A(snd_pcm_sw_params_malloc, (&sw_params)); CHECK_A(snd_pcm_sw_params_current, (as->pcm, sw_params)); CHECK_A(snd_pcm_sw_params, (as->pcm, sw_params)); CHECK_A(snd_pcm_prepare, (as->pcm)); snd_pcm_sw_params_free(sw_params); CHECK_A(snd_pcm_prepare, (as->pcm)); if (direction == STREAM_CAPTURE) CHECK_A(snd_pcm_start, (as->pcm)); as->nfds = snd_pcm_poll_descriptors_count(as->pcm); as->fds = calloc(as->nfds, sizeof(struct pollfd)); if (!as->fds) { trace_error("%s, memory allocation failure\n", __func__); goto err; } snd_pcm_poll_descriptors(as->pcm, as->fds, as->nfds); g_hash_table_insert(active_streams_ht, as, GINT_TO_POINTER(1)); for (uintptr_t k = 0; k < as->nfds; k ++) g_hash_table_insert(stream_by_fd_ht, GINT_TO_POINTER(as->fds[k].fd), as); wakeup_audio_thread(); #undef CHECK_A return as; err: free(as); return NULL; } static audio_stream * alsa_create_playback_stream(unsigned int sample_rate, unsigned int sample_frame_count, audio_stream_playback_cb_f *cb, void *cb_user_data) { audio_stream *as = alsa_create_stream(STREAM_PLAYBACK, sample_rate, sample_frame_count, "default"); if (!as) return NULL; as->playback_cb = cb; as->cb_user_data = cb_user_data; return as; } static char * find_pcm_name(const char *device_longname) { char *pcm_name = NULL; int card = -1; int done = 0; if (!device_longname) return strdup("default"); while (!done) { int err = snd_card_next(&card); if (err != 0) break; if (card == -1) break; char *longname = NULL; if (snd_card_get_longname(card, &longname) != 0) goto next_0; if (!longname) goto next_0; if (strcmp(device_longname, longname) != 0) goto next_2; void **hints; if (snd_device_name_hint(card, "pcm", &hints) != 0) goto next_2; for (int k = 0; hints[k] != NULL; k ++) { pcm_name = snd_device_name_get_hint(hints[k], "NAME"); if (strncmp(pcm_name, "default:", strlen("default:")) == 0) { done = 1; goto next_3; } free(pcm_name); pcm_name = NULL; } next_3: snd_device_name_free_hint(hints); next_2: free(longname); next_0: continue; } if (!pcm_name) pcm_name = strdup("default"); return pcm_name; } static audio_stream * alsa_create_capture_stream(unsigned int sample_rate, unsigned int sample_frame_count, audio_stream_capture_cb_f *cb, void *cb_user_data, const char *longname) { char *pcm_name = find_pcm_name(longname); audio_stream *as = alsa_create_stream(STREAM_CAPTURE, sample_rate, sample_frame_count, pcm_name); free(pcm_name); if (!as) return NULL; as->capture_cb = cb; as->cb_user_data = cb_user_data; return as; } static audio_device_name * alsa_enumerate_capture_devices(void) { int rcard; // count cards size_t cnt = 0; rcard = -1; while (1) { int err = snd_card_next(&rcard); if (err != 0) break; if (rcard == -1) break; cnt ++; } if (cnt == 0) return NULL; audio_device_name *list = calloc(sizeof(audio_device_name), cnt + 1); if (!list) return NULL; // fill the list uintptr_t idx = 0; rcard = -1; while (1) { int err = snd_card_next(&rcard); if (err != 0) break; if (rcard == -1) break; char *name; if (snd_card_get_name(rcard, &name) == 0 && name != NULL) { list[idx].name = name; char *longname; if (snd_card_get_longname(rcard, &longname) == 0 && longname != NULL) list[idx].longname = longname; idx ++; if (idx >= cnt) break; } } // terminate list list[idx].name = NULL; list[idx].longname = NULL; return list; } static void alsa_pause_stream(audio_stream *as, int enabled) { g_atomic_int_set(&as->paused, enabled); } static void alsa_destroy_stream(audio_stream *as) { pthread_mutex_lock(&lock); streams_to_delete = g_list_prepend(streams_to_delete, as); pthread_mutex_unlock(&lock); wakeup_audio_thread(); } static int alsa_available(void) { static int probed = 0; static int available = 0; pthread_mutex_lock(&lock); if (probed) { const int status = available; pthread_mutex_unlock(&lock); return status; } pthread_mutex_unlock(&lock); snd_pcm_t *pcm; const int ret = snd_pcm_open(&pcm, "default", SND_PCM_STREAM_PLAYBACK, 0); pthread_mutex_lock(&lock); available = (ret == 0); probed = 1; const int is_available = available; pthread_mutex_unlock(&lock); if (ret == 0) snd_pcm_close(pcm); return is_available; } audio_stream_ops audio_alsa = { .available = alsa_available, .create_playback_stream = alsa_create_playback_stream, .create_capture_stream = alsa_create_capture_stream, .enumerate_capture_devices = alsa_enumerate_capture_devices, .pause = alsa_pause_stream, .destroy = alsa_destroy_stream, }; freshplayerplugin-0.3.9/src/audio_thread_jack.c000066400000000000000000000371241321746453100216560ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "audio_thread.h" #include "config.h" #include "trace_core.h" #include "trace_helpers.h" #include #include #include #include #include #include #include #include #include #define CLIENT_NAME "freshwrapper" #define CMD_RESAMPLE_NEXT_CHUNK ((void *)1) #define CMD_TERMINATE ((void *)2) struct audio_stream_s { audio_stream_playback_cb_f *playback_cb; audio_stream_capture_cb_f *capture_cb; void *cb_user_data; audio_stream_direction direction; GAsyncQueue *async_q; pthread_t resampler_thread; jack_client_t *client; jack_port_t *input_port; jack_port_t *output_port_1; jack_port_t *output_port_2; size_t sample_rate; size_t sample_frame_count; size_t jack_sample_rate; size_t jack_sample_frame_count; void *pepper_buf; ///< buffer for Pepper side size_t pepper_buf_size; void *jack_buf[2]; ///< buffers for JACK side size_t jack_buf_size; volatile int paused; soxr_t resampler; jack_ringbuffer_t *rb_in; ///< ringbuffer for audio capture jack_ringbuffer_t *rb_out[2]; ///< ringbuffer for audio playback }; static int ja_available(void) { return config.audio_use_jack; } static void * ja_playback_resampler_thread_func(void *param) { audio_stream *as = param; while (1) { while (jack_ringbuffer_read_space(as->rb_out[0]) < as->jack_buf_size / 2) { if (g_atomic_int_get(&as->paused)) { memset(as->pepper_buf, 0, as->pepper_buf_size); } else { as->playback_cb(as->pepper_buf, as->pepper_buf_size, 0, as->cb_user_data); } size_t idone = 0, odone = 0; soxr_process(as->resampler, as->pepper_buf, as->sample_frame_count, &idone, as->jack_buf, as->jack_buf_size / sizeof(float), &odone); size_t wr1, wr2; wr1 = jack_ringbuffer_write(as->rb_out[0], as->jack_buf[0], odone * sizeof(float)); wr2 = jack_ringbuffer_write(as->rb_out[1], as->jack_buf[1], odone * sizeof(float)); if (wr1 != odone * sizeof(float) || wr2 != odone * sizeof(float)) trace_error("%s, ringbuffer overrun\n", __func__); } void *ptr = g_async_queue_pop(as->async_q); // termination condition if (ptr == CMD_TERMINATE) break; } return NULL; } static void * ja_capture_resampler_thread_func(void *param) { audio_stream *as = param; while (1) { if (jack_ringbuffer_read_space(as->rb_in) > as->jack_buf_size / 2) { size_t rd = jack_ringbuffer_read(as->rb_in, as->jack_buf[0], as->jack_sample_frame_count * sizeof(float)); if (rd == 0) trace_error("%s, ringbuffer underrun\n", __func__); size_t idone = 0, odone = 0; const size_t pepper_frame_size = 1 * sizeof(int16_t); // mono 16-bit soxr_process(as->resampler, as->jack_buf, rd / sizeof(float), &idone, as->pepper_buf, as->pepper_buf_size / pepper_frame_size, &odone); if (!g_atomic_int_get(&as->paused)) as->capture_cb(as->pepper_buf, odone * pepper_frame_size, 0, as->cb_user_data); } void *ptr = g_async_queue_pop(as->async_q); // termination condition if (ptr == CMD_TERMINATE) break; } return NULL; } static int ja_process_cb(jack_nframes_t nframes, void *param) { audio_stream *as = param; if (as->direction == STREAM_PLAYBACK) { void *out[2] = { jack_port_get_buffer(as->output_port_1, nframes), jack_port_get_buffer(as->output_port_2, nframes), }; size_t wr1 = jack_ringbuffer_read(as->rb_out[0], out[0], nframes * sizeof(float)); size_t wr2 = jack_ringbuffer_read(as->rb_out[1], out[1], nframes * sizeof(float)); if (wr1 != nframes * sizeof(float) || wr2 != nframes * sizeof(float)) trace_error("%s, ringbuffer underrun\n", __func__); } else { // STREAM_CAPTURE void *in = jack_port_get_buffer(as->input_port, nframes); size_t wr1 = jack_ringbuffer_write(as->rb_in, in, nframes * sizeof(float)); if (wr1 != nframes * sizeof(float)) trace_error("%s, ringbuffer overrun\n", __func__); } g_async_queue_push(as->async_q, CMD_RESAMPLE_NEXT_CHUNK); return 0; } static audio_stream * ja_do_create_stream(unsigned int sample_rate, unsigned int sample_frame_count, audio_stream_playback_cb_f *playback_cb, audio_stream_capture_cb_f *capture_cb, void *cb_user_data, audio_stream_direction direction) { jack_options_t options = JackNullOption; jack_status_t status; const char *server_name = config.jack_server_name; if (server_name) options |= JackServerName; if (!config.jack_autostart_server) options |= JackNoStartServer; audio_stream *as = calloc(1, sizeof(*as)); if (!as) { trace_error("%s, memory allocation failure, point 1\n", __func__); goto err_1; } as->playback_cb = playback_cb; as->capture_cb = capture_cb; as->cb_user_data = cb_user_data; as->direction = direction; g_atomic_int_set(&as->paused, 1); as->client = jack_client_open(CLIENT_NAME, options, &status, server_name); if (!as->client) { trace_error("%s, jack_client_open() failed with status=0x%x\n", __func__, status); if (status & JackServerFailed) trace_error("%s, can't connect to JACK server\n", __func__); goto err_2; } as->sample_rate = sample_rate; as->sample_frame_count = sample_frame_count; as->jack_sample_rate = jack_get_sample_rate(as->client); as->jack_sample_frame_count = ceil(1.0 * as->jack_sample_rate / as->sample_rate * as->sample_frame_count); if (direction == STREAM_PLAYBACK) { // allocate buffer for sample_frame_count frames const size_t frame_size = 2 * sizeof(int16_t); // stereo 16-bit as->pepper_buf_size = frame_size * sample_frame_count; as->pepper_buf = malloc(as->pepper_buf_size); // allocate room for twice as long (in seconds) buffer as as->pepper_buf as->jack_buf_size = (2 * as->jack_sample_frame_count) * sizeof(float); as->jack_buf[0] = malloc(as->jack_buf_size); as->jack_buf[1] = malloc(as->jack_buf_size); as->rb_out[0] = jack_ringbuffer_create(as->jack_buf_size); as->rb_out[1] = jack_ringbuffer_create(as->jack_buf_size); if (!as->pepper_buf || !as->jack_buf[0] || !as->jack_buf[1] || !as->rb_out[0] || !as->rb_out[1]) { trace_error("%s, memory allocation failure, point 2\n", __func__); goto err_3; } } else { // STREAM_CAPTURE // allocate buffer for sample_frame_count frames const size_t frame_size = 1 * sizeof(int16_t); // mono 16-bit as->pepper_buf_size = frame_size * sample_frame_count; as->pepper_buf = malloc(as->pepper_buf_size); // allocate room for twice as long (in seconds) buffer as as->pepper_buf as->jack_buf_size = (2 * as->jack_sample_frame_count) * sizeof(float); as->jack_buf[0] = malloc(as->jack_buf_size); as->rb_in = jack_ringbuffer_create(as->jack_buf_size); if (!as->pepper_buf || !as->jack_buf[0] || !as->rb_in) { trace_error("%s, memory allocation failure, point 3\n", __func__); goto err_3; } } soxr_quality_spec_t quality_spec = soxr_quality_spec(SOXR_QQ, 0); if (as->sample_rate == as->jack_sample_rate) { // workaround issue with same input and output rate quality_spec = soxr_quality_spec(SOXR_QQ, 0); } soxr_error_t soxr_err; if (direction == STREAM_PLAYBACK) { soxr_io_spec_t io_spec = soxr_io_spec(SOXR_INT16_I, SOXR_FLOAT32_S); as->resampler = soxr_create(as->sample_rate, as->jack_sample_rate, 2, &soxr_err, &io_spec, &quality_spec, NULL); } else { soxr_io_spec_t io_spec = soxr_io_spec(SOXR_FLOAT32_S, SOXR_INT16_I); as->resampler = soxr_create(as->jack_sample_rate, as->sample_rate, 1, &soxr_err, &io_spec, &quality_spec, NULL); } if (soxr_err != NULL) { trace_error("%s, can't create resampler: %s\n", __func__, soxr_strerror(soxr_err)); goto err_3; } as->async_q = g_async_queue_new(); if (!as->async_q) { trace_error("%s, can't create GAsyncQueue\n", __func__); goto err_4; } jack_set_process_callback(as->client, ja_process_cb, as); if (direction == STREAM_PLAYBACK) { as->output_port_1 = jack_port_register(as->client, "output1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); as->output_port_2 = jack_port_register(as->client, "output2", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); if (!as->output_port_1 || !as->output_port_2) { trace_error("%s, can't register output ports\n", __func__); goto err_5; } } else { as->input_port = jack_port_register(as->client, "input1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); if (!as->input_port) { trace_error("%s, can't register input port\n", __func__); goto err_5; } } if (direction == STREAM_PLAYBACK) { pthread_create(&as->resampler_thread, NULL, ja_playback_resampler_thread_func, as); } else { // STREAM_CAPTURE pthread_create(&as->resampler_thread, NULL, ja_capture_resampler_thread_func, as); } if (jack_activate(as->client) != 0) { trace_error("%s, can't activate client\n", __func__); goto err_6; } if (config.jack_autoconnect_ports) { const char **ports; if (direction == STREAM_PLAYBACK) { ports = jack_get_ports(as->client, NULL, NULL, JackPortIsPhysical | JackPortIsInput); if (!ports) { trace_error("%s, no physical playback ports\n", __func__); goto err_6; } if (ports[0]) { if (jack_connect(as->client, jack_port_name(as->output_port_1), ports[0]) != 0) trace_error("%s, can't connect output port 1\n", __func__); if (ports[1]) { if (jack_connect(as->client, jack_port_name(as->output_port_2), ports[1]) != 0) trace_error("%s, can't connect output port 2\n", __func__); } } } else { // STREAM_CAPTURE ports = jack_get_ports(as->client, NULL, NULL, JackPortIsPhysical | JackPortIsOutput); if (!ports) { trace_error("%s, no physical capture ports\n", __func__); goto err_6; } if (ports[0]) { if (jack_connect(as->client, ports[0], jack_port_name(as->input_port)) != 0) trace_error("%s, can't connect input port 1\n", __func__); if (ports[1]) { if (jack_connect(as->client, ports[1], jack_port_name(as->input_port)) != 0) trace_error("%s, can't connect input port 2\n", __func__); } } } jack_free(ports); } // config.jack_autoconnect_ports return as; err_6: g_async_queue_push(as->async_q, CMD_TERMINATE); pthread_join(as->resampler_thread, NULL); err_5: g_async_queue_unref(as->async_q); err_4: soxr_delete(as->resampler); err_3: if (as->rb_out[0]) jack_ringbuffer_free(as->rb_out[0]); if (as->rb_out[1]) jack_ringbuffer_free(as->rb_out[1]); if (as->rb_in) jack_ringbuffer_free(as->rb_in); free(as->pepper_buf); free(as->jack_buf[0]); free(as->jack_buf[1]); jack_client_close(as->client); err_2: free(as); err_1: return NULL; } static audio_stream * ja_create_playback_stream(unsigned int sample_rate, unsigned int sample_frame_count, audio_stream_playback_cb_f *cb, void *cb_user_data) { return ja_do_create_stream(sample_rate, sample_frame_count, cb, NULL, cb_user_data, STREAM_PLAYBACK); } static audio_stream * ja_create_capture_stream(unsigned int sample_rate, unsigned int sample_frame_count, audio_stream_capture_cb_f *cb, void *cb_user_data, const char *longname) { (void)longname; // have no meaning here. JACK itself selects appropriate sound device return ja_do_create_stream(sample_rate, sample_frame_count, NULL, cb, cb_user_data, STREAM_CAPTURE); } static audio_device_name * ja_enumerate_capture_devices(void) { audio_device_name *list = malloc(sizeof(audio_device_name) * 2); if (!list) return NULL; list[0].name = strdup("JACK capture device"); list[0].longname = strdup(list[0].name); list[1].name = NULL; list[1].longname = NULL; return list; } static void ja_pause_stream(audio_stream *as, int enabled) { g_atomic_int_set(&as->paused, enabled); } static void ja_destroy_stream(audio_stream *as) { jack_client_close(as->client); g_async_queue_push(as->async_q, CMD_TERMINATE); pthread_join(as->resampler_thread, NULL); g_async_queue_unref(as->async_q); soxr_delete(as->resampler); free(as->pepper_buf); free(as->jack_buf[0]); free(as->jack_buf[1]); if (as->rb_out[0]) jack_ringbuffer_free(as->rb_out[0]); if (as->rb_out[1]) jack_ringbuffer_free(as->rb_out[1]); if (as->rb_in) jack_ringbuffer_free(as->rb_in); } audio_stream_ops audio_jack = { .available = ja_available, .create_playback_stream = ja_create_playback_stream, .create_capture_stream = ja_create_capture_stream, .enumerate_capture_devices = ja_enumerate_capture_devices, .pause = ja_pause_stream, .destroy = ja_destroy_stream, }; freshplayerplugin-0.3.9/src/audio_thread_noaudio.c000066400000000000000000000132261321746453100224010ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "audio_thread.h" #include "ppb_message_loop.h" #include #include #include #include #include struct audio_stream_s { size_t sample_frame_count; size_t sample_rate; size_t samples_wanted; audio_stream_playback_cb_f *playback_cb; void *cb_user_data; volatile int paused; volatile int alive; }; static GHashTable *active_streams_ht = NULL; static volatile int audio_thread_started = 0; static volatile int terminate_thread = 0; static pthread_t audio_thread_id; static void * audio_thread(void *param) { static char buf[16 * 1024]; const size_t delay_ms = 20; ppb_message_loop_mark_thread_unsuitable(); while (1) { if (g_atomic_int_get(&terminate_thread)) goto quit; GList *streams = g_hash_table_get_keys(active_streams_ht); GList *ll = streams; while (ll) { struct audio_stream_s *as = ll->data; if (g_atomic_int_get(&as->alive)) { const size_t sample_size = 2 * sizeof(int16_t); // signed 16-bit stereo const size_t buf_size = MIN(as->sample_frame_count * sample_size, sizeof(buf)); as->samples_wanted += as->sample_rate * delay_ms / 1000; while (as->samples_wanted * sample_size > buf_size) { as->playback_cb(buf, buf_size, 0, as->cb_user_data); as->samples_wanted -= buf_size / sample_size; } } else { g_hash_table_remove(active_streams_ht, as); free(as); } ll = g_list_next(ll); } g_list_free(streams); usleep(delay_ms * 1000); } quit: return NULL; } static void __attribute__((constructor)) constructor_audio_thread_noaudio(void) { active_streams_ht = g_hash_table_new(g_direct_hash, g_direct_equal); } static void __attribute__((destructor)) destructor_audio_thread_noaudio(void) { if (g_atomic_int_get(&audio_thread_started)) { g_atomic_int_set(&terminate_thread, 1); pthread_join(audio_thread_id, NULL); } g_hash_table_unref(active_streams_ht); } static audio_stream * noaudio_create_stream(unsigned int sample_rate, unsigned int sample_frame_count) { audio_stream *as; if (!g_atomic_int_get(&audio_thread_started)) { pthread_create(&audio_thread_id, NULL, audio_thread, NULL); g_atomic_int_set(&audio_thread_started, 1); } as = calloc(1, sizeof(*as)); if (!as) goto err; as->sample_rate = sample_rate; as->sample_frame_count = sample_frame_count; g_atomic_int_set(&as->paused, 1); g_atomic_int_set(&as->alive, 1); g_hash_table_insert(active_streams_ht, as, GINT_TO_POINTER(1)); return as; err: free(as); return NULL; } static audio_stream * noaudio_create_playback_stream(unsigned int sample_rate, unsigned int sample_frame_count, audio_stream_playback_cb_f *cb, void *cb_user_data) { audio_stream *as = noaudio_create_stream(sample_rate, sample_frame_count); if (!as) return NULL; as->playback_cb = cb; as->cb_user_data = cb_user_data; return as; } static audio_stream * noaudio_create_capture_stream(unsigned int sample_rate, unsigned int sample_frame_count, audio_stream_capture_cb_f *cb, void *cb_user_data, const char *longname) { return NULL; } static audio_device_name * noaudio_enumerate_capture_devices(void) { // empty list, with ending NULL return calloc(sizeof(audio_device_name), 1); } static void noaudio_pause_stream(audio_stream *as, int enabled) { g_atomic_int_set(&as->paused, enabled); } static void noaudio_destroy_stream(audio_stream *as) { // mark as non-alive. Worker thread will free memory g_atomic_int_set(&as->alive, 0); } static int noaudio_available(void) { // since noaudio is an artificial backend, it's always available return 1; } audio_stream_ops audio_noaudio = { .available = noaudio_available, .create_playback_stream = noaudio_create_playback_stream, .create_capture_stream = noaudio_create_capture_stream, .enumerate_capture_devices = noaudio_enumerate_capture_devices, .pause = noaudio_pause_stream, .destroy = noaudio_destroy_stream, }; freshplayerplugin-0.3.9/src/audio_thread_pulseaudio.c000066400000000000000000000276231321746453100231230ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "audio_thread.h" #include "trace_core.h" #include "trace_helpers.h" #include #include #include #include #include #include #include #define CLIENT_NAME "freshwrapper" struct audio_stream_s { struct pa_sample_spec sample_spec; audio_stream_direction direction; size_t sample_frame_count; pa_stream *stream; audio_stream_playback_cb_f *playback_cb; audio_stream_capture_cb_f *capture_cb; void *cb_user_data; volatile int paused; }; static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; static int probed = 0; static int available = 0; static struct pa_threaded_mainloop *mainloop; static struct pa_context *context; static void pulse_context_state_cb(pa_context *c, void *user_data) { switch (pa_context_get_state(c)) { case PA_CONTEXT_READY: case PA_CONTEXT_TERMINATED: case PA_CONTEXT_FAILED: pa_threaded_mainloop_signal(mainloop, 0); break; default: break; } } static void __attribute__((destructor)) destructor_audio_thread_pulseaudio(void) { pthread_mutex_lock(&lock); if (probed && available) { pa_threaded_mainloop_stop(mainloop); pa_context_disconnect(context); pa_context_unref(context); context = NULL; pa_threaded_mainloop_free(mainloop); mainloop = NULL; probed = available = 0; } pthread_mutex_unlock(&lock); } static int pulse_available(void) { int ret; pthread_mutex_lock(&lock); if (probed) { ret = available; pthread_mutex_unlock(&lock); return ret; } probed = 1; available = 0; mainloop = pa_threaded_mainloop_new(); if (!mainloop) { trace_error("%s, can't create mainloop object\n", __func__); goto err_1; } context = pa_context_new(pa_threaded_mainloop_get_api(mainloop), CLIENT_NAME); if (!context) { trace_error("%s, can't create context\n", __func__); goto err_2; } pa_context_set_state_callback(context, pulse_context_state_cb, NULL); if (pa_context_connect(context, NULL, PA_CONTEXT_NOFLAGS, NULL) < 0) { trace_info_f("%s, no PulseAudio server available\n", __func__); goto err_3; } pa_threaded_mainloop_lock(mainloop); if (pa_threaded_mainloop_start(mainloop) < 0) { trace_error("%s, can't start mainloop\n", __func__); goto err_4; } pa_threaded_mainloop_wait(mainloop); if (pa_context_get_state(context) != PA_CONTEXT_READY) { trace_error("%s, context not ready\n", __func__); goto err_4; } pa_threaded_mainloop_unlock(mainloop); available = 1; pthread_mutex_unlock(&lock); return 1; err_4: pa_threaded_mainloop_unlock(mainloop); err_3: pa_context_unref(context); err_2: pa_threaded_mainloop_free(mainloop); err_1: pthread_mutex_unlock(&lock); return 0; } static void pulse_stream_state_cb(pa_stream *s, void *user_data) { switch (pa_stream_get_state(s)) { case PA_STREAM_READY: case PA_STREAM_FAILED: case PA_STREAM_TERMINATED: pa_threaded_mainloop_signal(mainloop, 0); break; default: break; } } static void pulse_stream_write_cb(pa_stream *s, size_t length, void *user_data) { audio_stream *as = user_data; char *buf; pa_stream_begin_write(as->stream, (void **)&buf, &length); if (g_atomic_int_get(&as->paused) || !as->playback_cb) { memset(buf, 0, length); } else { const size_t max_segment_length = as->sample_frame_count * pa_frame_size(&as->sample_spec); size_t to_process = length; size_t ofs = 0; while (to_process > 0) { const size_t segment_length = MIN(to_process, max_segment_length); as->playback_cb(buf + ofs, segment_length, 0, as->cb_user_data); to_process -= segment_length; ofs += segment_length; } } pa_stream_write(as->stream, buf, length, NULL, 0, PA_SEEK_RELATIVE); } static void pulse_stream_read_cb(pa_stream *s, size_t length, void *user_data) { audio_stream *as = user_data; const char *data; if (pa_stream_peek(s, (const void **)&data, &length) < 0) { trace_error("%s, pa_stream_peek failed\n", __func__); return; } if (!g_atomic_int_get(&as->paused)) { const size_t max_segment_length = as->sample_frame_count * pa_frame_size(&as->sample_spec); size_t to_process = length; size_t ofs = 0; while (to_process > 0) { const size_t segment_length = MIN(to_process, max_segment_length); as->capture_cb(data + ofs, segment_length, 0, as->cb_user_data); to_process -= segment_length; ofs += segment_length; } } pa_stream_drop(s); } static void pulse_stream_latency_update_cb(pa_stream *s, void *user_data) { pa_threaded_mainloop_signal(mainloop, 0); } static audio_stream * pulse_do_create_stream(unsigned int sample_rate, unsigned int sample_frame_count, audio_stream_playback_cb_f *playback_cb, audio_stream_capture_cb_f *capture_cb, void *cb_user_data, audio_stream_direction direction) { // ensure main loop is running if (!pulse_available()) { trace_error("%s, no PulseAudio server available\n", __func__); return NULL; } audio_stream *as = calloc(1, sizeof(*as)); if (!as) return NULL; as->playback_cb = playback_cb; as->capture_cb = capture_cb; as->cb_user_data = cb_user_data; // capture streams are monophonic as->sample_spec.channels = (direction == STREAM_PLAYBACK) ? 2 : 1; as->sample_spec.rate = sample_rate; as->sample_spec.format = PA_SAMPLE_S16LE; as->direction = direction; as->sample_frame_count = sample_frame_count; g_atomic_int_set(&as->paused, 1); pa_threaded_mainloop_lock(mainloop); const char *stream_name = (direction == STREAM_PLAYBACK) ? "playback" : "capture"; as->stream = pa_stream_new(context, stream_name, &as->sample_spec, NULL); if (!as->stream) { if (direction == STREAM_PLAYBACK) trace_error("%s, can't create playback stream\n", __func__); else trace_error("%s, can't create capture stream\n", __func__); goto err_1; } pa_stream_set_state_callback(as->stream, pulse_stream_state_cb, as); pa_stream_set_read_callback(as->stream, pulse_stream_read_cb, as); pa_stream_set_write_callback(as->stream, pulse_stream_write_cb, as); pa_stream_set_latency_update_callback(as->stream, pulse_stream_latency_update_cb, as); const size_t frame_size = pa_frame_size(&as->sample_spec); pa_buffer_attr buf_attr = { .maxlength = (uint32_t)-1, .tlength = sample_frame_count * frame_size * 2, .prebuf = (uint32_t)-1, .minreq = sample_frame_count * frame_size / 2, .fragsize = sample_frame_count * frame_size, }; if (direction == STREAM_PLAYBACK) { if (pa_stream_connect_playback(as->stream, NULL, &buf_attr, 0, NULL, NULL) < 0) { trace_error("%s, can't connect playback stream\n", __func__); goto err_2; } } else { int flags = PA_STREAM_ADJUST_LATENCY; if (pa_stream_connect_record(as->stream, NULL, &buf_attr, flags) < 0) { trace_error("%s, can't connect capture stream\n", __func__); goto err_2; } } while (1) { pa_stream_state_t state = pa_stream_get_state(as->stream); if (state == PA_STREAM_READY) break; if (!PA_STREAM_IS_GOOD(state)) { trace_error("%s, stream is not ready\n", __func__); goto err_2; } pa_threaded_mainloop_wait(mainloop); } pa_threaded_mainloop_unlock(mainloop); return as; err_2: pa_stream_unref(as->stream); err_1: pa_threaded_mainloop_unlock(mainloop); free(as); return NULL; } static audio_stream * pulse_create_playback_stream(unsigned int sample_rate, unsigned int sample_frame_count, audio_stream_playback_cb_f *cb, void *cb_user_data) { return pulse_do_create_stream(sample_rate, sample_frame_count, cb, NULL, cb_user_data, STREAM_PLAYBACK); } static audio_stream * pulse_create_capture_stream(unsigned int sample_rate, unsigned int sample_frame_count, audio_stream_capture_cb_f *cb, void *cb_user_data, const char *longname) { (void)longname; // have no meaning here. PulseAudio itself selects appropriate sound device return pulse_do_create_stream(sample_rate, sample_frame_count, NULL, cb, cb_user_data, STREAM_CAPTURE); } static audio_device_name * pulse_enumerate_capture_devices(void) { audio_device_name *list = malloc(sizeof(audio_device_name) * 2); if (!list) return NULL; list[0].name = strdup("PulseAudio capture device"); list[0].longname = strdup(list[0].name); list[1].name = NULL; list[1].longname = NULL; return list; } static void pulse_pause_stream(audio_stream *as, int enabled) { g_atomic_int_set(&as->paused, enabled); } static void pulse_stream_success_cb(pa_stream *s, int success, void *user_data) { pa_threaded_mainloop_signal(mainloop, 0); } static void pulse_wait_for_completion(pa_operation *op, pa_threaded_mainloop *ml) { if (!op) { trace_error("%s, operation is NULL\n", __func__); return; } while (pa_operation_get_state(op) == PA_OPERATION_RUNNING) pa_threaded_mainloop_wait(ml); pa_operation_unref(op); } static void pulse_destroy_stream(audio_stream *as) { pa_threaded_mainloop_lock(mainloop); pa_operation *op = pa_stream_cork(as->stream, 1, pulse_stream_success_cb, mainloop); pulse_wait_for_completion(op, mainloop); pa_stream_disconnect(as->stream); pa_stream_set_state_callback(as->stream, NULL, NULL); pa_stream_set_write_callback(as->stream, NULL, NULL); pa_stream_set_latency_update_callback(as->stream, NULL, NULL); pa_stream_unref(as->stream); pa_threaded_mainloop_unlock(mainloop); free(as); } audio_stream_ops audio_pulse = { .available = pulse_available, .create_playback_stream = pulse_create_playback_stream, .create_capture_stream = pulse_create_capture_stream, .enumerate_capture_devices = pulse_enumerate_capture_devices, .pause = pulse_pause_stream, .destroy = pulse_destroy_stream, }; freshplayerplugin-0.3.9/src/compat.c000066400000000000000000000040551321746453100175160ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "compat.h" #ifdef VER #error macro name collision #endif #define VER(major, minor) ((major) << 16 | (minor) << 8) #if (VER(GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION) < VER(2, 32)) gpointer g_async_queue_timeout_pop(GAsyncQueue *queue, guint64 timeout) { GTimeVal end_time; g_get_current_time(&end_time); g_time_val_add(&end_time, timeout); return g_async_queue_timed_pop(queue, &end_time); } void g_array_set_clear_func(GArray *array, GDestroyNotify clear_func) { // Only for compatibility. // TODO: memory leaks? } #endif #if (VER(GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION) < VER(2, 28)) static void call_destroy_notify(gpointer data, gpointer user_data) { GDestroyNotify func = (GDestroyNotify)user_data; func(data); } void g_list_free_full(GList *list, GDestroyNotify free_func) { g_list_foreach(list, call_destroy_notify, free_func); g_list_free(list); } #endif freshplayerplugin-0.3.9/src/compat.h000066400000000000000000000034141321746453100175210ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #ifdef VER #error macro name collision #endif #define VER(major, minor) ((major) << 16 | (minor) << 8) #if (VER(GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION) >= VER(2, 26)) #define HAVE_GLIB_DBUS 1 #else #define HAVE_GLIB_DBUS 0 #endif #if (VER(GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION) < VER(2, 32)) gpointer g_async_queue_timeout_pop(GAsyncQueue *queue, guint64 timeout); void g_array_set_clear_func(GArray *array, GDestroyNotify clear_func); #endif #if (VER(GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION) < VER(2, 28)) void g_list_free_full(GList *list, GDestroyNotify free_func); #endif #undef VER freshplayerplugin-0.3.9/src/compat_glx_defines.h000066400000000000000000000065511321746453100220750ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 // https://www.opengl.org/registry/specs/ARB/glx_create_context.txt #define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 #define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 #define GLX_CONTEXT_FLAGS_ARB 0x2094 #define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 // https://www.opengl.org/registry/specs/EXT/glx_create_context_es2_profile.txt #define GLX_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 #define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 // https://www.opengl.org/registry/specs/EXT/texture_from_pixmap.txt #define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 #define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 #define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 #define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 #define GLX_Y_INVERTED_EXT 0x20D4 #define GLX_TEXTURE_FORMAT_EXT 0x20D5 #define GLX_TEXTURE_TARGET_EXT 0x20D6 #define GLX_MIPMAP_TEXTURE_EXT 0x20D7 #define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 #define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 #define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA #define GLX_TEXTURE_1D_BIT_EXT 0x00000001 #define GLX_TEXTURE_2D_BIT_EXT 0x00000002 #define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 #define GLX_TEXTURE_1D_EXT 0x20DB #define GLX_TEXTURE_2D_EXT 0x20DC #define GLX_TEXTURE_RECTANGLE_EXT 0x20DD #define GLX_FRONT_LEFT_EXT 0x20DE #define GLX_FRONT_RIGHT_EXT 0x20DF #define GLX_BACK_LEFT_EXT 0x20E0 #define GLX_BACK_RIGHT_EXT 0x20E1 #define GLX_FRONT_EXT GLX_FRONT_LEFT_EXT #define GLX_BACK_EXT GLX_BACK_LEFT_EXT #define GLX_AUX0_EXT 0x20E2 #define GLX_AUX1_EXT 0x20E3 #define GLX_AUX2_EXT 0x20E4 #define GLX_AUX3_EXT 0x20E5 #define GLX_AUX4_EXT 0x20E6 #define GLX_AUX5_EXT 0x20E7 #define GLX_AUX6_EXT 0x20E8 #define GLX_AUX7_EXT 0x20E9 #define GLX_AUX8_EXT 0x20EA #define GLX_AUX9_EXT 0x20EB freshplayerplugin-0.3.9/src/config.c000066400000000000000000000214621321746453100175010ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "config.h" #include "config_parser/config_parser.h" #include "config_priv.h" #include "trace_core.h" #include #include #include #include #include static struct fpp_config_s default_config = { .audio_buffer_min_ms = 20, .audio_buffer_max_ms = 500, .audio_use_jack = 0, .jack_autoconnect_ports = 1, .jack_server_name = NULL, .jack_autostart_server = 1, .pepperflash_path = NULL, .flash_command_line = "", .enable_3d = 1, .enable_hwdec = 0, .quiet = 0, .fullscreen_width = 0, .fullscreen_height = 0, .fullscreen_horz_maximize_atom = 1, .fullscreen_vert_maximize_atom = 1, .randomize_dns_case = 0, .device_scale = 1.0, .enable_windowed_mode = 1, .enable_xembed = 1, .enable_vaapi = 1, .enable_vdpau = 1, .tie_fullscreen_window_to_browser = 1, .vsync_afterwait_us = 0, .fs_delay_ms = 300, .enable_vsync = 1, .double_click_delay_ms = 400, .show_version_info = 0, .probe_video_capture_devices = 1, .enable_xrender = 1, .quirks = { .connect_first_loader_to_unrequested_stream = 0, .dump_resource_histogram = 0, .dump_variables = 0, .plasma5_screensaver = 0, .plugin_missing = 0, .incompatible_npapi_version = 0, .x_synchronize = 0, .avoid_stdout = 0, }, }; static cfg_opt_t opts[] = { CFG_SIMPLE_INT("audio_buffer_min_ms", &config.audio_buffer_min_ms), CFG_SIMPLE_INT("audio_buffer_max_ms", &config.audio_buffer_max_ms), CFG_SIMPLE_INT("audio_use_jack", &config.audio_use_jack), CFG_SIMPLE_INT("jack_autoconnect_ports", &config.jack_autoconnect_ports), CFG_SIMPLE_STR("jack_server_name", &config.jack_server_name), CFG_SIMPLE_INT("jack_autostart_server", &config.jack_autostart_server), CFG_SIMPLE_STR("pepperflash_path", &config.pepperflash_path), CFG_SIMPLE_STR("flash_command_line", &config.flash_command_line), CFG_SIMPLE_INT("enable_3d", &config.enable_3d), CFG_SIMPLE_INT("enable_hwdec", &config.enable_hwdec), CFG_SIMPLE_INT("quiet", &config.quiet), CFG_SIMPLE_INT("fullscreen_width", &config.fullscreen_width), CFG_SIMPLE_INT("fullscreen_height", &config.fullscreen_height), CFG_SIMPLE_INT("fullscreen_horz_maximize_atom", &config.fullscreen_horz_maximize_atom), CFG_SIMPLE_INT("fullscreen_vert_maximize_atom", &config.fullscreen_vert_maximize_atom), CFG_SIMPLE_INT("randomize_dns_case", &config.randomize_dns_case), CFG_SIMPLE_FLOAT("device_scale", &config.device_scale), CFG_SIMPLE_INT("enable_windowed_mode", &config.enable_windowed_mode), CFG_SIMPLE_INT("enable_xembed", &config.enable_xembed), CFG_SIMPLE_INT("enable_vaapi", &config.enable_vaapi), CFG_SIMPLE_INT("enable_vdpau", &config.enable_vdpau), CFG_SIMPLE_INT("vsync_afterwait_us", &config.vsync_afterwait_us), CFG_SIMPLE_INT("fs_delay_ms", &config.fs_delay_ms), CFG_SIMPLE_INT("enable_vsync", &config.enable_vsync), CFG_SIMPLE_INT("tie_fullscreen_window_to_browser", &config.tie_fullscreen_window_to_browser), CFG_SIMPLE_INT("quirk_plasma5_screensaver", &config.quirks.plasma5_screensaver), CFG_SIMPLE_INT("double_click_delay_ms", &config.double_click_delay_ms), CFG_SIMPLE_INT("show_version_info", &config.show_version_info), CFG_SIMPLE_INT("probe_video_capture_devices", &config.probe_video_capture_devices), CFG_SIMPLE_INT("enable_xrender", &config.enable_xrender), CFG_END() }; struct fpp_config_s config = {}; static const char *salt_file_name = "salt.dat"; static const char *config_file_name = "freshwrapper.conf"; static const char *config_dir_name = "freshwrapper-data"; static int initialized = 0; static char *pepper_data_dir; static char *pepper_salt_file_name; static void initialize_quirks(void) { fpp_config_detect_plugin_specific_quirks(); // Webkit2gtk uses stdout to pass plugin name from plugin container to web renderer process. // So stdout should be avoided if possible. FILE *fp = fopen("/proc/self/cmdline", "r"); if (fp) { char buf[2048]; size_t read_bytes = fread(buf, 1, sizeof(buf) - 1, fp); buf[MIN(read_bytes, sizeof(buf) - 1)] = 0; if (read_bytes > 0) if (strstr(buf, "WebKitPluginProcess")) config.quirks.avoid_stdout = 1; fclose(fp); } } static char * get_local_config_path(const char *file_name) { char *res = NULL; const char *xdg_config_home = getenv("XDG_CONFIG_HOME"); if (xdg_config_home) { res = g_strdup_printf("%s/%s", xdg_config_home, file_name); } else { const char *home = getenv("HOME"); res = g_strdup_printf("%s/.config/%s", home ? home : "", file_name); } return res; } static char * get_global_config_path(const char *file_name) { return g_strdup_printf("/etc/%s", file_name); } static void error_report_func(const char *s) { trace_error("config: %s\n", s); } void fpp_config_initialize(void) { if (initialized) return; cfg_t *cfg; char *local_config = get_local_config_path(config_file_name); char *global_config = get_global_config_path(config_file_name); config = default_config; #define DUP_CFG_STRING(field) do { if (field) field = strdup(field); } while (0) // all non-NULL strings values need to be duplicated, since config parser free()'s // their previous versions DUP_CFG_STRING(config.jack_server_name); DUP_CFG_STRING(config.pepperflash_path); DUP_CFG_STRING(config.flash_command_line); // Setting locale to "C" changes decimal mark to point for floating point values setlocale(LC_ALL, "C"); cfg = cfg_init(opts, 0); cfg_set_error_func(cfg, error_report_func); if (cfg_parse(cfg, local_config) != CFG_SUCCESS) { trace_info_f("can't open configuration file %s, trying %s\n", local_config, global_config); if (cfg_parse(cfg, global_config) != CFG_SUCCESS) { trace_info_f("can't open configuration file %s, using default values\n", global_config); config = default_config; } } cfg_free(cfg); // restore locale setlocale(LC_ALL, ""); g_free(local_config); g_free(global_config); initialize_quirks(); // calculate plugin data directory local_config = get_local_config_path(config_dir_name); pepper_data_dir = g_strdup_printf("%s/%s", local_config, fpp_config_get_plugin_name()); pepper_salt_file_name = g_strdup_printf("%s/%s", local_config, salt_file_name); g_free(local_config); fpp_config_find_backend_plugin(); initialized = 1; } void fpp_config_destroy(void) { #define FREE_IF_CHANGED(field) \ do { \ if (config.field != default_config.field) \ free(config.field); \ } while (0) if (!initialized) return; FREE_IF_CHANGED(pepperflash_path); FREE_IF_CHANGED(flash_command_line); FREE_IF_CHANGED(jack_server_name); g_free(pepper_data_dir); g_free(pepper_salt_file_name); initialized = 0; } const char * fpp_config_get_pepper_data_dir(void) { return pepper_data_dir; } const char * fpp_config_get_pepper_salt_file_name(void) { return pepper_salt_file_name; } freshplayerplugin-0.3.9/src/config.h000066400000000000000000000051311321746453100175010ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 struct fpp_config_s { int audio_buffer_min_ms; int audio_buffer_max_ms; int audio_use_jack; int jack_autoconnect_ports; char *jack_server_name; int jack_autostart_server; char *pepperflash_path; char *flash_command_line; int enable_3d; int enable_hwdec; int quiet; int fullscreen_width; int fullscreen_height; int fullscreen_horz_maximize_atom; int fullscreen_vert_maximize_atom; int randomize_dns_case; double device_scale; int enable_windowed_mode; int enable_xembed; int enable_vaapi; int enable_vdpau; int tie_fullscreen_window_to_browser; int vsync_afterwait_us; int fs_delay_ms; int enable_vsync; int double_click_delay_ms; int show_version_info; int probe_video_capture_devices; int enable_xrender; struct { int connect_first_loader_to_unrequested_stream; int dump_resource_histogram; int dump_variables; int plasma5_screensaver; int plugin_missing; int incompatible_npapi_version; int x_synchronize; int avoid_stdout; } quirks; }; extern struct fpp_config_s config; void fpp_config_initialize(void); void fpp_config_destroy(void); const char * fpp_config_get_pepper_data_dir(void); const char * fpp_config_get_pepper_salt_file_name(void); freshplayerplugin-0.3.9/src/config_parser/000077500000000000000000000000001321746453100207045ustar00rootroot00000000000000freshplayerplugin-0.3.9/src/config_parser/CMakeLists.txt000066400000000000000000000010531321746453100234430ustar00rootroot00000000000000set(CONFIG_PARSER_FSM_C "${CMAKE_CURRENT_BINARY_DIR}/config_parser_fsm.c") include_directories("${CMAKE_CURRENT_BINARY_DIR}") add_custom_command( OUTPUT "${CONFIG_PARSER_FSM_C}" DEPENDS config_parser_fsm.rl.c COMMAND "${RAGEL}" ARGS -G2 "${CMAKE_CURRENT_SOURCE_DIR}/config_parser_fsm.rl.c" -o "${CONFIG_PARSER_FSM_C}" VERBATIM ) add_custom_target(generate-config-parser-fsm DEPENDS "${CONFIG_PARSER_FSM_C}") add_library(config-parser-obj OBJECT config_parser.c ) add_dependencies(config-parser-obj generate-config-parser-fsm) freshplayerplugin-0.3.9/src/config_parser/config_parser.c000066400000000000000000000101321321746453100236660ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "config_parser.h" #include #include #include #include struct cfg_s { GHashTable *entries_ht; cfg_report_error_f *error_func; }; struct entry { int type; void *ptr; }; cfg_t * cfg_init(cfg_opt_t *opts, unsigned int flags) { cfg_t *cfg = calloc(sizeof(*cfg), 1); if (!cfg) goto point_1; cfg->entries_ht = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); if (!cfg->entries_ht) goto point_2; cfg_opt_t *cur = opts; while (cur->name) { cfg_opt_t *e = g_malloc0(sizeof(*e)); if (!e) goto point_3; e->type = cur->type; e->ptr = cur->ptr; g_hash_table_insert(cfg->entries_ht, g_strdup(cur->name), e); cur++; } return cfg; point_3: g_hash_table_destroy(cfg->entries_ht); point_2: free(cfg); point_1: return NULL; } int cfg_parse(cfg_t *cfg, const char *filename) { GError *err = NULL; gchar *s; if (g_file_get_contents(filename, &s, NULL, &err) == FALSE) return CFG_FAILURE; cfg_parse_string(cfg, s); g_free(s); return CFG_SUCCESS; } static void handle_param(cfg_t *cfg, const char *ns, const char *ne, const char *vs, const char *ve) { char *name = g_strndup(ns, ne - ns); char *value = g_strndup(vs, ve - vs); char **str_ptr; int *int_ptr; double *double_ptr; cfg_opt_t *e = g_hash_table_lookup(cfg->entries_ht, name); if (!e) { if (cfg->error_func) { gchar *s = g_strdup_printf("unknown parameter: %s = %s", name, value); cfg->error_func(s); g_free(s); } goto done; } switch (e->type) { case CFG_TYPE_INT: int_ptr = e->ptr; *int_ptr = atoi(value); break; case CFG_TYPE_FLOAT: double_ptr = e->ptr; *double_ptr = atof(value); break; case CFG_TYPE_STRING: str_ptr = e->ptr; free(*str_ptr); *str_ptr = g_strdup(value); break; default: if (cfg->error_func) { gchar *s = g_strdup_printf("parameter of unknown type %d: %s = %s", e->type, name, value); cfg->error_func(s); g_free(s); } break; } done: g_free(name); g_free(value); } void cfg_parse_string(cfg_t *cfg, const char *s) { int cs; const char *p = s; const char *pe = p + strlen(s); const char *eof = pe; struct { const char *name_start; const char *name_end; const char *val_start; const char *val_end; } param; #include (void)config_parser_en_main; (void)config_parser_error; (void)config_parser_first_final; } void cfg_free(cfg_t *cfg) { g_hash_table_destroy(cfg->entries_ht); free(cfg); } void cfg_set_error_func(cfg_t *cfg, cfg_report_error_f func) { cfg->error_func = func; } freshplayerplugin-0.3.9/src/config_parser/config_parser.h000066400000000000000000000041341321746453100237000ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 enum { CFG_TYPE_UNKNOWN, CFG_TYPE_INT, CFG_TYPE_STRING, CFG_TYPE_FLOAT, }; enum { CFG_SUCCESS, CFG_FAILURE, }; #define CFG_SIMPLE_INT(a_name, a_ptr) { .name = a_name, .ptr = a_ptr, .type = CFG_TYPE_INT} #define CFG_SIMPLE_STR(a_name, a_ptr) { .name = a_name, .ptr = a_ptr, .type = CFG_TYPE_STRING} #define CFG_SIMPLE_FLOAT(a_name, a_ptr) { .name = a_name, .ptr = a_ptr, .type = CFG_TYPE_FLOAT} #define CFG_END() { .name = NULL, .ptr = NULL, .type = CFG_TYPE_UNKNOWN} typedef struct { const char *name; void *ptr; int type; } cfg_opt_t; typedef struct cfg_s cfg_t; typedef void (cfg_report_error_f)(const char *error_string); cfg_t * cfg_init(cfg_opt_t *opts, unsigned int flags); int cfg_parse(cfg_t *cfg, const char *filename); void cfg_parse_string(cfg_t *cfg, const char *s); void cfg_free(cfg_t *cfg); void cfg_set_error_func(cfg_t *cfg, cfg_report_error_f func); freshplayerplugin-0.3.9/src/config_parser/config_parser_fsm.rl.c000066400000000000000000000042731321746453100251600ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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. */ %%{ machine config_parser; action param_name_begin { param.name_start = p; } action param_name_end { param.name_end = p; } action param_val_begin { param.val_start = p; } action param_val_end { param.val_end = p; handle_param(cfg, param.name_start, param.name_end, param.val_start, param.val_end); } param_name = ((alpha | '_') (alnum | '_')*) >param_name_begin %param_name_end; param_val = ((any - '\n' - '\r' - "'" - '"')+) >param_val_begin %param_val_end; param_val_qt = "'" ((any - "'")* >param_val_begin %param_val_end) "'"; param_val_dblqt = '"' ((any - '"')* >param_val_begin %param_val_end) '"'; empty_line = space*; comment_line = space* '#' ( any - ';' - '\n' - '\r' )*; name_value_line = space* param_name ( space* '=' space* (param_val_qt | param_val_dblqt | param_val) space* )?; line = ( name_value_line | empty_line | comment_line ); main := (line ';'? [\r\n]+)* (line ';'?)?; }%% %%{ write data; write init; write exec; }%% freshplayerplugin-0.3.9/src/config_pepperflash.c000066400000000000000000000152241321746453100220710ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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. */ #define _XOPEN_SOURCE 500 #include "config.h" #include "trace_core.h" #include #include #include #include #include #include #include #include #include struct flapper_version { unsigned int v[4]; }; static char *flapper_path = NULL; static struct flapper_version flapper_version; static char *flapper_descr = NULL; static char *flapper_str_version = NULL; static const char *pepperflash_path_list[] = { // Chrome "/opt/google/chrome/PepperFlash/libpepflashplayer.so", // Adobe package "/usr/lib/flash-plugin/libpepflashplayer.so", "/usr/lib64/flash-plugin/libpepflashplayer.so", // adobe-flashplugin (Ubuntu) "/usr/lib/adobe-flashplugin/libpepflashplayer.so", // pepperflashplugin-nonfree (Debian) "/usr/lib/pepperflashplugin-nonfree/libpepflashplayer.so", // chromium-pepperflash-plugin (Slackware) "/usr/lib/PepperFlash/libpepflashplayer.so", "/usr/lib64/PepperFlash/libpepflashplayer.so", // chrome-binary-plugins (Gentoo/Sabayon) "/usr/lib/chromium-browser/PepperFlash/libpepflashplayer.so", "/usr/lib64/chromium-browser/PepperFlash/libpepflashplayer.so", // chromium-pepper-flash (Old Build) (CentOS/Read Hat/Fedora) "/usr/lib/chromium/PepperFlash/libpepflashplayer.so", "/usr/lib64/chromium/PepperFlash/libpepflashplayer.so", // chromium-pepper-flash (New Build) (CentOS/Read Hat/Fedora) "/opt/chromium/PepperFlash/libpepflashplayer.so", // pepflashplugin-installer (Ubuntu) "/usr/lib/pepflashplugin-installer/libpepflashplayer.so", // Chrome component update "~/.config/google-chrome/PepperFlash/*/libpepflashplayer.so", NULL, }; __attribute__((destructor)) static void destructor_fpp_config_pepper_flash(void) { free(flapper_path); g_free(flapper_descr); g_free(flapper_str_version); } static int file_exists_and_is_regular_and_readable(const char *fname) { struct stat sb; int ret = lstat(fname, &sb); // should exist if (ret != 0) return 0; // should be a regular file if (!S_ISREG(sb.st_mode)) return 0; // should be readable if (!(sb.st_mode & 0444)) return 0; return 1; } static struct flapper_version get_flapper_version(const char *fname) { struct flapper_version v = {}; // Try manifest.json file. char *manifest_dir = strdup(fname); gchar *manifest_path = g_strdup_printf("%s/manifest.json", dirname(manifest_dir)); free(manifest_dir); JSON_Value *root_val = json_parse_file(manifest_path); g_free(manifest_path); if (!root_val) { // There are either no such file, or it's not in JSON format. goto done; } JSON_Object *root_obj = json_value_get_object(root_val); const char *version = json_object_get_string(root_obj, "version"); if (version) { (void)sscanf(version, "%9u.%9u.%9u.%9u", &v.v[0], &v.v[1], &v.v[2], &v.v[3]); } json_value_free(root_val); done: return v; } static int compare_flapper_version(const struct flapper_version *a, const struct flapper_version *b) { for (int k = 0; k < 4; k++) { if (a->v[k] < b->v[k]) return -1; if (a->v[k] > b->v[k]) return 1; } return 0; } static uintptr_t probe_flapper(const char *fname) { if (!file_exists_and_is_regular_and_readable(fname)) return 1; struct flapper_version v = get_flapper_version(fname); trace_info_f("found %s, version %u.%u.%u.%u\n", fname, v.v[0], v.v[1], v.v[2], v.v[3]); if (!flapper_path || compare_flapper_version(&v, &flapper_version) > 0) { trace_info_f("%s has newer version\n", fname); free(flapper_path); flapper_path = strdup(fname); flapper_version = v; return 0; } return 0; } void fpp_config_find_backend_plugin(void) { if (config.pepperflash_path) { // First, search in user supplied paths. gchar **paths = g_strsplit(config.pepperflash_path, ":", -1); for (gchar **it = paths; *it != NULL; it++) { probe_flapper(*it); } g_strfreev(paths); } else { for (const char **it = pepperflash_path_list; *it != NULL; it++) { wordexp_t p; if (wordexp(*it, &p, WRDE_NOCMD) == 0) { const char *fname = p.we_wordv[0]; trace_info_f("probing %s\n", fname); probe_flapper(fname); } } } flapper_descr = g_strdup_printf("Shockwave Flash %u.%u r%u", flapper_version.v[0], flapper_version.v[1], flapper_version.v[2]); flapper_str_version = g_strdup_printf("%u.%u.%u.%u", flapper_version.v[0], flapper_version.v[1], flapper_version.v[2], flapper_version.v[3]); } const char * fpp_config_get_plugin_version(void) { return flapper_str_version; } const char * fpp_config_get_plugin_name(void) { return "Shockwave Flash"; } const char * fpp_config_get_plugin_descr(void) { return flapper_descr; } const char * fpp_config_get_plugin_mime_type(void) { return "application/x-shockwave-flash:swf:Shockwave Flash;" "application/futuresplash:spl:FutureSplash Player"; } char * fpp_config_get_plugin_path(void) { return flapper_path; } const char * fpp_config_get_plugin_file_name(void) { return "libpepflashplayer.so"; } void fpp_config_detect_plugin_specific_quirks(void) { config.quirks.connect_first_loader_to_unrequested_stream = 1; } freshplayerplugin-0.3.9/src/config_priv.h000066400000000000000000000033421321746453100205430ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 /** name of binary (without path) */ const char * fpp_config_get_plugin_file_name(void); /** default name of plugin to display on plugin list page */ const char * fpp_config_get_plugin_name(void); /** list of mime types in NPAPI format */ const char * fpp_config_get_plugin_mime_type(void); const char * fpp_config_get_plugin_version(void); const char * fpp_config_get_plugin_descr(void); /** return full path to a plugin if set */ char * fpp_config_get_plugin_path(void); void fpp_config_detect_plugin_specific_quirks(void); void fpp_config_find_backend_plugin(void); freshplayerplugin-0.3.9/src/dep_check.c000066400000000000000000000024661321746453100201440ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 char * NP_GetPluginVersion(void); int main(void) { printf("version: %s\n", NP_GetPluginVersion()); printf("pass\n"); return 0; } freshplayerplugin-0.3.9/src/eintr_retry.h000066400000000000000000000030671321746453100206100ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include // helper macro to retry system call which returned EINTR #define RETRY_ON_EINTR(x) ({ \ typeof(x) ___tmp_res; \ do { \ ___tmp_res = (x); \ } while (___tmp_res == -1 && errno == EINTR); \ ___tmp_res; \ }) freshplayerplugin-0.3.9/src/encoding_alias.c000066400000000000000000000102101321746453100211600ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "encoding_alias.h" #include #include #include #include enum { UIGNORE = 0, ZERO = 1, NONZ = 2, }; static const uint8_t char_types[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ZERO, NONZ, NONZ, NONZ, NONZ, NONZ, NONZ, NONZ, NONZ, NONZ, 0, 0, 0, 0, 0, 0, 0, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0, 0, 0, 0, 0, 0, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0, 0, 0, 0, 0, /* remaining 128-255 are 0 */ }; // maps an alias to the canonical encoding name static GHashTable *ce_ht; // char * -> char * static char * strip_enc_name(const char *name) { if (!name) return NULL; char *dst = strdup(name); if (!dst) return NULL; char *p = dst; int after_digit = 0; while (1) { char c = *name++; if (c == '\0') break; const uint8_t type = char_types[(uint8_t)c]; switch (type) { case UIGNORE: after_digit = 0; // ignore all but letter and digits continue; case ZERO: if (!after_digit) { const uint8_t next_type = char_types[(uint8_t)(*name)]; if (next_type == ZERO || next_type == NONZ) { // ignore leading zero before another digit continue; } } break; case NONZ: after_digit = 1; break; default: c = type; // lowercased letter after_digit = 0; break; } *p++ = c; } *p = 0; return dst; } __attribute__((constructor)) static void constructor_encoding_alias(void) { ce_ht = g_hash_table_new_full(g_str_hash, g_str_equal, free, free); struct { const char *dst; const char *src; } encs[] = { #include "encoding_alias_list.inc.c" }; for (uint32_t k = 0; k < sizeof(encs) / sizeof(encs[0]); k ++) { char *stripped_src_name = strip_enc_name(encs[k].src); g_hash_table_insert(ce_ht, stripped_src_name, strdup(encs[k].dst)); } } __attribute__((destructor)) static void destructor_encoding_alias(void) { g_hash_table_destroy(ce_ht); } const char * encoding_alias_get_canonical_name(const char *name) { const char *res = name; char *stripped_name = strip_enc_name(name); res = g_hash_table_lookup(ce_ht, stripped_name); if (!res) res = name; g_free(stripped_name); return res; } freshplayerplugin-0.3.9/src/encoding_alias.h000066400000000000000000000023441321746453100211760ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 const char * encoding_alias_get_canonical_name(const char *name); freshplayerplugin-0.3.9/src/encoding_alias_list.inc.c000066400000000000000000000201431321746453100227710ustar00rootroot00000000000000// autogenerated by /tools/encodings/gen-encoding-aliases.py // The Encoding { "UTF-8", "UTF-8" }, { "UTF-8", "unicode-1-1-utf-8" }, { "UTF-8", "utf-8" }, { "UTF-8", "utf8" }, // Legacy single-byte encodings { "IBM866", "IBM866" }, { "IBM866", "866" }, { "IBM866", "cp866" }, { "IBM866", "csibm866" }, { "IBM866", "ibm866" }, { "ISO-8859-2", "ISO-8859-2" }, { "ISO-8859-2", "csisolatin2" }, { "ISO-8859-2", "iso-8859-2" }, { "ISO-8859-2", "iso-ir-101" }, { "ISO-8859-2", "iso8859-2" }, { "ISO-8859-2", "iso88592" }, { "ISO-8859-2", "iso_8859-2" }, { "ISO-8859-2", "iso_8859-2:1987" }, { "ISO-8859-2", "l2" }, { "ISO-8859-2", "latin2" }, { "ISO-8859-3", "ISO-8859-3" }, { "ISO-8859-3", "csisolatin3" }, { "ISO-8859-3", "iso-8859-3" }, { "ISO-8859-3", "iso-ir-109" }, { "ISO-8859-3", "iso8859-3" }, { "ISO-8859-3", "iso88593" }, { "ISO-8859-3", "iso_8859-3" }, { "ISO-8859-3", "iso_8859-3:1988" }, { "ISO-8859-3", "l3" }, { "ISO-8859-3", "latin3" }, { "ISO-8859-4", "ISO-8859-4" }, { "ISO-8859-4", "csisolatin4" }, { "ISO-8859-4", "iso-8859-4" }, { "ISO-8859-4", "iso-ir-110" }, { "ISO-8859-4", "iso8859-4" }, { "ISO-8859-4", "iso88594" }, { "ISO-8859-4", "iso_8859-4" }, { "ISO-8859-4", "iso_8859-4:1988" }, { "ISO-8859-4", "l4" }, { "ISO-8859-4", "latin4" }, { "ISO-8859-5", "ISO-8859-5" }, { "ISO-8859-5", "csisolatincyrillic" }, { "ISO-8859-5", "cyrillic" }, { "ISO-8859-5", "iso-8859-5" }, { "ISO-8859-5", "iso-ir-144" }, { "ISO-8859-5", "iso8859-5" }, { "ISO-8859-5", "iso88595" }, { "ISO-8859-5", "iso_8859-5" }, { "ISO-8859-5", "iso_8859-5:1988" }, { "ISO-8859-6", "ISO-8859-6" }, { "ISO-8859-6", "arabic" }, { "ISO-8859-6", "asmo-708" }, { "ISO-8859-6", "csiso88596e" }, { "ISO-8859-6", "csiso88596i" }, { "ISO-8859-6", "csisolatinarabic" }, { "ISO-8859-6", "ecma-114" }, { "ISO-8859-6", "iso-8859-6" }, { "ISO-8859-6", "iso-8859-6-e" }, { "ISO-8859-6", "iso-8859-6-i" }, { "ISO-8859-6", "iso-ir-127" }, { "ISO-8859-6", "iso8859-6" }, { "ISO-8859-6", "iso88596" }, { "ISO-8859-6", "iso_8859-6" }, { "ISO-8859-6", "iso_8859-6:1987" }, { "ISO-8859-7", "ISO-8859-7" }, { "ISO-8859-7", "csisolatingreek" }, { "ISO-8859-7", "ecma-118" }, { "ISO-8859-7", "elot_928" }, { "ISO-8859-7", "greek" }, { "ISO-8859-7", "greek8" }, { "ISO-8859-7", "iso-8859-7" }, { "ISO-8859-7", "iso-ir-126" }, { "ISO-8859-7", "iso8859-7" }, { "ISO-8859-7", "iso88597" }, { "ISO-8859-7", "iso_8859-7" }, { "ISO-8859-7", "iso_8859-7:1987" }, { "ISO-8859-7", "sun_eu_greek" }, { "ISO-8859-8", "ISO-8859-8" }, { "ISO-8859-8", "csiso88598e" }, { "ISO-8859-8", "csisolatinhebrew" }, { "ISO-8859-8", "hebrew" }, { "ISO-8859-8", "iso-8859-8" }, { "ISO-8859-8", "iso-8859-8-e" }, { "ISO-8859-8", "iso-ir-138" }, { "ISO-8859-8", "iso8859-8" }, { "ISO-8859-8", "iso88598" }, { "ISO-8859-8", "iso_8859-8" }, { "ISO-8859-8", "iso_8859-8:1988" }, { "ISO-8859-8", "visual" }, { "ISO-8859-8-I", "ISO-8859-8-I" }, { "ISO-8859-8-I", "csiso88598i" }, { "ISO-8859-8-I", "iso-8859-8-i" }, { "ISO-8859-8-I", "logical" }, { "ISO-8859-10", "ISO-8859-10" }, { "ISO-8859-10", "csisolatin6" }, { "ISO-8859-10", "iso-8859-10" }, { "ISO-8859-10", "iso-ir-157" }, { "ISO-8859-10", "iso8859-10" }, { "ISO-8859-10", "iso885910" }, { "ISO-8859-10", "l6" }, { "ISO-8859-10", "latin6" }, { "ISO-8859-13", "ISO-8859-13" }, { "ISO-8859-13", "iso-8859-13" }, { "ISO-8859-13", "iso8859-13" }, { "ISO-8859-13", "iso885913" }, { "ISO-8859-14", "ISO-8859-14" }, { "ISO-8859-14", "iso-8859-14" }, { "ISO-8859-14", "iso8859-14" }, { "ISO-8859-14", "iso885914" }, { "ISO-8859-15", "ISO-8859-15" }, { "ISO-8859-15", "csisolatin9" }, { "ISO-8859-15", "iso-8859-15" }, { "ISO-8859-15", "iso8859-15" }, { "ISO-8859-15", "iso885915" }, { "ISO-8859-15", "iso_8859-15" }, { "ISO-8859-15", "l9" }, { "ISO-8859-16", "ISO-8859-16" }, { "ISO-8859-16", "iso-8859-16" }, { "KOI8-R", "KOI8-R" }, { "KOI8-R", "cskoi8r" }, { "KOI8-R", "koi" }, { "KOI8-R", "koi8" }, { "KOI8-R", "koi8-r" }, { "KOI8-R", "koi8_r" }, { "KOI8-U", "KOI8-U" }, { "KOI8-U", "koi8-ru" }, { "KOI8-U", "koi8-u" }, { "macintosh", "macintosh" }, { "macintosh", "csmacintosh" }, { "macintosh", "mac" }, { "macintosh", "macintosh" }, { "macintosh", "x-mac-roman" }, { "windows-874", "windows-874" }, { "windows-874", "dos-874" }, { "windows-874", "iso-8859-11" }, { "windows-874", "iso8859-11" }, { "windows-874", "iso885911" }, { "windows-874", "tis-620" }, { "windows-874", "windows-874" }, { "windows-1250", "windows-1250" }, { "windows-1250", "cp1250" }, { "windows-1250", "windows-1250" }, { "windows-1250", "x-cp1250" }, { "windows-1251", "windows-1251" }, { "windows-1251", "cp1251" }, { "windows-1251", "windows-1251" }, { "windows-1251", "x-cp1251" }, { "windows-1252", "windows-1252" }, { "windows-1252", "ansi_x3.4-1968" }, { "windows-1252", "ascii" }, { "windows-1252", "cp1252" }, { "windows-1252", "cp819" }, { "windows-1252", "csisolatin1" }, { "windows-1252", "ibm819" }, { "windows-1252", "iso-8859-1" }, { "windows-1252", "iso-ir-100" }, { "windows-1252", "iso8859-1" }, { "windows-1252", "iso88591" }, { "windows-1252", "iso_8859-1" }, { "windows-1252", "iso_8859-1:1987" }, { "windows-1252", "l1" }, { "windows-1252", "latin1" }, { "windows-1252", "us-ascii" }, { "windows-1252", "windows-1252" }, { "windows-1252", "x-cp1252" }, { "windows-1253", "windows-1253" }, { "windows-1253", "cp1253" }, { "windows-1253", "windows-1253" }, { "windows-1253", "x-cp1253" }, { "windows-1254", "windows-1254" }, { "windows-1254", "cp1254" }, { "windows-1254", "csisolatin5" }, { "windows-1254", "iso-8859-9" }, { "windows-1254", "iso-ir-148" }, { "windows-1254", "iso8859-9" }, { "windows-1254", "iso88599" }, { "windows-1254", "iso_8859-9" }, { "windows-1254", "iso_8859-9:1989" }, { "windows-1254", "l5" }, { "windows-1254", "latin5" }, { "windows-1254", "windows-1254" }, { "windows-1254", "x-cp1254" }, { "windows-1255", "windows-1255" }, { "windows-1255", "cp1255" }, { "windows-1255", "windows-1255" }, { "windows-1255", "x-cp1255" }, { "windows-1256", "windows-1256" }, { "windows-1256", "cp1256" }, { "windows-1256", "windows-1256" }, { "windows-1256", "x-cp1256" }, { "windows-1257", "windows-1257" }, { "windows-1257", "cp1257" }, { "windows-1257", "windows-1257" }, { "windows-1257", "x-cp1257" }, { "windows-1258", "windows-1258" }, { "windows-1258", "cp1258" }, { "windows-1258", "windows-1258" }, { "windows-1258", "x-cp1258" }, { "x-mac-cyrillic", "x-mac-cyrillic" }, { "x-mac-cyrillic", "x-mac-cyrillic" }, { "x-mac-cyrillic", "x-mac-ukrainian" }, // Legacy multi-byte Chinese (simplified) encodings { "GBK", "GBK" }, { "GBK", "chinese" }, { "GBK", "csgb2312" }, { "GBK", "csiso58gb231280" }, { "GBK", "gb2312" }, { "GBK", "gb_2312" }, { "GBK", "gb_2312-80" }, { "GBK", "gbk" }, { "GBK", "iso-ir-58" }, { "GBK", "x-gbk" }, { "gb18030", "gb18030" }, { "gb18030", "gb18030" }, // Legacy multi-byte Chinese (traditional) encodings { "Big5", "Big5" }, { "Big5", "big5" }, { "Big5", "big5-hkscs" }, { "Big5", "cn-big5" }, { "Big5", "csbig5" }, { "Big5", "x-x-big5" }, // Legacy multi-byte Japanese encodings { "EUC-JP", "EUC-JP" }, { "EUC-JP", "cseucpkdfmtjapanese" }, { "EUC-JP", "euc-jp" }, { "EUC-JP", "x-euc-jp" }, { "ISO-2022-JP", "ISO-2022-JP" }, { "ISO-2022-JP", "csiso2022jp" }, { "ISO-2022-JP", "iso-2022-jp" }, { "Shift_JIS", "Shift_JIS" }, { "Shift_JIS", "csshiftjis" }, { "Shift_JIS", "ms932" }, { "Shift_JIS", "ms_kanji" }, { "Shift_JIS", "shift-jis" }, { "Shift_JIS", "shift_jis" }, { "Shift_JIS", "sjis" }, { "Shift_JIS", "windows-31j" }, { "Shift_JIS", "x-sjis" }, // Legacy multi-byte Korean encodings { "EUC-KR", "EUC-KR" }, { "EUC-KR", "cseuckr" }, { "EUC-KR", "csksc56011987" }, { "EUC-KR", "euc-kr" }, { "EUC-KR", "iso-ir-149" }, { "EUC-KR", "korean" }, { "EUC-KR", "ks_c_5601-1987" }, { "EUC-KR", "ks_c_5601-1989" }, { "EUC-KR", "ksc5601" }, { "EUC-KR", "ksc_5601" }, { "EUC-KR", "windows-949" }, // Legacy miscellaneous encodings { "replacement", "replacement" }, { "replacement", "csiso2022kr" }, { "replacement", "hz-gb-2312" }, { "replacement", "iso-2022-cn" }, { "replacement", "iso-2022-cn-ext" }, { "replacement", "iso-2022-kr" }, { "UTF-16BE", "UTF-16BE" }, { "UTF-16BE", "utf-16be" }, { "UTF-16LE", "UTF-16LE" }, { "UTF-16LE", "utf-16" }, { "UTF-16LE", "utf-16le" }, { "x-user-defined", "x-user-defined" }, { "x-user-defined", "x-user-defined" }, freshplayerplugin-0.3.9/src/font.c000066400000000000000000000224051321746453100172000ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "font.h" #include "pp_resource.h" #include "ppb_image_data.h" #include "ppb_var.h" #include "tables.h" #include "trace_core.h" #include #include #include #include struct PP_Var fpp_font_get_font_families(void) { GString *builder; PangoFontFamily **families; int n; pango_font_map_list_families(tables_get_pango_font_map(), &families, &n); builder = g_string_new(NULL); for (int k = 0; k < n; k ++) { g_string_append(builder, pango_font_family_get_name(families[k])); g_string_append_c(builder, 0); } struct PP_Var var = ppb_var_var_from_utf8(builder->str, builder->len); g_string_free(builder, TRUE); g_free(families); return var; } void fpp_font_init(struct fpp_font *ff, const struct PP_FontDescription_Dev *description) { PangoFontDescription *font_desc = pp_font_desc_to_pango_font_desc(description); ff->family = description->face.type == PP_VARTYPE_STRING ? 0 : description->family; ff->letter_spacing = description->letter_spacing; ff->word_spacing = description->word_spacing; ff->font = pango_context_load_font(tables_get_pango_ctx(), font_desc); ff->font_desc = pango_font_describe_with_absolute_size(ff->font); pango_font_description_free(font_desc); // font description won't change during lifetime of browser_font resource, // so we can cache it here ff->measure_layout = pango_layout_new(tables_get_pango_ctx()); pango_layout_set_font_description(ff->measure_layout, ff->font_desc); } void fpp_font_destroy(struct fpp_font *ff) { pango_font_description_free(ff->font_desc); g_object_unref(ff->font); g_object_unref(ff->measure_layout); } PP_Bool fpp_font_describe(struct fpp_font *ff, struct PP_FontDescription_Dev *description, struct PP_FontMetrics_Dev *metrics) { memset(description, 0, sizeof(*description)); memset(metrics, 0, sizeof(*metrics)); const char *s_family = pango_font_description_get_family(ff->font_desc); description->face = ppb_var_var_from_utf8_z(s_family); description->family = ff->family >= 0 ? ff->family : 0; description->size = pango_font_description_get_size(ff->font_desc) / PANGO_SCALE; description->weight = pango_font_description_get_weight(ff->font_desc)/100 - 1; description->italic = (pango_font_description_get_style(ff->font_desc) != PANGO_STYLE_NORMAL); description->small_caps = (pango_font_description_get_variant(ff->font_desc) == PANGO_VARIANT_SMALL_CAPS); description->letter_spacing = ff->letter_spacing; description->word_spacing = ff->word_spacing; PangoFontMetrics *m = pango_font_get_metrics(ff->font, NULL); // TODO: use fontconfig-specific structures in pango to determine height and x-height metrics->ascent = pango_font_metrics_get_ascent(m) / PANGO_SCALE; metrics->descent = pango_font_metrics_get_descent(m) / PANGO_SCALE; metrics->height = (pango_font_metrics_get_ascent(m) + pango_font_metrics_get_descent(m)) / PANGO_SCALE; metrics->line_spacing = 1; // TODO: get actual line spacing metrics->x_height = metrics->height; // TODO: find out actual x-height pango_font_metrics_unref(m); return PP_TRUE; } PP_Bool fpp_font_draw_text_at(struct fpp_font *ff, PP_Resource image_data, const struct PP_TextRun_Dev *text, const struct PP_Point *position, uint32_t color, const struct PP_Rect *clip, PP_Bool image_data_is_opaque) { (void)image_data_is_opaque; // TODO: is it worth implementing? struct pp_image_data_s *id = pp_resource_acquire(image_data, PP_RESOURCE_IMAGE_DATA); if (!id) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } cairo_t *cr = cairo_create(id->cairo_surf); if (clip) { cairo_rectangle(cr, clip->point.x, clip->point.y, clip->size.width, clip->size.height); cairo_clip(cr); } PangoFontMetrics *m = pango_font_get_metrics(ff->font, NULL); int32_t ascent = pango_font_metrics_get_ascent(m) / PANGO_SCALE; cairo_surface_mark_dirty(id->cairo_surf); if (position) cairo_move_to(cr, position->x, position->y - ascent); else cairo_move_to(cr, 0, 0); pango_font_metrics_unref(m); cairo_set_source_rgba(cr, ((color >> 16) & 0xffu) / 255.0, ((color >> 8) & 0xffu) / 255.0, ((color >> 0) & 0xffu) / 255.0, ((color >> 24) & 0xffu) / 255.0); PangoLayout *layout = pango_cairo_create_layout(cr); uint32_t len = 0; const char *s = ""; if (text->text.type == PP_VARTYPE_STRING) s = ppb_var_var_to_utf8(text->text, &len); // TODO: factor into rtl direction pango_layout_set_font_description(layout, ff->font_desc); pango_layout_set_text(layout, s, len); pango_cairo_layout_path(cr, layout); cairo_fill(cr); g_object_unref(layout); cairo_surface_flush(id->cairo_surf); cairo_destroy(cr); pp_resource_release(image_data); return PP_TRUE; } int32_t fpp_font_measure_text(struct fpp_font *ff, const struct PP_TextRun_Dev *text) { uint32_t len = 0; const char *s = ""; if (text->text.type == PP_VARTYPE_STRING) s = ppb_var_var_to_utf8(text->text, &len); // TODO: factor into rtl direction pango_layout_set_text(ff->measure_layout, s, len); int width, height; pango_layout_get_pixel_size(ff->measure_layout, &width, &height); return width; } uint32_t fpp_font_character_offset_for_pixel(struct fpp_font *ff, const struct PP_TextRun_Dev *text, int32_t pixel_position) { return 0; } int32_t fpp_font_pixel_offset_for_character(struct fpp_font *ff, const struct PP_TextRun_Dev *text, uint32_t char_offset) { return 0; } PangoFontDescription * pp_font_desc_to_pango_font_desc(const struct PP_FontDescription_Dev *description) { PangoFontDescription *font_desc; if (description->face.type == PP_VARTYPE_STRING) { const char *s = ppb_var_var_to_utf8(description->face, NULL); font_desc = pango_font_description_from_string(s); } else { font_desc = pango_font_description_new(); switch (description->family) { case PP_BROWSERFONT_TRUSTED_FAMILY_SERIF: pango_font_description_set_family(font_desc, "serif"); break; case PP_BROWSERFONT_TRUSTED_FAMILY_SANSSERIF: pango_font_description_set_family(font_desc, "sans-serif"); break; case PP_BROWSERFONT_TRUSTED_FAMILY_MONOSPACE: pango_font_description_set_family(font_desc, "monospace"); break; case PP_BROWSERFONT_TRUSTED_FAMILY_DEFAULT: // fall through default: // do nothing break; } } pango_font_description_set_absolute_size(font_desc, description->size * PANGO_SCALE); pango_font_description_set_weight(font_desc, (description->weight + 1) * 100); if (description->italic) pango_font_description_set_style(font_desc, PANGO_STYLE_ITALIC); if (description->small_caps) pango_font_description_set_variant(font_desc, PANGO_VARIANT_SMALL_CAPS); return font_desc; } struct PP_FontDescription_Dev pp_browser_font_desc_to_pp_font_desc(const struct PP_BrowserFont_Trusted_Description *descr) { struct PP_FontDescription_Dev font_descr = { .face = descr->face, .family = (PP_FontFamily_Dev)descr->family, .size = descr->size, .weight = (PP_FontWeight_Dev)descr->weight, .italic = descr->italic, .small_caps = descr->small_caps, .letter_spacing = descr->letter_spacing, .word_spacing = descr->word_spacing, .padding = descr->padding }; return font_descr; } PangoFontDescription * pp_browser_font_desc_to_pango_font_desc(const struct PP_BrowserFont_Trusted_Description *descr) { struct PP_FontDescription_Dev font_descr = pp_browser_font_desc_to_pp_font_desc(descr); return pp_font_desc_to_pango_font_desc(&font_descr); } freshplayerplugin-0.3.9/src/font.h000066400000000000000000000056011321746453100172040ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include #include #include struct fpp_font { PangoFont *font; PangoFontDescription *font_desc; PangoLayout *measure_layout; int32_t letter_spacing; int32_t word_spacing; int32_t family; }; struct PP_Var fpp_font_get_font_families(void); void fpp_font_init(struct fpp_font *ff, const struct PP_FontDescription_Dev *description); void fpp_font_destroy(struct fpp_font *ff); PP_Bool fpp_font_describe(struct fpp_font *ff, struct PP_FontDescription_Dev *description, struct PP_FontMetrics_Dev *metrics); PP_Bool fpp_font_draw_text_at(struct fpp_font *ff, PP_Resource image_data, const struct PP_TextRun_Dev *text, const struct PP_Point *position, uint32_t color, const struct PP_Rect *clip, PP_Bool image_data_is_opaque); int32_t fpp_font_measure_text(struct fpp_font *ff, const struct PP_TextRun_Dev *text); uint32_t fpp_font_character_offset_for_pixel(struct fpp_font *ff, const struct PP_TextRun_Dev *text, int32_t pixel_position); int32_t fpp_font_pixel_offset_for_character(struct fpp_font *ff, const struct PP_TextRun_Dev *text, uint32_t char_offset); PangoFontDescription * pp_font_desc_to_pango_font_desc(const struct PP_FontDescription_Dev *description); struct PP_FontDescription_Dev pp_browser_font_desc_to_pp_font_desc(const struct PP_BrowserFont_Trusted_Description *descr); PangoFontDescription * pp_browser_font_desc_to_pango_font_desc(const struct PP_BrowserFont_Trusted_Description *descr); freshplayerplugin-0.3.9/src/glx.h000066400000000000000000000002321321746453100170230ustar00rootroot00000000000000#pragma once #define GLX_GLXEXT_LEGACY // prevent inclusion of glxext.h #define GL_GLEXT_LEGACY // prevent inclusion of glext.h #include freshplayerplugin-0.3.9/src/gtk_wrapper.c000066400000000000000000000264641321746453100205700ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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. */ #define _GNU_SOURCE #include "gtk_wrapper.h" #include "trace_core.h" #include #include #include #include #include static struct { int major_version; int minor_version; int available_flag; void *dl_handler; } gw = {}; GdkAtom (*gw_gdk_atom_intern)(const gchar *atom_name, gboolean only_if_exists); GdkAtom (*gw_gdk_atom_intern_static_string)(const gchar *atom_name); gchar * (*gw_gdk_atom_name)(GdkAtom atom); GdkDisplay * (*gw_gdk_display_get_default)(void); void (*gw_gdk_event_free)(GdkEvent *event); GdkEvent * (*gw_gdk_event_new)(GdkEventType type); gboolean (*gw_gdk_keymap_get_entries_for_keycode)(GdkKeymap *keymap, guint hardware_keycode, GdkKeymapKey **keys, guint **keyvals, gint *n_entries); GdkKeymap * (*gw_gdk_keymap_get_for_display)(GdkDisplay *display); GdkDisplay * (*gw_gdk_window_get_display)(GdkWindow *window); void (*gw_gdk_window_set_user_data)(GdkWindow *window, gpointer user_data); Display * (*gw_gdk_x11_display_get_xdisplay)(GdkDisplay *display); Window (*gw_gdk_x11_drawable_get_xid)(GdkWindow *window); GdkDisplay * (*gw_gdk_x11_lookup_xdisplay)(Display *xdisplay); GdkWindow * (*gw_gdk_x11_window_foreign_new_for_display)(GdkDisplay *display, Window window); GdkWindow * (*gw_gdk_x11_window_lookup_for_display)(GdkDisplay *display, Window window); GType (*gw_gtk_check_menu_item_get_type)(void); GtkWidget * (*gw_gtk_check_menu_item_new_with_label)(const gchar *label); void (*gw_gtk_check_menu_item_set_active)(GtkCheckMenuItem *check_menu_item, gboolean is_active); void (*gw_gtk_clipboard_clear)(GtkClipboard *clipboard); GtkClipboard * (*gw_gtk_clipboard_get)(GdkAtom selection); void (*gw_gtk_clipboard_set_can_store)(GtkClipboard *clipboard, const GtkTargetEntry *targets, gint n_targets); gboolean (*gw_gtk_clipboard_set_with_data)(GtkClipboard *clipboard, const GtkTargetEntry *targets, guint n_targets, GtkClipboardGetFunc get_func, GtkClipboardClearFunc clear_func, gpointer user_data); GtkSelectionData * (*gw_gtk_clipboard_wait_for_contents)(GtkClipboard *clipboard, GdkAtom target); gboolean (*gw_gtk_clipboard_wait_is_target_available)(GtkClipboard *clipboard, GdkAtom target); GtkWidget * (*gw_gtk_file_chooser_dialog_new)(const gchar *title, GtkWindow *parent, GtkFileChooserAction action, const gchar *first_button_text, ...); GSList * (*gw_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser); GType (*gw_gtk_file_chooser_get_type)(void); void (*gw_gtk_file_chooser_set_select_multiple)(GtkFileChooser *chooser, gboolean select_multiple); guint32 (*gw_gtk_get_current_event_time)(void); gboolean (*gw_gtk_im_context_filter_keypress)(GtkIMContext *context, GdkEventKey *event); void (*gw_gtk_im_context_focus_in)(GtkIMContext *context); void (*gw_gtk_im_context_focus_out)(GtkIMContext *context); void (*gw_gtk_im_context_get_preedit_string)(GtkIMContext *context, gchar **str, PangoAttrList **attrs, gint *cursor_pos); void (*gw_gtk_im_context_reset)(GtkIMContext *context); void (*gw_gtk_im_context_set_client_window)(GtkIMContext *context, GdkWindow *window); void (*gw_gtk_im_context_set_cursor_location)(GtkIMContext *context, const GdkRectangle *area); void (*gw_gtk_im_context_set_surrounding)(GtkIMContext *context, const gchar *text, gint len, gint cursor_index); GtkIMContext * (*gw_gtk_im_context_simple_new)(void); GtkIMContext * (*gw_gtk_im_multicontext_new)(void); GtkWidget * (*gw_gtk_label_new)(const gchar *str); GType (*gw_gtk_menu_get_type)(void); GType (*gw_gtk_menu_item_get_type)(void); GtkWidget * (*gw_gtk_menu_item_new_with_label)(const gchar *label); void (*gw_gtk_menu_item_set_submenu)(GtkMenuItem *menu_item, GtkWidget *submenu); GtkWidget * (*gw_gtk_menu_new)(void); void (*gw_gtk_menu_popup)(GtkMenu *menu, GtkWidget *parent_menu_shell, GtkWidget *parent_menu_item, GtkMenuPositionFunc func, gpointer data, guint button, guint32 activate_time); void (*gw_gtk_menu_shell_append)(GtkMenuShell *menu_shell, GtkWidget *child); GType (*gw_gtk_menu_shell_get_type)(void); void (*gw_gtk_selection_data_free)(GtkSelectionData *data); const guchar * (*gw_gtk_selection_data_get_data)(const GtkSelectionData *selection_data); gint (*gw_gtk_selection_data_get_length)(const GtkSelectionData *selection_data); void (*gw_gtk_selection_data_set)(GtkSelectionData *selection_data, GdkAtom type, gint format, const guchar *data, gint length); GtkWidget * (*gw_gtk_separator_menu_item_new)(void); void (*gw_gtk_widget_destroy)(GtkWidget *widget); GType (*gw_gtk_widget_get_type)(void); GdkWindow * (*gw_gtk_widget_get_window)(GtkWidget *widget); void (*gw_gtk_widget_realize)(GtkWidget *widget); void (*gw_gtk_widget_set_realized)(GtkWidget *widget, gboolean realized); void (*gw_gtk_widget_set_sensitive)(GtkWidget *widget, gboolean sensitive); void (*gw_gtk_widget_show)(GtkWidget *widget); static int find_gtk_cb(struct dl_phdr_info *info, size_t size, void *data) { if (!info->dlpi_name) return 0; // try GTK+ 2 if (strstr(info->dlpi_name, "/libgtk-x11-2.0")) { gw.dl_handler = dlopen(info->dlpi_name, RTLD_NOW); gw.major_version = 2; } // try GTK+ 3 if (strstr(info->dlpi_name, "/libgtk-3.so")) { gw.dl_handler = dlopen(info->dlpi_name, RTLD_NOW); gw.major_version = 3; } // don't care if both versions are loaded. // In that case we're in a buggy state anyway. return 0; } void gtk_wrapper_initialize(void) { static int initialize_was_called = 0; if (initialize_was_called) return; initialize_was_called = 1; dl_iterate_phdr(find_gtk_cb, NULL); if (gw.major_version == 0) return; gw.available_flag = 1; uint32_t *minor_version; uint32_t (*gw_gtk_get_minor_version)(void); switch (gw.major_version) { case 2: minor_version = dlsym(RTLD_DEFAULT, "gtk_minor_version"); if (minor_version) memcpy(&gw.minor_version, minor_version, sizeof(uint32_t)); break; case 3: gw_gtk_get_minor_version = dlsym(RTLD_DEFAULT, "gtk_get_minor_version"); if (gw_gtk_get_minor_version) gw.minor_version = gw_gtk_get_minor_version(); break; default: // do nothing break; } #define GET_SYMBOL2(symname, libname) \ do { \ gw_ ## symname = dlsym(gw.dl_handler, #libname); \ if (gw_ ## symname == NULL) \ trace_error("can't resolve " #libname "\n"); \ } while (0) #define GET_SYMBOL(symname) \ do { \ GET_SYMBOL2(symname, symname); \ } while (0) GET_SYMBOL(gtk_check_menu_item_get_type); GET_SYMBOL(gtk_check_menu_item_new_with_label); GET_SYMBOL(gtk_check_menu_item_set_active); GET_SYMBOL(gtk_clipboard_clear); GET_SYMBOL(gtk_clipboard_get); GET_SYMBOL(gtk_clipboard_set_can_store); GET_SYMBOL(gtk_clipboard_set_with_data); GET_SYMBOL(gtk_clipboard_wait_for_contents); GET_SYMBOL(gtk_clipboard_wait_is_target_available); GET_SYMBOL(gtk_file_chooser_dialog_new); GET_SYMBOL(gtk_file_chooser_get_filenames); GET_SYMBOL(gtk_file_chooser_get_type); GET_SYMBOL(gtk_file_chooser_set_select_multiple); GET_SYMBOL(gtk_get_current_event_time); GET_SYMBOL(gtk_im_context_filter_keypress); GET_SYMBOL(gtk_im_context_focus_in); GET_SYMBOL(gtk_im_context_focus_out); GET_SYMBOL(gtk_im_context_get_preedit_string); GET_SYMBOL(gtk_im_context_reset); GET_SYMBOL(gtk_im_context_set_client_window); GET_SYMBOL(gtk_im_context_set_cursor_location); GET_SYMBOL(gtk_im_context_set_surrounding); GET_SYMBOL(gtk_im_context_simple_new); GET_SYMBOL(gtk_im_multicontext_new); GET_SYMBOL(gtk_label_new); GET_SYMBOL(gtk_menu_get_type); GET_SYMBOL(gtk_menu_item_get_type); GET_SYMBOL(gtk_menu_item_new_with_label); GET_SYMBOL(gtk_menu_item_set_submenu); GET_SYMBOL(gtk_menu_new); GET_SYMBOL(gtk_menu_popup); GET_SYMBOL(gtk_menu_shell_append); GET_SYMBOL(gtk_menu_shell_get_type); GET_SYMBOL(gtk_selection_data_free); GET_SYMBOL(gtk_selection_data_get_data); GET_SYMBOL(gtk_selection_data_get_length); GET_SYMBOL(gtk_selection_data_set); GET_SYMBOL(gtk_separator_menu_item_new); GET_SYMBOL(gtk_widget_destroy); GET_SYMBOL(gtk_widget_get_type); GET_SYMBOL(gtk_widget_get_window); GET_SYMBOL(gtk_widget_realize); GET_SYMBOL(gtk_widget_set_realized); GET_SYMBOL(gtk_widget_set_sensitive); GET_SYMBOL(gtk_widget_show); GET_SYMBOL(gdk_atom_intern); GET_SYMBOL(gdk_atom_intern_static_string); GET_SYMBOL(gdk_atom_name); GET_SYMBOL(gdk_display_get_default); GET_SYMBOL(gdk_event_free); GET_SYMBOL(gdk_event_new); GET_SYMBOL(gdk_keymap_get_entries_for_keycode); GET_SYMBOL(gdk_keymap_get_for_display); GET_SYMBOL(gdk_window_get_display); GET_SYMBOL(gdk_window_set_user_data); GET_SYMBOL(gdk_x11_display_get_xdisplay); GET_SYMBOL(gdk_x11_lookup_xdisplay); if (gw.major_version == 2) { GET_SYMBOL(gdk_x11_drawable_get_xid); } else { GET_SYMBOL2(gdk_x11_drawable_get_xid, gdk_x11_window_get_xid); } if (gw.major_version == 2 && gw.minor_version < 24) { // Those functions didn't exists before 2.24. // They appear in 2.24, while previous names become deprecated. GET_SYMBOL2(gdk_x11_window_foreign_new_for_display, gdk_window_foreign_new_for_display); GET_SYMBOL2(gdk_x11_window_lookup_for_display, gdk_window_lookup_for_display); } else { // in 2.24, or in 3.* GET_SYMBOL(gdk_x11_window_foreign_new_for_display); GET_SYMBOL(gdk_x11_window_lookup_for_display); } } int gw_major_version(void) { return gw.major_version; } int gw_minor_version(void) { return gw.minor_version; } int gw_gtk_available(void) { return gw.available_flag; } freshplayerplugin-0.3.9/src/gtk_wrapper.h000066400000000000000000000470121321746453100205650ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include #include #include // GTK+ type mockups #define GDK_WINDOW_XDISPLAY(win) \ (gw_gdk_x11_display_get_xdisplay(gw_gdk_window_get_display(win))) #define GDK_WINDOW_XID(win) (gw_gdk_x11_drawable_get_xid(win)) #define GTK_TYPE_CHECK_MENU_ITEM (gw_gtk_check_menu_item_get_type()) #define GTK_TYPE_FILE_CHOOSER (gw_gtk_file_chooser_get_type()) #define GTK_TYPE_MENU (gw_gtk_menu_get_type()) #define GTK_TYPE_MENU_ITEM (gw_gtk_menu_item_get_type()) #define GTK_TYPE_MENU_SHELL (gw_gtk_menu_shell_get_type()) #define GTK_TYPE_WIDGET (gw_gtk_widget_get_type()) #define GTK_FILE_CHOOSER(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_FILE_CHOOSER, GtkFileChooser)) #define GTK_WIDGET(widget) \ (G_TYPE_CHECK_INSTANCE_CAST((widget), GTK_TYPE_WIDGET, GtkWidget)) #define GTK_CHECK_MENU_ITEM(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_CHECK_MENU_ITEM, GtkCheckMenuItem)) #define GTK_MENU_SHELL(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_MENU_SHELL, GtkMenuShell)) #define GTK_MENU_ITEM(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_MENU_ITEM, GtkMenuItem)) #define GTK_MENU(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_MENU, GtkMenu)) #define _GDK_MAKE_ATOM(val) ((GdkAtom)GUINT_TO_POINTER(val)) #define GDK_NONE _GDK_MAKE_ATOM(0) #define GDK_SELECTION_PRIMARY _GDK_MAKE_ATOM(1) #define GDK_SELECTION_CLIPBOARD _GDK_MAKE_ATOM(69) typedef cairo_rectangle_int_t GdkRectangle; typedef struct _GdkAtom *GdkAtom; typedef struct _GdkDevice GdkDevice; typedef struct _GdkDisplay GdkDisplay; typedef struct _GdkDragContext GdkDragContext; typedef struct _GdkDrawable GdkWindow; typedef struct _GdkEventSequence GdkEventSequence; typedef struct _GdkKeymap GdkKeymap; typedef struct _GtkCheckMenuItem GtkCheckMenuItem; typedef struct _GtkClipboard GtkClipboard; typedef struct _GtkDialog GtkDialog; typedef struct _GtkFileChooser GtkFileChooser; typedef struct _GtkIMContext GtkIMContext; typedef struct _GtkMenu GtkMenu; typedef struct _GtkMenuItem GtkMenuItem; typedef struct _GtkMenuShell GtkMenuShell; typedef struct _GtkSelectionData GtkSelectionData; typedef struct _GtkWidget GtkWidget; typedef struct _GtkWindow GtkWindow; typedef enum { GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER, } GtkFileChooserAction; typedef enum { GDK_VISIBILITY_UNOBSCURED, GDK_VISIBILITY_PARTIAL, GDK_VISIBILITY_FULLY_OBSCURED, } GdkVisibilityState; typedef enum { GDK_SCROLL_UP, GDK_SCROLL_DOWN, GDK_SCROLL_LEFT, GDK_SCROLL_RIGHT, GDK_SCROLL_SMOOTH, } GdkScrollDirection; typedef enum { GDK_CROSSING_NORMAL, GDK_CROSSING_GRAB, GDK_CROSSING_UNGRAB, GDK_CROSSING_GTK_GRAB, GDK_CROSSING_GTK_UNGRAB, GDK_CROSSING_STATE_CHANGED, GDK_CROSSING_TOUCH_BEGIN, GDK_CROSSING_TOUCH_END, GDK_CROSSING_DEVICE_SWITCH, } GdkCrossingMode; typedef enum { GDK_NOTIFY_ANCESTOR = 0, GDK_NOTIFY_VIRTUAL = 1, GDK_NOTIFY_INFERIOR = 2, GDK_NOTIFY_NONLINEAR = 3, GDK_NOTIFY_NONLINEAR_VIRTUAL = 4, GDK_NOTIFY_UNKNOWN = 5, } GdkNotifyType; typedef enum { GDK_OWNER_CHANGE_NEW_OWNER, GDK_OWNER_CHANGE_DESTROY, GDK_OWNER_CHANGE_CLOSE, } GdkOwnerChange; typedef enum { GDK_SETTING_ACTION_NEW, GDK_SETTING_ACTION_CHANGED, GDK_SETTING_ACTION_DELETED, } GdkSettingAction; typedef enum { GDK_WINDOW_STATE_WITHDRAWN = 1 << 0, GDK_WINDOW_STATE_ICONIFIED = 1 << 1, GDK_WINDOW_STATE_MAXIMIZED = 1 << 2, GDK_WINDOW_STATE_STICKY = 1 << 3, GDK_WINDOW_STATE_FULLSCREEN = 1 << 4, GDK_WINDOW_STATE_ABOVE = 1 << 5, GDK_WINDOW_STATE_BELOW = 1 << 6, GDK_WINDOW_STATE_FOCUSED = 1 << 7, GDK_WINDOW_STATE_TILED = 1 << 8, } GdkWindowState; typedef enum { GDK_NOTHING = -1, GDK_DELETE = 0, GDK_DESTROY = 1, GDK_EXPOSE = 2, GDK_MOTION_NOTIFY = 3, GDK_BUTTON_PRESS = 4, GDK_2BUTTON_PRESS = 5, GDK_3BUTTON_PRESS = 6, GDK_BUTTON_RELEASE = 7, GDK_KEY_PRESS = 8, GDK_KEY_RELEASE = 9, GDK_ENTER_NOTIFY = 10, GDK_LEAVE_NOTIFY = 11, GDK_FOCUS_CHANGE = 12, GDK_CONFIGURE = 13, GDK_MAP = 14, GDK_UNMAP = 15, GDK_PROPERTY_NOTIFY = 16, GDK_SELECTION_CLEAR = 17, GDK_SELECTION_REQUEST = 18, GDK_SELECTION_NOTIFY = 19, GDK_PROXIMITY_IN = 20, GDK_PROXIMITY_OUT = 21, GDK_DRAG_ENTER = 22, GDK_DRAG_LEAVE = 23, GDK_DRAG_MOTION = 24, GDK_DRAG_STATUS = 25, GDK_DROP_START = 26, GDK_DROP_FINISHED = 27, GDK_CLIENT_EVENT = 28, GDK_VISIBILITY_NOTIFY = 29, GDK_NO_EXPOSE = 30, GDK_SCROLL = 31, GDK_WINDOW_STATE = 32, GDK_SETTING = 33, GDK_OWNER_CHANGE = 34, GDK_GRAB_BROKEN = 35, GDK_DAMAGE = 36, GDK_EVENT_LAST, } GdkEventType; typedef enum { GTK_RESPONSE_NONE = -1, GTK_RESPONSE_REJECT = -2, GTK_RESPONSE_ACCEPT = -3, GTK_RESPONSE_DELETE_EVENT = -4, GTK_RESPONSE_OK = -5, GTK_RESPONSE_CANCEL = -6, GTK_RESPONSE_CLOSE = -7, GTK_RESPONSE_YES = -8, GTK_RESPONSE_NO = -9, GTK_RESPONSE_APPLY = -10, GTK_RESPONSE_HELP = -11, } GtkResponseType; typedef struct _GdkEventAny { GdkEventType type; GdkWindow *window; gint8 send_event; } GdkEventAny; typedef struct _GdkEventExpose { GdkEventType type; GdkWindow *window; gint8 send_event; GdkRectangle area; cairo_region_t *region; gint count; } GdkEventExpose; typedef struct _GdkEventVisibility { GdkEventType type; GdkWindow *window; gint8 send_event; GdkVisibilityState state; } GdkEventVisibility; typedef struct _GdkEventMotion { GdkEventType type; GdkWindow *window; gint8 send_event; guint32 time; gdouble x, y; gdouble *axes; guint state; gint16 is_hint; GdkDevice *device; gdouble x_root, y_root; } GdkEventMotion; typedef struct _GdkEventButton { GdkEventType type; GdkWindow *window; gint8 send_event; guint32 time; gdouble x, y; gdouble *axes; guint state; guint button; GdkDevice *device; gdouble x_root, y_root; } GdkEventButton; typedef struct _GdkEventTouch { GdkEventType type; GdkWindow *window; gint8 send_event; guint32 time; gdouble x, y; gdouble *axes; guint state; GdkEventSequence *sequence; gboolean emulating_pointer; GdkDevice *device; gdouble x_root, y_root; } GdkEventTouch; typedef struct _GdkEventScroll { GdkEventType type; GdkWindow *window; gint8 send_event; guint32 time; gdouble x, y; guint state; GdkScrollDirection direction; GdkDevice *device; gdouble x_root, y_root; gdouble delta_x, delta_y; guint is_stop:1; } GdkEventScroll; typedef struct _GdkEventKey { GdkEventType type; GdkWindow *window; gint8 send_event; guint32 time; guint state; guint keyval; gint length; gchar *string; guint16 hardware_keycode; guint8 group; guint is_modifier:1; } GdkEventKey; typedef struct _GdkEventCrossing { GdkEventType type; GdkWindow *window; gint8 send_event; GdkWindow *subwindow; guint32 time; gdouble x, y; gdouble x_root, y_root; GdkCrossingMode mode; GdkNotifyType detail; gboolean focus; guint state; } GdkEventCrossing; typedef struct _GdkEventFocus { GdkEventType type; GdkWindow *window; gint8 send_event; gint16 in; } GdkEventFocus; typedef struct _GdkEventConfigure { GdkEventType type; GdkWindow *window; gint8 send_event; gint x, y; gint width; gint height; } GdkEventConfigure; typedef struct _GdkEventProperty { GdkEventType type; GdkWindow *window; gint8 send_event; GdkAtom atom; guint32 time; guint state; } GdkEventProperty; typedef struct _GdkEventSelection { GdkEventType type; GdkWindow *window; gint8 send_event; GdkAtom selection; GdkAtom target; GdkAtom property; guint32 time; GdkWindow *requestor; } GdkEventSelection; typedef struct _GdkEventOwnerChange { GdkEventType type; GdkWindow *window; gint8 send_event; GdkWindow *owner; GdkOwnerChange reason; GdkAtom selection; guint32 time; guint32 selection_time; } GdkEventOwnerChange; typedef struct _GdkEventProximity { GdkEventType type; GdkWindow *window; gint8 send_event; guint32 time; GdkDevice *device; } GdkEventProximity; typedef struct _GdkEventSetting { GdkEventType type; GdkWindow *window; gint8 send_event; GdkSettingAction action; char *name; } GdkEventSetting; typedef struct _GdkEventWindowState { GdkEventType type; GdkWindow *window; gint8 send_event; GdkWindowState changed_mask; GdkWindowState new_window_state; } GdkEventWindowState; typedef struct _GdkEventGrabBroken { GdkEventType type; GdkWindow *window; gint8 send_event; gboolean keyboard; gboolean implicit; GdkWindow *grab_window; } GdkEventGrabBroken; typedef struct _GdkEventDND { GdkEventType type; GdkWindow *window; gint8 send_event; GdkDragContext *context; guint32 time; gshort x_root, y_root; } GdkEventDND; typedef struct _GdkEventTouchpadSwipe { GdkEventType type; GdkWindow *window; gint8 send_event; gint8 phase; gint8 n_fingers; guint32 time; gdouble x, y; gdouble dx, dy; gdouble x_root, y_root; guint state; } GdkEventTouchpadSwipe; typedef struct _GdkEventTouchpadPinch { GdkEventType type; GdkWindow *window; gint8 send_event; gint8 phase; gint8 n_fingers; guint32 time; gdouble x, y; gdouble dx, dy; gdouble angle_delta; gdouble scale; gdouble x_root, y_root; guint state; } GdkEventTouchpadPinch; typedef union _GdkEvent { GdkEventType type; GdkEventAny any; GdkEventExpose expose; GdkEventVisibility visibility; GdkEventMotion motion; GdkEventButton button; GdkEventTouch touch; GdkEventScroll scroll; GdkEventKey key; GdkEventCrossing crossing; GdkEventFocus focus_change; GdkEventConfigure configure; GdkEventProperty property; GdkEventSelection selection; GdkEventOwnerChange owner_change; GdkEventProximity proximity; GdkEventDND dnd; GdkEventWindowState window_state; GdkEventSetting setting; GdkEventGrabBroken grab_broken; GdkEventTouchpadSwipe touchpad_swipe; GdkEventTouchpadPinch touchpad_pinch; } GdkEvent; typedef struct _GdkKeymapKey { guint keycode; gint group; gint level; } GdkKeymapKey; typedef struct _GtkTargetEntry { gchar *target; guint flags; guint info; } GtkTargetEntry; typedef void (*GtkClipboardGetFunc)(GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, gpointer user_data_or_owner); typedef void (*GtkClipboardClearFunc)(GtkClipboard *clipboard, gpointer user_data_or_owner); typedef void (*GtkMenuPositionFunc)(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data); // list of pointers to GTK+ functions extern GdkAtom (*gw_gdk_atom_intern)(const gchar *atom_name, gboolean only_if_exists); extern GdkAtom (*gw_gdk_atom_intern_static_string)(const gchar *atom_name); extern gchar * (*gw_gdk_atom_name)(GdkAtom atom); extern GdkDisplay * (*gw_gdk_display_get_default)(void); extern void (*gw_gdk_event_free)(GdkEvent *event); extern GdkEvent * (*gw_gdk_event_new)(GdkEventType type); extern gboolean (*gw_gdk_keymap_get_entries_for_keycode)(GdkKeymap *keymap, guint hardware_keycode, GdkKeymapKey **keys, guint **keyvals, gint *n_entries); extern GdkKeymap * (*gw_gdk_keymap_get_for_display)(GdkDisplay *display); extern GdkDisplay * (*gw_gdk_window_get_display)(GdkWindow *window); extern void (*gw_gdk_window_set_user_data)(GdkWindow *window, gpointer user_data); extern Display * (*gw_gdk_x11_display_get_xdisplay)(GdkDisplay *display); extern Window (*gw_gdk_x11_drawable_get_xid)(GdkWindow *window); extern GdkDisplay * (*gw_gdk_x11_lookup_xdisplay)(Display *xdisplay); extern GdkWindow * (*gw_gdk_x11_window_foreign_new_for_display)(GdkDisplay *display, Window window); extern GdkWindow * (*gw_gdk_x11_window_lookup_for_display)(GdkDisplay *display, Window window); extern GType (*gw_gtk_check_menu_item_get_type)(void); extern GtkWidget * (*gw_gtk_check_menu_item_new_with_label)(const gchar *label); extern void (*gw_gtk_check_menu_item_set_active)(GtkCheckMenuItem *check_menu_item, gboolean is_active); extern void (*gw_gtk_clipboard_clear)(GtkClipboard *clipboard); extern GtkClipboard * (*gw_gtk_clipboard_get)(GdkAtom selection); extern void (*gw_gtk_clipboard_set_can_store)(GtkClipboard *clipboard, const GtkTargetEntry *targets, gint n_targets); extern gboolean (*gw_gtk_clipboard_set_with_data)(GtkClipboard *clipboard, const GtkTargetEntry *targets, guint n_targets, GtkClipboardGetFunc get_func, GtkClipboardClearFunc clear_func, gpointer user_data); extern GtkSelectionData * (*gw_gtk_clipboard_wait_for_contents)(GtkClipboard *clipboard, GdkAtom target); extern gboolean (*gw_gtk_clipboard_wait_is_target_available)(GtkClipboard *clipboard, GdkAtom target); extern GtkWidget * (*gw_gtk_file_chooser_dialog_new)(const gchar *title, GtkWindow *parent, GtkFileChooserAction action, const gchar *first_button_text, ...); extern GSList * (*gw_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser); extern GType (*gw_gtk_file_chooser_get_type)(void); extern void (*gw_gtk_file_chooser_set_select_multiple)(GtkFileChooser *chooser, gboolean select_multiple); extern guint32 (*gw_gtk_get_current_event_time)(void); extern gboolean (*gw_gtk_im_context_filter_keypress)(GtkIMContext *context, GdkEventKey *event); extern void (*gw_gtk_im_context_focus_in)(GtkIMContext *context); extern void (*gw_gtk_im_context_focus_out)(GtkIMContext *context); extern void (*gw_gtk_im_context_get_preedit_string)(GtkIMContext *context, gchar **str, PangoAttrList **attrs, gint *cursor_pos); extern void (*gw_gtk_im_context_reset)(GtkIMContext *context); extern void (*gw_gtk_im_context_set_client_window)(GtkIMContext *context, GdkWindow *window); extern void (*gw_gtk_im_context_set_cursor_location)(GtkIMContext *context, const GdkRectangle *area); extern void (*gw_gtk_im_context_set_surrounding)(GtkIMContext *context, const gchar *text, gint len, gint cursor_index); extern GtkIMContext * (*gw_gtk_im_context_simple_new)(void); extern GtkIMContext * (*gw_gtk_im_multicontext_new)(void); extern GtkWidget * (*gw_gtk_label_new)(const gchar *str); extern GType (*gw_gtk_menu_get_type)(void); extern GType (*gw_gtk_menu_item_get_type)(void); extern GtkWidget * (*gw_gtk_menu_item_new_with_label)(const gchar *label); extern void (*gw_gtk_menu_item_set_submenu)(GtkMenuItem *menu_item, GtkWidget *submenu); extern GtkWidget * (*gw_gtk_menu_new)(void); extern void (*gw_gtk_menu_popup)(GtkMenu *menu, GtkWidget *parent_menu_shell, GtkWidget *parent_menu_item, GtkMenuPositionFunc func, gpointer data, guint button, guint32 activate_time); extern void (*gw_gtk_menu_shell_append)(GtkMenuShell *menu_shell, GtkWidget *child); extern GType (*gw_gtk_menu_shell_get_type)(void); extern void (*gw_gtk_selection_data_free)(GtkSelectionData *data); extern const guchar * (*gw_gtk_selection_data_get_data)(const GtkSelectionData *selection_data); extern gint (*gw_gtk_selection_data_get_length)(const GtkSelectionData *selection_data); extern void (*gw_gtk_selection_data_set)(GtkSelectionData *selection_data, GdkAtom type, gint format, const guchar *data, gint length); extern GtkWidget * (*gw_gtk_separator_menu_item_new)(void); extern void (*gw_gtk_widget_destroy)(GtkWidget *widget); extern GType (*gw_gtk_widget_get_type)(void); extern GdkWindow * (*gw_gtk_widget_get_window)(GtkWidget *widget); extern void (*gw_gtk_widget_realize)(GtkWidget *widget); extern void (*gw_gtk_widget_set_realized)(GtkWidget *widget, gboolean realized); extern void (*gw_gtk_widget_set_sensitive)(GtkWidget *widget, gboolean sensitive); extern void (*gw_gtk_widget_show)(GtkWidget *widget); // end of function pointers list void gtk_wrapper_initialize(void); int gw_major_version(void); int gw_minor_version(void); int gw_gtk_available(void); freshplayerplugin-0.3.9/src/header_parser.c000066400000000000000000000074231321746453100210410ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "header_parser.h" #include #include #include #include struct parsed_headers_s * hp_parse_headers(const char *headers) { struct parsed_headers_s *ph = calloc(1, sizeof(*ph)); const char *delimiter = "\r\n"; char *headers_copy, *saveptr, *part; unsigned int k; if (headers == NULL) { // all fields zeroed return ph; } // count headers, determine http code headers_copy = strdup(headers); ph->cnt = 0; ph->http_code = 200; part = strtok_r(headers_copy, delimiter, &saveptr); if (part) { int major = 0, minor = 0, code = 0, ret; ret = sscanf(part, "HTTP/%6d.%6d %6d", &major, &minor, &code); if (ret >= 3) { ph->http_code = code; } part = strtok_r(NULL, delimiter, &saveptr); } while (part) { ph->cnt ++; part = strtok_r(NULL, delimiter, &saveptr); } free(headers_copy); // parse headers to name and value headers_copy = strdup(headers); if (ph->cnt > 0) { ph->name = malloc(sizeof(char *) * ph->cnt); ph->value = malloc(sizeof(char *) * ph->cnt); } part = strtok_r(headers_copy, delimiter, &saveptr); // save status line if (part) { ph->status_line = strdup(part); part = strtok_r(NULL, delimiter, &saveptr); } // save headers k = 0; while (part && k < ph->cnt) { char *colon = strchr(part, ':'); if (colon) { *colon = 0; ph->name[k] = strdup(part); char *value_start = colon + 1; while (isspace(*value_start)) value_start ++; ph->value[k] = strdup(value_start); *colon = ':'; } else { ph->name[k] = strdup(part); ph->value[k] = strdup(""); } part = strtok_r(NULL, delimiter, &saveptr); k ++; } free(headers_copy); return ph; } void hp_free_parsed_headers(struct parsed_headers_s *ph) { for (unsigned int k = 0; k < ph->cnt; k ++) { free(ph->name[k]); free(ph->value[k]); } free(ph->name); free(ph->value); free(ph->status_line); free(ph); } const char * hp_get_header_value(struct parsed_headers_s *ph, const char *name) { for (unsigned int k = 0; k < ph->cnt; k ++) { if (strcasecmp(ph->name[k], name) == 0) return ph->value[k]; } return NULL; } int hp_header_exists(struct parsed_headers_s *ph, const char *name) { for (unsigned int k = 0; k < ph->cnt; k ++) { if (strcasecmp(ph->name[k], name) == 0) return 1; } return 0; } freshplayerplugin-0.3.9/src/header_parser.h000066400000000000000000000031421321746453100210400ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 struct parsed_headers_s { unsigned int cnt; char **name; char **value; char *status_line; unsigned int http_code; }; struct parsed_headers_s * hp_parse_headers(const char *headers); void hp_free_parsed_headers(struct parsed_headers_s *ph); const char * hp_get_header_value(struct parsed_headers_s *ph, const char *name); int hp_header_exists(struct parsed_headers_s *ph, const char *name); freshplayerplugin-0.3.9/src/keycodeconvert.c000066400000000000000000000222211321746453100212520ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "keycodeconvert.h" #include "keycodepp.h" #define XK_3270 #include #include #include int xkeycode_to_pp_keycode(int xkeycode) { switch (xkeycode) { case XK_Break: return VK_CANCEL; case XK_BackSpace: return VK_BACK; case XK_Tab: case XK_ISO_Left_Tab: return VK_TAB; case XK_Clear: return VK_CLEAR; case XK_Return: case XK_KP_Enter: case XK_ISO_Enter: case XK_3270_Enter: return VK_RETURN; case XK_Pause: return VK_PAUSE; case XK_Caps_Lock: return VK_CAPITAL; case XK_Kana_Lock: case XK_Kana_Shift: return VK_KANA; case XK_Hangul: return VK_HANGUL; case XK_Hangul_Hanja: return VK_HANJA; case XK_Kanji: return VK_KANJI; case XK_Escape: return VK_ESCAPE; case XK_space: return VK_SPACE; case XK_Page_Up: return VK_PRIOR; case XK_Page_Down: return VK_NEXT; case XK_End: return VK_END; case XK_Home: return VK_HOME; case XK_Left: return VK_LEFT; case XK_Up: return VK_UP; case XK_Right: return VK_RIGHT; case XK_Down: return VK_DOWN; case XK_Select: return VK_SELECT; case XK_Print: return VK_PRINT; case XK_Execute: return VK_EXECUTE; case XK_Sys_Req: return VK_SNAPSHOT; case XK_Insert: return VK_INSERT; case XK_Delete: return VK_DELETE; case XK_Help: return VK_HELP; // digits case XK_1: case XK_exclam: return '1'; case XK_2: case XK_at: return '2'; case XK_3: case XK_numbersign: return '3'; case XK_4: case XK_dollar: return '4'; case XK_5: case XK_percent: return '5'; case XK_6: case XK_asciicircum: return '6'; case XK_7: case XK_ampersand: return '7'; case XK_8: case XK_asterisk: return '8'; case XK_9: case XK_parenleft: return '9'; case XK_0: case XK_parenright: return '0'; // letters case XK_a: case XK_A: return 'A'; case XK_b: case XK_B: return 'B'; case XK_c: case XK_C: return 'C'; case XK_d: case XK_D: return 'D'; case XK_e: case XK_E: return 'E'; case XK_f: case XK_F: return 'F'; case XK_g: case XK_G: return 'G'; case XK_h: case XK_H: return 'H'; case XK_i: case XK_I: return 'I'; case XK_j: case XK_J: return 'J'; case XK_k: case XK_K: return 'K'; case XK_l: case XK_L: return 'L'; case XK_m: case XK_M: return 'M'; case XK_n: case XK_N: return 'N'; case XK_o: case XK_O: return 'O'; case XK_p: case XK_P: return 'P'; case XK_q: case XK_Q: return 'Q'; case XK_r: case XK_R: return 'R'; case XK_s: case XK_S: return 'S'; case XK_t: case XK_T: return 'T'; case XK_u: case XK_U: return 'U'; case XK_v: case XK_V: return 'V'; case XK_w: case XK_W: return 'W'; case XK_x: case XK_X: return 'X'; case XK_y: case XK_Y: return 'Y'; case XK_z: case XK_Z: return 'Z'; case XK_Super_L: return VK_LWIN; case XK_Super_R: return VK_RWIN; case XK_Menu: return VK_APPS; case XK_KP_0: return VK_NUMPAD0; case XK_KP_1: return VK_NUMPAD1; case XK_KP_2: return VK_NUMPAD2; case XK_KP_3: return VK_NUMPAD3; case XK_KP_4: return VK_NUMPAD4; case XK_KP_5: return VK_NUMPAD5; case XK_KP_6: return VK_NUMPAD6; case XK_KP_7: return VK_NUMPAD7; case XK_KP_8: return VK_NUMPAD8; case XK_KP_9: return VK_NUMPAD9; case XK_KP_Multiply: return VK_MULTIPLY; case XK_KP_Add: return VK_ADD; case XK_KP_Separator: return VK_SEPARATOR; case XK_KP_Subtract: return VK_SUBTRACT; case XK_KP_Decimal: return VK_DECIMAL; case XK_KP_Divide: return VK_DIVIDE; case XK_F1: return VK_F1; case XK_F2: return VK_F2; case XK_F3: return VK_F3; case XK_F4: return VK_F4; case XK_F5: return VK_F5; case XK_F6: return VK_F6; case XK_F7: return VK_F7; case XK_F8: return VK_F8; case XK_F9: return VK_F9; case XK_F10: return VK_F10; case XK_F11: return VK_F11; case XK_F12: return VK_F12; case XK_F13: return VK_F13; case XK_F14: return VK_F14; case XK_F15: return VK_F15; case XK_F16: return VK_F16; case XK_F17: return VK_F17; case XK_F18: return VK_F18; case XK_F19: return VK_F19; case XK_F20: return VK_F20; case XK_F21: return VK_F21; case XK_F22: return VK_F22; case XK_F23: return VK_F23; case XK_F24: return VK_F24; case XK_Num_Lock: return VK_NUMLOCK; case XK_Scroll_Lock: return VK_SCROLL; case XK_Shift_L: case XK_Shift_R: return VK_SHIFT; case XK_Control_L: case XK_Control_R: return VK_CONTROL; case XK_Meta_L: case XK_Meta_R: case XK_Alt_L: case XK_Alt_R: return VK_MENU; case XF86XK_Back: return VK_BROWSER_BACK; case XF86XK_Forward: return VK_BROWSER_FORWARD; case XF86XK_Refresh: return VK_BROWSER_REFRESH; case XF86XK_Stop: return VK_BROWSER_STOP; case XF86XK_Search: return VK_BROWSER_SEARCH; case XF86XK_Favorites: return VK_BROWSER_FAVORITES; case XF86XK_HomePage: return VK_BROWSER_HOME; case XF86XK_AudioMute: return VK_VOLUME_MUTE; case XF86XK_AudioLowerVolume: return VK_VOLUME_DOWN; case XF86XK_AudioRaiseVolume: return VK_VOLUME_UP; case XF86XK_AudioNext: return VK_MEDIA_NEXT_TRACK; case XF86XK_AudioPrev: return VK_MEDIA_PREV_TRACK; case XF86XK_AudioStop: return VK_MEDIA_STOP; case XF86XK_AudioPlay: return VK_MEDIA_PLAY_PAUSE; case XF86XK_Mail: return VK_LAUNCH_MAIL; case XF86XK_LaunchA: return VK_LAUNCH_APP1; case XF86XK_LaunchB: return VK_LAUNCH_APP2; case XK_semicolon: case XK_colon: return VK_OEM_1; case XK_plus: case XK_equal: return VK_OEM_PLUS; case XK_comma: case XK_less: return VK_OEM_COMMA; case XK_minus: case XK_underscore: return VK_OEM_MINUS; case XK_period: case XK_greater: return VK_OEM_PERIOD; case XK_slash: case XK_question: return VK_OEM_2; case XK_quoteleft: case XK_asciitilde: return VK_OEM_3; case XK_bracketleft: case XK_braceleft: return VK_OEM_4; case XK_backslash: case XK_bar: return VK_OEM_5; case XK_bracketright: case XK_braceright: return VK_OEM_6; case XK_quoteright: case XK_quotedbl: return VK_OEM_7; case XK_3270_Attn: return VK_ATTN; case XK_3270_CursorSelect: return VK_CRSEL; case XK_3270_ExSelect: return VK_EXSEL; case XK_3270_EraseEOF: return VK_EREOF; case XK_3270_Play: return VK_PLAY; case XK_3270_PA1: return VK_PA1; default: return 0; } } int get_left_right_pp_flag(int xkeycode) { switch (xkeycode) { case XK_Shift_L: case XK_Control_L: case XK_Meta_L: case XK_Alt_L: case XK_Super_L: return PP_INPUTEVENT_MODIFIER_ISLEFT; case XK_Shift_R: case XK_Control_R: case XK_Meta_R: case XK_Alt_R: case XK_Super_R: return PP_INPUTEVENT_MODIFIER_ISRIGHT; default: return 0; } } freshplayerplugin-0.3.9/src/keycodeconvert.h000066400000000000000000000023671321746453100212700ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 int xkeycode_to_pp_keycode(int xkeycode); int get_left_right_pp_flag(int xkeycode); freshplayerplugin-0.3.9/src/keycodepp.h000066400000000000000000000162271321746453100202270ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #define VK_LBUTTON 0x01 // Left mouse button #define VK_RBUTTON 0x02 // Right mouse button #define VK_CANCEL 0x03 // Control-break processing #define VK_MBUTTON 0x04 // Middle mouse button (three-button mouse) #define VK_XBUTTON1 0x05 // X1 mouse button #define VK_XBUTTON2 0x06 // X2 mouse button #define VK_BACK 0x08 // BACKSPACE key #define VK_TAB 0x09 // TAB key #define VK_CLEAR 0x0C // CLEAR key #define VK_RETURN 0x0D // ENTER key #define VK_SHIFT 0x10 // SHIFT key #define VK_CONTROL 0x11 // CTRL key #define VK_MENU 0x12 // ALT key #define VK_PAUSE 0x13 // PAUSE key #define VK_CAPITAL 0x14 // CAPS LOCK key #define VK_KANA 0x15 // IME Kana mode #define VK_HANGUEL 0x15 // IME Hanguel mode (maintained for compatibility; use VK_HANGUL) #define VK_HANGUL 0x15 // IME Hangul mode #define VK_JUNJA 0x17 // IME Junja mode #define VK_FINAL 0x18 // IME final mode #define VK_HANJA 0x19 // IME Hanja mode #define VK_KANJI 0x19 // IME Kanji mode #define VK_ESCAPE 0x1B // ESC key #define VK_CONVERT 0x1C // IME convert #define VK_NONCONVERT 0x1D // IME nonconvert #define VK_ACCEPT 0x1E // IME accept #define VK_MODECHANGE 0x1F // IME mode change request #define VK_SPACE 0x20 // SPACEBAR #define VK_PRIOR 0x21 // PAGE UP key #define VK_NEXT 0x22 // PAGE DOWN key #define VK_END 0x23 // END key #define VK_HOME 0x24 // HOME key #define VK_LEFT 0x25 // LEFT ARROW key #define VK_UP 0x26 // UP ARROW key #define VK_RIGHT 0x27 // RIGHT ARROW key #define VK_DOWN 0x28 // DOWN ARROW key #define VK_SELECT 0x29 // SELECT key #define VK_PRINT 0x2A // PRINT key #define VK_EXECUTE 0x2B // EXECUTE key #define VK_SNAPSHOT 0x2C // PRINT SCREEN key #define VK_INSERT 0x2D // INS key #define VK_DELETE 0x2E // DEL key #define VK_HELP 0x2F // HELP key // 0x30 0 // 0x31 1 // 0x32 2 // 0x33 3 // 0x34 4 // 0x35 5 // 0x36 6 // 0x37 7 // 0x38 8 // 0x39 9 // 0x41 A // 0x42 B // 0x43 C // 0x44 D // 0x45 E // 0x46 F // 0x47 G // 0x48 H // 0x49 I // 0x4A J // 0x4B K // 0x4C L // 0x4D M // 0x4E N // 0x4F O // 0x50 P // 0x51 Q // 0x52 R // 0x53 S // 0x54 T // 0x55 U // 0x56 V // 0x57 W // 0x58 X // 0x59 Y // 0x5A Z #define VK_LWIN 0x5B #define VK_RWIN 0x5C #define VK_APPS 0x5D #define VK_SLEEP 0x5F #define VK_NUMPAD0 0x60 #define VK_NUMPAD1 0x61 #define VK_NUMPAD2 0x62 #define VK_NUMPAD3 0x63 #define VK_NUMPAD4 0x64 #define VK_NUMPAD5 0x65 #define VK_NUMPAD6 0x66 #define VK_NUMPAD7 0x67 #define VK_NUMPAD8 0x68 #define VK_NUMPAD9 0x69 #define VK_MULTIPLY 0x6A #define VK_ADD 0x6B #define VK_SEPARATOR 0x6C #define VK_SUBTRACT 0x6D #define VK_DECIMAL 0x6E #define VK_DIVIDE 0x6F #define VK_F1 0x70 #define VK_F2 0x71 #define VK_F3 0x72 #define VK_F4 0x73 #define VK_F5 0x74 #define VK_F6 0x75 #define VK_F7 0x76 #define VK_F8 0x77 #define VK_F9 0x78 #define VK_F10 0x79 #define VK_F11 0x7A #define VK_F12 0x7B #define VK_F13 0x7C #define VK_F14 0x7D #define VK_F15 0x7E #define VK_F16 0x7F #define VK_F17 0x80 #define VK_F18 0x81 #define VK_F19 0x82 #define VK_F20 0x83 #define VK_F21 0x84 #define VK_F22 0x85 #define VK_F23 0x86 #define VK_F24 0x87 #define VK_NUMLOCK 0x90 #define VK_SCROLL 0x91 #define VK_LSHIFT 0xA0 #define VK_RSHIFT 0xA1 #define VK_LCONTROL 0xA2 #define VK_RCONTROL 0xA3 #define VK_LMENU 0xA4 #define VK_RMENU 0xA5 #define VK_BROWSER_BACK 0xA6 #define VK_BROWSER_FORWARD 0xA7 #define VK_BROWSER_REFRESH 0xA8 #define VK_BROWSER_STOP 0xA9 #define VK_BROWSER_SEARCH 0xAA #define VK_BROWSER_FAVORITES 0xAB #define VK_BROWSER_HOME 0xAC #define VK_VOLUME_MUTE 0xAD #define VK_VOLUME_DOWN 0xAE #define VK_VOLUME_UP 0xAF #define VK_MEDIA_NEXT_TRACK 0xB0 #define VK_MEDIA_PREV_TRACK 0xB1 #define VK_MEDIA_STOP 0xB2 #define VK_MEDIA_PLAY_PAUSE 0xB3 #define VK_LAUNCH_MAIL 0xB4 #define VK_LAUNCH_MEDIA_SELECT 0xB5 #define VK_LAUNCH_APP1 0xB6 #define VK_LAUNCH_APP2 0xB7 #define VK_OEM_1 0xBA // ';:' #define VK_OEM_PLUS 0xBB // '+' #define VK_OEM_COMMA 0xBC // ',' #define VK_OEM_MINUS 0xBD // '-' #define VK_OEM_PERIOD 0xBE // '.' #define VK_OEM_2 0xBF // '/?' #define VK_OEM_3 0xC0 // '`~' #define VK_OEM_4 0xDB // '[{' #define VK_OEM_5 0xDC // '\|' #define VK_OEM_6 0xDD // ']}' #define VK_OEM_7 0xDE // 'single-quote/double-quote' key #define VK_OEM_8 0xDF // #define VK_OEM_102 0xE2 // #define VK_PROCESSKEY 0xE5 // IME PROCESS key #define VK_PACKET 0xE7 // #define VK_ATTN 0xF6 // Attn key #define VK_CRSEL 0xF7 // CrSel key #define VK_EXSEL 0xF8 // ExSel key #define VK_EREOF 0xF9 // Erase EOF key #define VK_PLAY 0xFA // Play key #define VK_ZOOM 0xFB // Zoom key #define VK_NONAME 0xFC // Reserved #define VK_PA1 0xFD // PA1 key #define VK_OEM_CLEAR 0xFE // Clear key freshplayerplugin-0.3.9/src/link_check.c000066400000000000000000000023371321746453100203260ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 int main(void) { printf("pass\n"); return 0; } freshplayerplugin-0.3.9/src/main_thread.c000066400000000000000000000042211321746453100205010ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "main_thread.h" #include "ppb_instance.h" #include "ppb_message_loop.h" #include "trace_core.h" #include "utils.h" #include #include #include #include static void wait_on_barrier(void *user_data, int32_t result) { pthread_barrier_t *barrier = user_data; pthread_barrier_wait(barrier); } void * fresh_wrapper_main_thread(void *p) { struct pp_instance_s *pp_i = p; PP_Resource message_loop; message_loop = ppb_message_loop_create(pp_i->id); if (!message_loop) { trace_error("%s, can't create message loop\n", __func__); return NULL; } ppb_message_loop_attach_to_current_thread(message_loop); ppb_message_loop_proclaim_this_thread_main(); // wait for barrier inside a task to ensure loop is running ppb_message_loop_post_work(message_loop, PP_MakeCCB(wait_on_barrier, &pp_i->main_thread_barrier), 0); ppb_message_loop_run(message_loop); return NULL; } freshplayerplugin-0.3.9/src/main_thread.h000066400000000000000000000023151321746453100205100ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 void * fresh_wrapper_main_thread(void *p); freshplayerplugin-0.3.9/src/n2p_proxy_class.c000066400000000000000000000361121321746453100213570ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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. */ /* * proxy class which wraps around NPObject while providing PP_Var object */ #include "n2p_proxy_class.h" #include "ppb_core.h" #include "ppb_message_loop.h" #include "ppb_var.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include "utils.h" #include #include #include #include #include #include #include #include #include #include #include #include struct has_property_param_s { struct PP_Var name; struct PP_Var *exception; void *object; bool result; PP_Resource m_loop; int depth; }; static void n2p_has_property_ptac(void *param) { struct has_property_param_s *p = param; const char *s_name = ppb_var_var_to_utf8(p->name, NULL); NPIdentifier identifier = npn.getstringidentifier(s_name); NPP npp = tables_get_npobj_npp_mapping(p->object); if (npp) p->result = npn.hasproperty(npp, p->object, identifier); else p->result = false; ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void n2p_has_property_comt(void *user_data, int32_t result) { struct has_property_param_s *p = user_data; ppb_core_call_on_browser_thread(0, n2p_has_property_ptac, p); } static bool n2p_has_property(void *object, struct PP_Var name, struct PP_Var *exception) { if (name.type != PP_VARTYPE_STRING) { trace_error("%s, name is not a string\n", __func__); // TODO: fill exception return false; } struct has_property_param_s *p = g_slice_alloc(sizeof(*p)); p->object = object; p->name = name; p->exception = exception; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(n2p_has_property_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); bool result = p->result; g_slice_free1(sizeof(*p), p); return result; } static bool n2p_has_method(void *object, struct PP_Var name, struct PP_Var *exception) { return false; } struct get_property_param_s { void *object; struct PP_Var name; struct PP_Var *exception; struct PP_Var result; PP_Resource m_loop; int depth; }; static void n2p_get_property_ptac(void *param) { struct get_property_param_s *p = param; const char *s_name = ppb_var_var_to_utf8(p->name, NULL); NPIdentifier identifier = npn.getstringidentifier(s_name); NPVariant np_value; NPP npp = tables_get_npobj_npp_mapping(p->object); if (npp && npn.getproperty(npp, p->object, identifier, &np_value)) { struct PP_Var var = np_variant_to_pp_var(np_value); if (np_value.type == NPVariantType_Object) tables_add_npobj_npp_mapping(np_value.value.objectValue, npp); else npn.releasevariantvalue(&np_value); p->result = var; } else { p->result = PP_MakeUndefined(); } ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void n2p_get_property_comt(void *user_data, int32_t result) { struct get_property_param_s *p = user_data; ppb_core_call_on_browser_thread(0, n2p_get_property_ptac, p); } static struct PP_Var n2p_get_property(void *object, struct PP_Var name, struct PP_Var *exception) { if (name.type != PP_VARTYPE_STRING) { trace_error("%s, name is not a string\n", __func__); // TODO: fill exception return PP_MakeUndefined(); } struct get_property_param_s *p = g_slice_alloc(sizeof(*p)); p->object = object; p->name = name; p->exception = exception; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(n2p_get_property_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); struct PP_Var result = p->result; g_slice_free1(sizeof(*p), p); return result; } static void n2p_get_all_property_names(void *object, uint32_t *property_count, struct PP_Var **properties, struct PP_Var *exception) { } static void n2p_set_property(void *object, struct PP_Var name, struct PP_Var value, struct PP_Var *exception) { } static void n2p_remove_property(void *object, struct PP_Var name, struct PP_Var *exception) { } struct call_param_s { void *object; struct PP_Var method_name; uint32_t argc; struct PP_Var *argv; struct PP_Var *exception; struct PP_Var result; PP_Resource m_loop; int depth; }; static void n2p_call_ptac(void *param) { struct call_param_s *p = param; const char *s_method_name = ppb_var_var_to_utf8(p->method_name, NULL); NPIdentifier np_method_name = npn.getstringidentifier(s_method_name); NPP npp = tables_get_npobj_npp_mapping(p->object); NPVariant *np_args = malloc(p->argc * sizeof(NPVariant)); for (uint32_t k = 0; k < p->argc; k ++) np_args[k] = pp_var_to_np_variant(p->argv[k]); NPVariant np_result; bool res = npp ? npn.invoke(npp, p->object, np_method_name, np_args, p->argc, &np_result) : FALSE; for (uint32_t k = 0; k < p->argc; k ++) npn.releasevariantvalue(&np_args[k]); free(np_args); if (res) { struct PP_Var var = np_variant_to_pp_var(np_result); if (np_result.type == NPVariantType_Object) tables_add_npobj_npp_mapping(np_result.value.objectValue, npp); else npn.releasevariantvalue(&np_result); p->result = var; } else { trace_error("%s, NPN_Invoke failed (or there were no npp)\n", __func__); p->result = PP_MakeUndefined(); } ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void n2p_call_comt(void *user_data, int32_t result) { struct call_param_s *p = user_data; ppb_core_call_on_browser_thread(0, n2p_call_ptac, p); } static struct PP_Var n2p_call(void *object, struct PP_Var method_name, uint32_t argc, struct PP_Var *argv, struct PP_Var *exception) { if (method_name.type != PP_VARTYPE_STRING) { trace_error("%s, method_name is not a string\n", __func__); // TODO: fill exception return PP_MakeUndefined(); } struct call_param_s *p = g_slice_alloc(sizeof(*p)); p->object = object; p->method_name = method_name; p->argc = argc; p->argv = argv; p->exception = exception; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(n2p_call_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); struct PP_Var result = p->result; g_slice_free1(sizeof(*p), p); return result; } struct construct_param_s { void *object; uint32_t argc; struct PP_Var *argv; struct PP_Var *exception; struct PP_Var result; PP_Resource m_loop; int depth; }; static void n2p_construct_ptac(void *param) { struct construct_param_s *p = param; NPP npp = tables_get_npobj_npp_mapping(p->object); NPVariant *np_args = malloc(p->argc * sizeof(NPVariant)); for (uint32_t k = 0; k < p->argc; k ++) np_args[k] = pp_var_to_np_variant(p->argv[k]); NPVariant np_result; bool res = npp ? npn.construct(npp, p->object, np_args, p->argc, &np_result) : FALSE; for (uint32_t k = 0; k < p->argc; k ++) npn.releasevariantvalue(&np_args[k]); free(np_args); if (res) { struct PP_Var var = np_variant_to_pp_var(np_result); if (np_result.type == NPVariantType_Object) tables_add_npobj_npp_mapping(np_result.value.objectValue, npp); else npn.releasevariantvalue(&np_result); p->result = var; } else { p->result = PP_MakeUndefined(); } ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void n2p_construct_comt(void *user_data, int32_t result) { struct construct_param_s *p = user_data; ppb_core_call_on_browser_thread(0, n2p_construct_ptac, p); } static struct PP_Var n2p_construct(void *object, uint32_t argc, struct PP_Var *argv, struct PP_Var *exception) { struct construct_param_s *p = g_slice_alloc(sizeof(*p)); p->object = object; p->argc = argc; p->argv = argv; p->exception = exception; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(n2p_construct_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); struct PP_Var result = p->result; g_slice_free1(sizeof(*p), p); return result; } struct deallocate_param_s { void *object; PP_Resource m_loop; int depth; }; static void n2p_deallocate_ptac(void *param) { struct deallocate_param_s *p = param; NPObject *np_object = p->object; uint32_t ref_cnt = np_object->referenceCount; npn.releaseobject(p->object); if (ref_cnt <= 1) tables_remove_npobj_npp_mapping(p->object); ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void n2p_deallocate_comt(void *user_data, int32_t result) { struct deallocate_param_s *p = user_data; ppb_core_call_on_browser_thread(0, n2p_deallocate_ptac, p); } static void n2p_deallocate(void *object) { if (!object) { trace_warning("%s, object == NULL\n", __func__); return; } struct deallocate_param_s *p = g_slice_alloc(sizeof(*p)); p->object = object; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(n2p_deallocate_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); g_slice_free1(sizeof(*p), p); } // trace wrappers TRACE_WRAPPER bool trace_n2p_has_property(void *object, struct PP_Var name, struct PP_Var *exception) { char *s_name = trace_var_as_string(name); trace_info("[CLS] {full} %s object=%p, name=%s\n", __func__+6, object, s_name); g_free(s_name); return n2p_has_property(object, name, exception); } TRACE_WRAPPER bool trace_n2p_has_method(void *object, struct PP_Var name, struct PP_Var *exception) { char *s_name = trace_var_as_string(name); trace_info("[CLS] {zilch} %s object=%p, name=%s\n", __func__+6, object, s_name); g_free(s_name); return n2p_has_method(object, name, exception); } TRACE_WRAPPER struct PP_Var trace_n2p_get_property(void *object, struct PP_Var name, struct PP_Var *exception) { char *s_name = trace_var_as_string(name); trace_info("[CLS] {full} %s object=%p, name=%s\n", __func__+6, object, s_name); g_free(s_name); return n2p_get_property(object, name, exception); } TRACE_WRAPPER void trace_n2p_get_all_property_names(void *object, uint32_t *property_count, struct PP_Var **properties, struct PP_Var *exception) { trace_info("[CLS] {zilch} %s object=%p\n", __func__+6, object); n2p_get_all_property_names(object, property_count, properties, exception); } TRACE_WRAPPER void trace_n2p_set_property(void *object, struct PP_Var name, struct PP_Var value, struct PP_Var *exception) { char *s_name = trace_var_as_string(name); char *s_value = trace_var_as_string(value); trace_info("[CLS] {zilch} %s object=%p, name=%s, value=%s\n", __func__+6, object, s_name, s_value); g_free(s_name); g_free(s_value); n2p_set_property(object, name, value, exception); } TRACE_WRAPPER void trace_n2p_remove_property(void *object, struct PP_Var name, struct PP_Var *exception) { char *s_name = trace_var_as_string(name); trace_info("[CLS] {zilch} %s object=%p, name=%s\n", __func__+6, object, s_name); g_free(s_name); n2p_remove_property(object, name, exception); } TRACE_WRAPPER struct PP_Var trace_n2p_call(void *object, struct PP_Var method_name, uint32_t argc, struct PP_Var *argv, struct PP_Var *exception) { char *s_method_name = trace_var_as_string(method_name); trace_info("[CLS] {full} %s object=%p, method_name=%s, argc=%u, argv=%p\n", __func__+6, object, s_method_name, argc, argv); g_free(s_method_name); return n2p_call(object, method_name, argc, argv, exception); } TRACE_WRAPPER struct PP_Var trace_n2p_construct(void *object, uint32_t argc, struct PP_Var *argv, struct PP_Var *exception) { trace_info("[CLS] {full} %s object=%p, argc=%u, argv=%p\n", __func__+6, object, argc, argv); return n2p_construct(object, argc, argv, exception); } TRACE_WRAPPER void trace_n2p_deallocate(void *object) { trace_info("[CLS] {full} %s object=%p\n", __func__+6, object); n2p_deallocate(object); } const struct PPP_Class_Deprecated n2p_proxy_class = { .HasProperty = TWRAPF(n2p_has_property), .HasMethod = TWRAPZ(n2p_has_method), .GetProperty = TWRAPF(n2p_get_property), .GetAllPropertyNames = TWRAPZ(n2p_get_all_property_names), .SetProperty = TWRAPZ(n2p_set_property), .RemoveProperty = TWRAPZ(n2p_remove_property), .Call = TWRAPF(n2p_call), .Construct = TWRAPF(n2p_construct), .Deallocate = TWRAPF(n2p_deallocate), }; freshplayerplugin-0.3.9/src/n2p_proxy_class.h000066400000000000000000000024131321746453100213610ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include extern const struct PPP_Class_Deprecated n2p_proxy_class; freshplayerplugin-0.3.9/src/np_asynccall.c000066400000000000000000000050641321746453100207020ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "np_asynccall.h" #include "trace_core.h" #include #include #include static GMainContext *g_main_context_of_main_thread; int np_asynccall_initialize(void) { g_main_context_of_main_thread = g_main_context_default(); if (!g_main_context_of_main_thread) return 1; return 0; } struct np_asynccall_callback_proxy_params { void (*func)(void *); void *user_data; }; static gboolean np_asynccall_callback_proxy(void *user_data) { struct np_asynccall_callback_proxy_params *p = user_data; p->func(p->user_data); g_slice_free(struct np_asynccall_callback_proxy_params, p); // This is a oneshot operation, source should be removed. return FALSE; } void np_asynccall_call(NPP instance, void (*func)(void *), void *user_data) { GSource *source = g_idle_source_new(); if (!source) { trace_error("%s, can't create GSource\n", __func__); return; } struct np_asynccall_callback_proxy_params *p = g_slice_alloc0(sizeof(*p)); if (!p) { g_source_unref(source); trace_error("%s, can't allocate memory\n", __func__); return; } p->func = func; p->user_data = user_data; g_source_set_priority(source, G_PRIORITY_DEFAULT); g_source_set_callback(source, np_asynccall_callback_proxy, p, NULL); g_source_attach(source, g_main_context_of_main_thread); g_source_unref(source); } freshplayerplugin-0.3.9/src/np_asynccall.h000066400000000000000000000033361321746453100207070ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include // Emulation of NPN_PluginThreadAsyncCall. // // There are versions of Firefox, which have NPN_PluginThreadAsyncCall removed. // Since it's required by FreshPlayerPlugin, it needs to be emulated. // Current implementation uses the fact the browser runs GLib's mainloop. /// Initialize plugin-thread-async-call emulation. /// /// This call must be performed from plugin's main thread. int np_asynccall_initialize(void); /// Schedule |func| on the plugin's main thread. void np_asynccall_call(NPP instance, void (*func)(void *), void *userData); freshplayerplugin-0.3.9/src/np_entry.c000066400000000000000000000336221321746453100200730ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "compat.h" #include "config.h" #include "config_priv.h" #include "gtk_wrapper.h" #include "main_thread.h" #include "np_asynccall.h" #include "pp_interface.h" #include "ppb_core.h" #include "ppb_instance.h" #include "ppb_message_loop.h" #include "reverse_constant.h" #include "tables.h" #include "trace_core.h" #include "utils.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void *module_dl_handler; static struct pp_instance_s *aux_instance = NULL; static int np_initialize_was_called = 0; struct call_plugin_init_module_param_s { PP_Resource m_loop; int depth; int32_t (*ppp_initialize_module)(PP_Module module_id, PPB_GetInterface get_browser_interface); int result; }; static void call_plugin_init_module_comt(void *user_data, int32_t result) { struct call_plugin_init_module_param_s *p = user_data; // TODO: make module ids distinct // p->ppp_initialize_module is always non-NULL p->result = p->ppp_initialize_module(42, ppb_get_interface); ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void call_plugin_init_module_prepare_comt(void *user_data, int32_t result) { ppb_core_trampoline_to_main_thread(PP_MakeCCB(call_plugin_init_module_comt, user_data), PP_OK, __func__); } static int call_plugin_init_module(void) { int32_t (*ppp_initialize_module)(PP_Module module_id, PPB_GetInterface get_browser_interface); if (!module_dl_handler) return 0; ppp_initialize_module = dlsym(module_dl_handler, "PPP_InitializeModule"); if (!ppp_initialize_module) return 0; struct call_plugin_init_module_param_s *p = g_slice_alloc(sizeof(*p)); p->m_loop = ppb_message_loop_get_for_browser_thread(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; p->ppp_initialize_module = ppp_initialize_module; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(call_plugin_init_module_prepare_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); int res = p->result; g_slice_free1(sizeof(*p), p); return res; } static int probe_ppp_module(void) { fpp_config_initialize(); if (!fpp_config_get_plugin_path()) { config.quirks.plugin_missing = 1; trace_error("%s, can't find %s\n", __func__, fpp_config_get_plugin_file_name()); return 1; } return 0; } static uintptr_t load_ppp_module() { if (module_dl_handler) { // already loaded return 0; } // ensure we have a module name probe_ppp_module(); if (!fpp_config_get_plugin_path()) goto err; module_dl_handler = dlopen(fpp_config_get_plugin_path(), RTLD_LAZY); if (!module_dl_handler) { trace_info_f("%s, can't open %s\n", __func__, fpp_config_get_plugin_path()); goto err; } int32_t (*ppp_initialize_module)(PP_Module module_id, PPB_GetInterface get_browser_interface); ppp_initialize_module = dlsym(module_dl_handler, "PPP_InitializeModule"); ppp_get_interface = dlsym(module_dl_handler, "PPP_GetInterface"); if (!ppp_initialize_module || !ppp_get_interface) { trace_error("%s, one of required PPP_* is missing\n", __func__); if (module_dl_handler) dlclose(module_dl_handler); module_dl_handler = NULL; goto err; } // allocate auxiliary instance if (!aux_instance) { aux_instance = calloc(1, sizeof(*aux_instance)); if (!aux_instance) goto err; aux_instance->id = tables_generate_new_pp_instance_id(); tables_add_pp_instance(aux_instance->id, aux_instance); } // allocate message loop for browser thread if (ppb_message_loop_get_current() == 0) { PP_Resource message_loop = ppb_message_loop_create(aux_instance->id); ppb_message_loop_attach_to_current_thread(message_loop); ppb_message_loop_proclaim_this_thread_browser(); } // allocate message loop for plugin thread (main thread) if (ppb_message_loop_get_for_main_thread() == 0) { pthread_barrier_init(&aux_instance->main_thread_barrier, NULL, 2); pthread_create(&aux_instance->main_thread, NULL, fresh_wrapper_main_thread, aux_instance); pthread_detach(aux_instance->main_thread); pthread_barrier_wait(&aux_instance->main_thread_barrier); pthread_barrier_destroy(&aux_instance->main_thread_barrier); } return 0; err: config.quirks.plugin_missing = 1; return 1; } struct call_plugin_shutdown_module_param_s { PP_Resource m_loop; int depth; void (*ppp_shutdown_module)(void); }; static void call_plugin_shutdown_module_comt(void *user_data, int32_t result) { struct call_plugin_shutdown_module_param_s *p = user_data; p->ppp_shutdown_module(); // p->ppp_shutdown_module is always non-NULL ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void call_plugin_shutdown_module_prepare_comt(void *user_data, int32_t result) { ppb_core_trampoline_to_main_thread(PP_MakeCCB(call_plugin_shutdown_module_comt, user_data), PP_OK, __func__); } static void call_plugin_shutdown_module(void) { if (!module_dl_handler) return; void (*ppp_shutdown_module)(void); ppp_shutdown_module = dlsym(module_dl_handler, "PPP_ShutdownModule"); if (!ppp_shutdown_module) return; struct call_plugin_shutdown_module_param_s *p = g_slice_alloc(sizeof(*p)); p->m_loop = ppb_message_loop_get_for_browser_thread(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; p->ppp_shutdown_module = ppp_shutdown_module; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(call_plugin_shutdown_module_prepare_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); g_slice_free1(sizeof(*p), p); } static void unload_ppp_module(void) { // call module shutdown handler if exists call_plugin_shutdown_module(); if (module_dl_handler) dlclose(module_dl_handler); module_dl_handler = NULL; fpp_config_destroy(); } const char * NP_GetMIMEDescription(void) { trace_info_f("[NP] %s\n", __func__); return fpp_config_get_plugin_mime_type(); } char * NP_GetPluginVersion(void) { trace_info_f("[NP] %s\n", __func__); probe_ppp_module(); return (char *)fpp_config_get_plugin_version(); } NPError NP_GetValue(void *instance, NPPVariable variable, void *value) { trace_info_f("[NP] %s instance=%p, variable=%s, value=%p\n", __func__, instance, reverse_npp_variable(variable), value); probe_ppp_module(); switch (variable) { case NPPVpluginNameString: *(const char **)value = fpp_config_get_plugin_name(); break; case NPPVpluginDescriptionString: *(const char **)value = fpp_config_get_plugin_descr(); break; default: trace_info_z(" not implemented variable %d\n", variable); } return NPERR_NO_ERROR; } static int x_error_handler(Display *dpy, XErrorEvent *ee) { trace_error("[NP] caught Xlib error %d\n", ee->error_code); return 0; } static int x_io_error_hanlder(Display *dpy) { // IO errors can't be ignored, they always terminate program. // Let's crash here to get core file! trace_error("[NP] got Xlib IO error\n"); abort(); return 0; } static void call_gdb_signal_handler(int sig, siginfo_t *si, void *p) { static char cmd[4096]; pid_t pid = getpid(); time_t now = time(NULL); // ask gdb to debug this process snprintf(cmd, sizeof(cmd), "gdb --pid %d" " -ex 'set logging file /tmp/freshwrapper-backtrace-%d-%d.txt'" " -ex 'set logging on'" " -ex 'set pagination off'" " -ex 'echo === backtrace triggered by signal %d ===\\n'" " -ex 'echo === current thread ===\\n'" " -ex bt" " -ex 'echo === thread list ===\\n'" " -ex 'info threads'" " -ex 'echo === all threads ===\\n'" " -ex 'thread apply all bt full'" " -ex 'set confirm off'" " -ex 'quit'", (int)pid, (int)now, (int)pid, sig); // call gdb int ret = system(cmd); if (ret != 0) printf("gdb return status: %d\n", ret); exit(sig); } static void setup_sig_handlers(void) { int s[] = { SIGSEGV, SIGILL, SIGABRT }; struct sigaction sa = {}; sa.sa_flags = SA_SIGINFO; sigemptyset(&sa.sa_mask); for (uintptr_t k = 0; k < sizeof(s) / sizeof(s[0]); k ++) sigaddset(&sa.sa_mask, s[k]); sa.sa_sigaction = call_gdb_signal_handler; for (uintptr_t k = 0; k < sizeof(s) / sizeof(s[0]); k ++) { struct sigaction prev; // ensure there were no handlers before if (sigaction(s[k], NULL, &prev) != 0) continue; if ((prev.sa_flags & SA_SIGINFO) && prev.sa_sigaction != NULL) continue; if (!(prev.sa_flags & SA_SIGINFO) && prev.sa_handler != NULL) continue; // install own handler if (sigaction(s[k], &sa, NULL) != 0) trace_error("%s, can't set signal %d handler\n", __func__, s[k]); } } NPError NP_Initialize(NPNetscapeFuncs *aNPNFuncs, NPPluginFuncs *aNPPFuncs) { trace_info_f("[NP] %s aNPNFuncs=%p, aNPPFuncs=%p, browser API version = %u\n", __func__, aNPNFuncs, aNPPFuncs, aNPNFuncs->version); if (np_initialize_was_called) { trace_warning("NP_Initialize was called more than once\n"); return NPERR_NO_ERROR; } np_initialize_was_called = 1; setup_sig_handlers(); gtk_wrapper_initialize(); if (!gw_gtk_available()) { trace_error("no GTK+ loaded\n"); return NPERR_NO_ERROR; } trace_info_f("found GTK+ %d.%d\n", gw_major_version(), gw_minor_version()); // set logging-only error handler. // Ignore a previous one, we have no plans to restore it (void)XSetErrorHandler(x_error_handler); (void)XSetIOErrorHandler(x_io_error_hanlder); memset(&npn, 0, sizeof(npn)); memcpy(&npn, aNPNFuncs, sizeof(npn) < aNPNFuncs->size ? sizeof(npn) : aNPNFuncs->size); if (npn.pluginthreadasynccall == NULL) { trace_info_f("browser have npn.pluginthreadasynccall == NULL\n"); if (np_asynccall_initialize() != 0) { trace_error("can't initialize async call emulation\n"); // It's required, can't continue. return NPERR_GENERIC_ERROR; } npn.pluginthreadasynccall = np_asynccall_call; } NPPluginFuncs pf; memset(&pf, 0, sizeof(NPPluginFuncs)); pf.size = MIN(aNPPFuncs->size, sizeof(NPPluginFuncs)); // browser is supposed to fill .size and .version pf.newp = NPP_New; pf.destroy = NPP_Destroy; pf.setwindow = NPP_SetWindow; pf.newstream = NPP_NewStream; pf.destroystream = NPP_DestroyStream; pf.asfile = NPP_StreamAsFile; pf.writeready = NPP_WriteReady; pf.write = NPP_Write; pf.print = NPP_Print; pf.event = NPP_HandleEvent; pf.urlnotify = NPP_URLNotify; pf.getvalue = NPP_GetValue; pf.setvalue = NPP_SetValue; pf.gotfocus = NPP_GotFocus; pf.lostfocus = NPP_LostFocus; pf.urlredirectnotify = NPP_URLRedirectNotify; pf.clearsitedata = NPP_ClearSiteData; pf.getsiteswithdata = NPP_GetSitesWithData; pf.didComposite = NPP_DidComposite; memcpy(aNPPFuncs, &pf, pf.size); if (aNPNFuncs->version < NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL) { config.quirks.plugin_missing = 1; config.quirks.incompatible_npapi_version = 1; } load_ppp_module(); if (tables_open_display() != 0) return NPERR_GENERIC_ERROR; int res = call_plugin_init_module(); if (res != 0) { trace_error("%s, PPP_InitializeModule returned %d\n", __func__, res); return NPERR_GENERIC_ERROR; } return NPERR_NO_ERROR; } NPError NP_Shutdown(void) { trace_info_f("[NP] %s\n", __func__); unload_ppp_module(); tables_close_display(); return NPERR_NO_ERROR; } freshplayerplugin-0.3.9/src/np_functions.c000066400000000000000000002052761321746453100207500ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "config.h" #include "config_priv.h" #include "eintr_retry.h" #include "gtk_wrapper.h" #include "header_parser.h" #include "keycodeconvert.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_core.h" #include "ppb_cursor_control.h" #include "ppb_flash_fullscreen.h" #include "ppb_graphics2d.h" #include "ppb_graphics3d.h" #include "ppb_input_event.h" #include "ppb_instance.h" #include "ppb_message_loop.h" #include "ppb_url_loader.h" #include "ppb_url_request_info.h" #include "ppb_url_util.h" #include "ppb_var.h" #include "ppb_view.h" #include "reverse_constant.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include "utils.h" #include "x11_event_thread.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int16_t handle_key_press_release_event(NPP npp, void *event); static void do_nothing(void *user_data, int32_t result) { (void)user_data; (void)result; } static void set_window_comt(void *user_data, int32_t result) { const PP_Instance instance_id = (size_t)user_data; struct pp_instance_s *pp_i = tables_get_pp_instance(instance_id); if (!pp_i) { // instance was unregistered, no need to do anything return; } PP_Resource view = pp_resource_allocate(PP_RESOURCE_VIEW, pp_i); struct pp_view_s *v = pp_resource_acquire(view, PP_RESOURCE_VIEW); if (v) { pthread_mutex_lock(&display.lock); v->rect.point.x = 0; v->rect.point.y = 0; v->rect.size.width = pp_i->width / config.device_scale + 0.5; v->rect.size.height = pp_i->height / config.device_scale + 0.5; pp_resource_release(view); pthread_mutex_unlock(&display.lock); pp_i->ppp_instance_1_1->DidChangeView(pp_i->id, view); ppb_core_release_resource(view); } } NPError NPP_SetWindow(NPP npp, NPWindow *window) { if (config.quirks.plugin_missing) return NPERR_NO_ERROR; char *window_str = trace_np_window_as_string(window); trace_info_f("[NPP] {full} %s npp=%p, window=%s\n", __func__, npp, window_str); g_free(window_str); struct pp_instance_s *pp_i = npp->pdata; if (!pp_i) { trace_error("%s, pp_i is NULL\n", __func__); return NPERR_NO_ERROR; } pp_i->wnd = (Window)window->window; pp_i->x = window->x; pp_i->y = window->y; pp_i->width = window->width; pp_i->height = window->height; pp_i->clip_rect.left = window->clipRect.left; pp_i->clip_rect.right = window->clipRect.right; pp_i->clip_rect.top = window->clipRect.top; pp_i->clip_rect.bottom = window->clipRect.bottom; if (npn.getvalue(pp_i->npp, NPNVnetscapeWindow, &pp_i->browser_wnd) != NPERR_NO_ERROR) { pp_i->browser_wnd = None; trace_error("%s, failed to get NPNVnetscapeWindow\n", __func__); } if (pp_i->windowed_mode) { pp_i->wnd = x11et_register_window(pp_i->id, (Window)window->window, NPP_HandleEvent, pp_i->use_xembed); } pthread_mutex_lock(&display.lock); if (!pp_i->is_fullscreen) { if (g_atomic_int_get(&pp_i->instance_loaded)) { ppb_core_call_on_main_thread2(0, PP_MakeCCB(set_window_comt, GINT_TO_POINTER(pp_i->id)), PP_OK, __func__); } } pthread_mutex_unlock(&display.lock); return NPERR_NO_ERROR; } struct call_plugin_did_create_param_s { PP_Resource m_loop; int depth; struct pp_instance_s *pp_i; }; static void call_plugin_did_create_comt(void *user_data, int32_t result) { struct call_plugin_did_create_param_s *p = user_data; struct pp_instance_s *pp_i = p->pp_i; pp_i->ppp_instance_1_1 = ppp_get_interface(PPP_INSTANCE_INTERFACE_1_1); if (!pp_i->ppp_instance_1_1) { trace_error("%s, failed to get required %s\n", __func__, PPP_INSTANCE_INTERFACE_1_1); goto done; } pp_i->ppp_input_event = ppp_get_interface(PPP_INPUT_EVENT_INTERFACE_0_1); if (!pp_i->ppp_input_event) { trace_error("%s, failed to get required %s\n", __func__, PPP_INPUT_EVENT_INTERFACE_0_1); goto done; } pp_i->ppp_instance_1_1->DidCreate(pp_i->id, pp_i->argc, (const char **)pp_i->argn, (const char **)pp_i->argv); // no need to keep argn/argv after initialization for (intptr_t k = 0; k < pp_i->argc; k++) { free(pp_i->argn[k]); free(pp_i->argv[k]); } free_and_nullify(pp_i->argn); free_and_nullify(pp_i->argv); pp_i->ppp_instance_private = ppp_get_interface(PPP_INSTANCE_PRIVATE_INTERFACE_0_1); if (pp_i->ppp_instance_private && pp_i->ppp_instance_private->GetInstanceObject) { pp_i->scriptable_pp_obj = pp_i->ppp_instance_private->GetInstanceObject(pp_i->id); } else { pp_i->scriptable_pp_obj = PP_MakeUndefined(); } if (pp_i->is_fullframe) { PP_Resource request_info = ppb_url_request_info_create(pp_i->id); PP_Resource url_loader = ppb_url_loader_create(pp_i->id); struct PP_Var s_method = ppb_var_var_from_utf8_z("GET"); ppb_url_request_info_set_property(request_info, PP_URLREQUESTPROPERTY_URL, pp_i->instance_url); ppb_url_request_info_set_property(request_info, PP_URLREQUESTPROPERTY_METHOD, s_method); ppb_url_loader_open(url_loader, request_info, PP_MakeCCB(do_nothing, NULL)); ppb_var_release(s_method); ppb_core_release_resource(request_info); pp_i->ppp_instance_1_1->HandleDocumentLoad(pp_i->id, url_loader); } done: ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void call_plugin_did_create_prepare_comt(void *user_data, int32_t result) { ppb_core_trampoline_to_main_thread(PP_MakeCCB(call_plugin_did_create_comt, user_data), PP_OK, __func__); } static struct PP_Var get_document_url(const struct pp_instance_s *pp_i) { struct PP_Var document_url = PP_MakeUndefined(); NPIdentifier location_id = npn.getstringidentifier("location"); NPIdentifier href_id = npn.getstringidentifier("href"); NPObject *np_location_obj; NPVariant location_var, href_var; if (!npn.getproperty(pp_i->npp, pp_i->np_window_obj, location_id, &location_var)) goto err_2; if (location_var.type != NPVariantType_Object) goto err_3; np_location_obj = location_var.value.objectValue; if (!npn.getproperty(pp_i->npp, np_location_obj, href_id, &href_var)) goto err_3; struct PP_Var var = np_variant_to_pp_var(href_var); if (var.type != PP_VARTYPE_STRING) { ppb_var_release(var); goto err_4; } document_url = var; err_4: npn.releasevariantvalue(&href_var); err_3: npn.releasevariantvalue(&location_var); err_2: return document_url; } static struct PP_Var get_document_base_url(const struct pp_instance_s *pp_i) { struct PP_Var base_url = PP_MakeUndefined(); NPIdentifier document_id = npn.getstringidentifier("document"); NPVariant document_var; if (npn.getproperty(pp_i->npp, pp_i->np_window_obj, document_id, &document_var)) { if (document_var.type == NPVariantType_Object) { NPObject *document_obj = document_var.value.objectValue; NPIdentifier base_uri_id = npn.getstringidentifier("baseURI"); NPVariant base_uri_var; if (npn.getproperty(pp_i->npp, document_obj, base_uri_id, &base_uri_var)) { struct PP_Var var = np_variant_to_pp_var(base_uri_var); if (var.type == PP_VARTYPE_STRING) base_url = ppb_var_add_ref2(var); ppb_var_release(var); npn.releasevariantvalue(&base_uri_var); } } npn.releasevariantvalue(&document_var); } return base_url; } struct call_plugin_handle_input_event_param_s { PP_Instance instance; PP_Resource event_id; }; static void call_ppp_handle_input_event_comt(void *user_data, int32_t result) { struct call_plugin_handle_input_event_param_s *p = user_data; struct pp_instance_s *pp_i = tables_get_pp_instance(p->instance); if (pp_i && pp_i->ppp_input_event) pp_i->ppp_input_event->HandleInputEvent(p->instance, p->event_id); ppb_core_release_resource(p->event_id); g_slice_free1(sizeof(*p), p); } static void ppp_handle_input_event_helper(struct pp_instance_s *pp_i, PP_Resource event_id) { struct call_plugin_handle_input_event_param_s *p = g_slice_alloc0(sizeof(*p)); p->instance = pp_i->id; p->event_id = event_id; ppb_core_call_on_main_thread2(0, PP_MakeCCB(call_ppp_handle_input_event_comt, p), PP_OK, __func__); } static void im_preedit_start(GtkIMContext *im_context, struct pp_instance_s *pp_i) { PP_TimeTicks time_stamp = 0; // TODO: get real time stamp PP_Resource event; event = ppb_ime_input_event_create(pp_i->id, PP_INPUTEVENT_TYPE_IME_COMPOSITION_START, time_stamp, PP_MakeUndefined(), 0, NULL, 0, 0, 0); ppp_handle_input_event_helper(pp_i, event); } static void im_preedit_changed(GtkIMContext *im_context, struct pp_instance_s *pp_i) { PP_TimeTicks time_stamp = 0; // TODO: get real time stamp gchar *preedit_string; gchar *ptr; size_t preedit_string_len; gint cursor_pos; gint cursor_pos_bytes; PP_Resource event; struct PP_Var text; uint32_t offsets[2]; gw_gtk_im_context_get_preedit_string(im_context, &preedit_string, NULL, &cursor_pos); ptr = preedit_string; for (int k = 0; k < cursor_pos; k ++) ptr = g_utf8_next_char(ptr); cursor_pos_bytes = ptr - preedit_string; preedit_string_len = strlen(preedit_string); text = ppb_var_var_from_utf8(preedit_string, preedit_string_len); offsets[0] = 0; offsets[1] = preedit_string_len; event = ppb_ime_input_event_create(pp_i->id, PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE, time_stamp, text, 1, offsets, -1, cursor_pos_bytes, cursor_pos_bytes); ppp_handle_input_event_helper(pp_i, event); ppb_var_release(text); g_free(preedit_string); } static void im_commit(GtkIMContext *im_context, const gchar *str, struct pp_instance_s *pp_i) { PP_TimeTicks time_stamp = 0; // TODO: get real time stamp size_t str_len = str ? strlen(str) : 0; struct PP_Var text = ppb_var_var_from_utf8(str, str_len); uint32_t offsets[2] = { 0, str_len }; PP_Resource event; event = ppb_ime_input_event_create(pp_i->id, PP_INPUTEVENT_TYPE_IME_COMPOSITION_END, time_stamp, text, 1, offsets, 0, str_len, str_len); ppp_handle_input_event_helper(pp_i, event); event = ppb_ime_input_event_create(pp_i->id, PP_INPUTEVENT_TYPE_IME_TEXT, time_stamp, text, 1, offsets, 0, str_len, str_len); ppp_handle_input_event_helper(pp_i, event); ppb_var_release(text); } static int is_printable_sequence(const char *s, size_t len) { const unsigned char *u = (const unsigned char *)s; if (len == 1 && 0x20 <= u[0] && u[0] <= 0x7e) return 1; // all sequences of two and more bytes are considired printable if (len > 1) return 1; return 0; } // Due to asynchronous operation IME can give back key press event by inserting it into GTK+ // event queue. Auxiliary catcher widget is used to catch such events and pass them to processing // routine again. static gboolean catcher_key_press(GtkWidget *widget, GdkEvent *event, struct pp_instance_s *pp_i) { XEvent ev = { .xkey = { .type = KeyPress, .display = GDK_WINDOW_XDISPLAY(event->key.window), .keycode = event->key.hardware_keycode, .time = event->key.time, .state = event->key.state, } }; // untie GdkWindow from auxiliary widget gw_gdk_window_set_user_data(event->key.window, NULL); handle_key_press_release_event(pp_i->npp, &ev); return TRUE; } NPError NPP_New(NPMIMEType pluginType, NPP npp, uint16_t mode, int16_t argc, char *argn[], char *argv[], NPSavedData *saved) { trace_info_f("[NPP] {full} %s pluginType=%s npp=%p, mode=%d, argc=%d, saved=%p\n", __func__, pluginType, npp, mode, argc, saved); for (int k = 0; k < argc; k ++) trace_info_f(" argn[%d] = %s, argv[%d] = %s\n", k, argn[k], k, argv[k]); if (config.quirks.plugin_missing) { trace_info_z("plugin missing, using placeholder\n"); // ask windowsless mode if (npn.setvalue(npp, NPPVpluginWindowBool, (void*)0) != NPERR_NO_ERROR) trace_error("%s, failed to set NPPVpluginWindowBool\n", __func__); return NPERR_NO_ERROR; } if (!ppp_get_interface) { // something went terribly wrong trace_error("ppp_get_interface is NULL\n"); return NPERR_MODULE_LOAD_FAILED_ERROR; } struct pp_instance_s *pp_i; pp_i = calloc(sizeof(*pp_i), 1); npp->pdata = pp_i; if (!pp_i) return NPERR_OUT_OF_MEMORY_ERROR; pthread_mutex_lock(&display.lock); pp_i->npp = npp; pthread_mutex_unlock(&display.lock); // windowed mode will only be used if enabled in config file. If used, it will be disabled // for instances with wmode equal to either "transparent" or "opaque" pp_i->windowed_mode = config.enable_windowed_mode; pp_i->argc = argc; pp_i->argn = malloc(argc * sizeof(char*)); pp_i->argv = malloc(argc * sizeof(char*)); struct PP_Var instance_relative_url = PP_MakeUndefined(); for (int k = 0; k < argc; k ++) { pp_i->argn[k] = strdup(argn[k] ? argn[k] : ""); pp_i->argv[k] = strdup(argv[k] ? argv[k] : ""); if (strcasecmp(pp_i->argn[k], "src") == 0) instance_relative_url = ppb_var_var_from_utf8_z(pp_i->argv[k]); if (strcasecmp(pp_i->argn[k], "wmode") == 0) { if (strcasecmp(pp_i->argv[k], "transparent") == 0) { pp_i->is_transparent = 1; pp_i->windowed_mode = 0; // wmode=transparent movies should use windowless mode } if (strcasecmp(pp_i->argv[k], "opaque") == 0) pp_i->windowed_mode = 0; // wmode=opaque movies should use windowless mode } } if (pp_i->windowed_mode) { // ask windowed mode if (npn.setvalue(npp, NPPVpluginWindowBool, (void*)1) != NPERR_NO_ERROR) trace_error("%s, failed to set NPPVpluginWindowBool\n", __func__); } else { // ask windowsless mode if (npn.setvalue(npp, NPPVpluginWindowBool, (void*)0) != NPERR_NO_ERROR) trace_error("%s, failed to set NPPVpluginWindowBool\n", __func__); } // determine whenever XEmbed is used NPBool browser_supports_xembed = false; if (npn.getvalue(npp, NPNVSupportsXEmbedBool, &browser_supports_xembed) != NPERR_NO_ERROR) trace_error("%s, failed to get NPNVSupportsXEmbedBool\n", __func__); pp_i->use_xembed = browser_supports_xembed && config.enable_xembed; trace_info_f(" XEmbed is %s\n", browser_supports_xembed ? "supported" : "not supported"); trace_info_f(" XEmbed is %s\n", pp_i->use_xembed ? "used" : "not used"); // set transparency mode if (npn.setvalue(npp, NPPVpluginTransparentBool, (void *)(size_t)pp_i->is_transparent) != NPERR_NO_ERROR) { trace_error("%s, failed to set NPPVpluginTransparentBool\n", __func__); } pp_i->is_fullframe = (mode == NP_FULL); pp_i->id = tables_generate_new_pp_instance_id(); tables_add_pp_instance(pp_i->id, pp_i); pp_i->incognito_mode = 0; if (npn.version >= NPVERS_HAS_PRIVATE_MODE) { NPBool private = false; if (npn.getvalue(pp_i->npp, NPNVprivateModeBool, &private) == NPERR_NO_ERROR) { pp_i->incognito_mode = private ? 1 : 0; } else { // Not an error, actually. Browser can have no support for that variable. trace_info_f("%s, failed to get NPNVprivateModeBool\n", __func__); } } do { // getting window object NPError err = npn.getvalue(npp, NPNVWindowNPObject, &pp_i->np_window_obj); if (err == NPERR_NO_ERROR) { tables_add_npobj_npp_mapping(pp_i->np_window_obj, npp); } else { trace_error("%s, failed to get NPNVWindowNPObject, err = %d\n", __func__, err); pp_i->np_window_obj = NULL; } // getting plugin element object err = npn.getvalue(npp, NPNVPluginElementNPObject, &pp_i->np_plugin_element_obj); if (err == NPERR_NO_ERROR) { tables_add_npobj_npp_mapping(pp_i->np_plugin_element_obj, npp); } else { trace_error("%s, failed to get NPNVPluginElementNPObject, err = %d\n", __func__, err); pp_i->np_plugin_element_obj = NULL; } } while (0); pp_i->document_url = get_document_url(pp_i); pp_i->document_base_url = get_document_base_url(pp_i); if (instance_relative_url.type == PP_VARTYPE_UNDEFINED) { // there were no 'src' attribute, using document base url as an instance url pp_i->instance_url = ppb_var_add_ref2(pp_i->document_base_url); } else { // resolve instance URL pp_i->instance_url = ppb_url_util_resolve_relative_to_url(pp_i->document_base_url, instance_relative_url, NULL); ppb_var_release(instance_relative_url); } // prepare GTK+ widget for catching keypress events returned by IME pp_i->catcher_widget = gw_gtk_label_new(""); gw_gtk_widget_set_realized(pp_i->catcher_widget, TRUE); g_signal_connect(pp_i->catcher_widget, "key-press-event", G_CALLBACK(catcher_key_press), pp_i); pp_i->textinput_type = PP_TEXTINPUT_TYPE_DEV_NONE; pp_i->im_context_multi = gw_gtk_im_multicontext_new(); pp_i->im_context_simple = gw_gtk_im_context_simple_new(); pp_i->im_context = NULL; g_signal_connect(pp_i->im_context_multi, "commit", G_CALLBACK(im_commit), pp_i); g_signal_connect(pp_i->im_context_simple, "commit", G_CALLBACK(im_commit), pp_i); g_signal_connect(pp_i->im_context_multi, "preedit-changed", G_CALLBACK(im_preedit_changed), pp_i); g_signal_connect(pp_i->im_context_simple, "preedit-changed", G_CALLBACK(im_preedit_changed), pp_i); g_signal_connect(pp_i->im_context_multi, "preedit-start", G_CALLBACK(im_preedit_start), pp_i); g_signal_connect(pp_i->im_context_simple, "preedit-start", G_CALLBACK(im_preedit_start), pp_i); if (ppb_message_loop_get_current() == 0) { trace_error("%s, no browser thread\n", __func__); return NPERR_GENERIC_ERROR; } if (ppb_message_loop_get_for_main_thread() == 0) { trace_error("%s, no plugin thread\n", __func__); return NPERR_GENERIC_ERROR; } struct call_plugin_did_create_param_s *p = g_slice_alloc(sizeof(*p)); p->m_loop = ppb_message_loop_get_for_browser_thread(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; p->pp_i = pp_i; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(call_plugin_did_create_prepare_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); g_slice_free1(sizeof(*p), p); if (!pp_i->ppp_instance_1_1 || !pp_i->ppp_input_event) { trace_error("%s, one of required plugin interfaces is missing\n", __func__); // TODO: cleanup? return NPERR_GENERIC_ERROR; } g_atomic_int_set(&pp_i->instance_loaded, 1); return NPERR_NO_ERROR; } struct destroy_instance_param_s { struct pp_instance_s *pp_i; PP_Resource m_loop; int depth; }; static void destroy_instance_comt(void *user_data, int32_t result) { struct destroy_instance_param_s *p = user_data; ppb_flash_fullscreen_set_fullscreen(p->pp_i->id, PP_FALSE); p->pp_i->ppp_instance_1_1->DidDestroy(p->pp_i->id); tables_remove_pp_instance(p->pp_i->id); pthread_mutex_lock(&display.lock); p->pp_i->npp = NULL; pthread_mutex_unlock(&display.lock); ppb_var_release(p->pp_i->instance_url); ppb_var_release(p->pp_i->document_url); ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void destroy_instance_prepare_comt(void *user_data, int32_t result) { ppb_core_trampoline_to_main_thread(PP_MakeCCB(destroy_instance_comt, user_data), PP_OK, __func__); } NPError NPP_Destroy(NPP npp, NPSavedData **save) { trace_info_f("[NPP] {full} %s npp=%p, save=%p\n", __func__, npp, save); struct pp_instance_s *pp_i = npp->pdata; if (config.quirks.plugin_missing) return NPERR_NO_ERROR; if (!pp_i) goto no_pp_i; if (pp_i->windowed_mode) x11et_unregister_window(pp_i->wnd); if (pp_i->have_prev_cursor) { pthread_mutex_lock(&display.lock); XFreeCursor(display.x, pp_i->prev_cursor); pthread_mutex_unlock(&display.lock); } pp_i->im_context = NULL; if (pp_i->im_context_multi) g_object_unref(pp_i->im_context_multi); if (pp_i->im_context_simple) g_object_unref(pp_i->im_context_simple); struct destroy_instance_param_s *p = g_slice_alloc(sizeof(*p)); p->pp_i = npp->pdata; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(destroy_instance_prepare_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); g_slice_free1(sizeof(*p), p); g_object_ref_sink(pp_i->catcher_widget); npn.releaseobject(pp_i->np_window_obj); npn.releaseobject(pp_i->np_plugin_element_obj); tables_remove_npobj_npp_mapping(pp_i->np_window_obj); tables_remove_npobj_npp_mapping(pp_i->np_plugin_element_obj); ppb_var_release(pp_i->scriptable_pp_obj); free(pp_i); no_pp_i: if (save) *save = NULL; return NPERR_NO_ERROR; } NPError NPP_NewStream(NPP npp, NPMIMEType type, NPStream *stream, NPBool seekable, uint16_t *stype) { trace_info_f("[NPP] {full} %s npp=%p, type=%s, stream={.pdata=%p, .ndata=%p, .url=%s, " "end=%u, lastmodified=%u, .notifyData=%u, .headers=%s}, seekable=%d\n", __func__, npp, type, stream->pdata, stream->ndata, stream->url, stream->end, stream->lastmodified, (unsigned)(size_t)stream->notifyData, stream->headers, seekable); struct pp_instance_s *pp_i = npp->pdata; if (config.quirks.plugin_missing) return NPERR_NO_ERROR; int rewrite_url_in_loader = 0; PP_Resource loader = (size_t)stream->notifyData; if (!loader && pp_i->content_url_loader != 0 && ! pp_i->content_url_loader_used) { // this is unrequested stream from browser, so it must be the stream we are waiting for loader = pp_i->content_url_loader; rewrite_url_in_loader = 1; pp_i->content_url_loader_used = 1; } if (!loader) { // ignoring unrequested streams stream->pdata = NULL; trace_info_f(" ignoring unrequested stream\n"); return NPERR_NO_ERROR; } struct PP_CompletionCallback ccb = {}; PP_Resource ccb_ml = 0; stream->pdata = (void*)(size_t)loader; struct pp_url_loader_s *ul = pp_resource_acquire(loader, PP_RESOURCE_URL_LOADER); if (ul) { struct parsed_headers_s *ph = hp_parse_headers(stream->headers); ccb = ul->ccb; ccb_ml = ul->ccb_ml; ul->ccb = PP_MakeCCB(NULL, NULL); // prevent callback from being called twice ul->np_stream = stream; if (rewrite_url_in_loader) { free(ul->url); ul->url = nullsafe_strdup(stream->url); // rewriting is only performed for the stream with plugin content, so it's new URL of // the instance ppb_var_release(pp_i->instance_url); pp_i->instance_url = ppb_var_var_from_utf8_z(ul->url); } // handling redirection if (ph->http_code >= 300 && ph->http_code <= 307 && ul->redirect_url) { if (ul->follow_redirects) { trace_info_f(" %s, redirecting to %s\n", __func__, ul->redirect_url); pp_resource_release(loader); ppb_url_loader_follow_redirect(loader, PP_MakeCCB(do_nothing, NULL)); // There is no need to fill response headers, status_line and other parameters // since they are freed in follow_redirect anyway. hp_free_parsed_headers(ph); goto quit; } } size_t headers_len = 0; for (uintptr_t k = 0; k < ph->cnt; k ++) headers_len += strlen(ph->name[k]) + strlen(": ") + strlen(ph->value[k]) + strlen("\n"); // reconstruct headers ul->headers = malloc(headers_len + 1); char *ptr = ul->headers; for (unsigned int k = 0; k < ph->cnt; k ++) { if (k != 0) { memcpy(ptr, "\n", strlen("\n")); ptr += strlen("\n"); } memcpy(ptr, ph->name[k], strlen(ph->name[k])); ptr += strlen(ph->name[k]); memcpy(ptr, ": ", strlen(": ")); ptr += strlen(": "); memcpy(ptr, ph->value[k], strlen(ph->value[k]));ptr += strlen(ph->value[k]); } *ptr = 0; ul->http_code = ph->http_code; ul->response_size = stream->end > 0 ? (int64_t)stream->end : -1; ul->status_line = nullsafe_strdup(ph->status_line); hp_free_parsed_headers(ph); pp_resource_release(loader); } quit: if (ccb.func) ppb_message_loop_post_work_with_result(ccb_ml, ccb, 0, PP_OK, 0, __func__); return NPERR_NO_ERROR; } static void url_read_task_wrapper_comt(void *user_data, int32_t result) { struct url_loader_read_task_s *rt = user_data; if (pp_resource_get_type(rt->url_loader) != PP_RESOURCE_URL_LOADER) { trace_info_f(" url_loader gone (=%d)\n", rt->url_loader); goto err; } trace_info_f(" calling wrapped callback={.func=%p, .user_data=%p, .flags=%d}, result=%d\n", rt->ccb.func, rt->ccb.user_data, rt->ccb.flags, result); rt->ccb.func(rt->ccb.user_data, result); trace_info_f(" returning from wrapped callback={.func=%p, .user_data=%p, .flags=%d}, " "result=%d\n", rt->ccb.func, rt->ccb.user_data, rt->ccb.flags, result); err: g_slice_free1(sizeof(*rt), rt); } NPError NPP_DestroyStream(NPP npp, NPStream *stream, NPReason reason) { trace_info_f("[NPP] {full} %s npp=%p, stream={.pdata=%p, .ndata=%p, .url=%s, end=%u, " "lastmodified=%u, .notifyData=%u, .headers=%s}, reason=%d\n", __func__, npp, stream->pdata, stream->ndata, stream->url, stream->end, stream->lastmodified, (unsigned)(size_t)stream->notifyData, "", reason); if (config.quirks.plugin_missing) return NPERR_NO_ERROR; PP_Resource loader = (PP_Resource)(size_t)stream->pdata; if (!loader) return NPERR_NO_ERROR; struct pp_url_loader_s *ul = pp_resource_acquire(loader, PP_RESOURCE_URL_LOADER); if (!ul) return NPERR_NO_ERROR; ul->np_stream = NULL; if (ul->redirect_url) { pp_resource_release(loader); return NPERR_NO_ERROR; } ul->finished_loading = 1; // execute all remaining tasks in task list while (ul && ul->read_tasks) { GList *llink = g_list_first(ul->read_tasks); struct url_loader_read_task_s *rt = llink->data; ul->read_tasks = g_list_delete_link(ul->read_tasks, llink); int32_t read_bytes = -1; off_t ofs = lseek(ul->fd, ul->read_pos, SEEK_SET); if (ofs != (off_t) -1) read_bytes = RETRY_ON_EINTR(read(ul->fd, rt->buffer, rt->bytes_to_read)); if (read_bytes == -1) read_bytes = PP_ERROR_FAILED; else ul->read_pos += read_bytes; pp_resource_release(loader); ppb_message_loop_post_work_with_result(rt->ccb_ml, PP_MakeCCB(url_read_task_wrapper_comt, rt), 0, read_bytes, 0, __func__); ul = pp_resource_acquire(loader, PP_RESOURCE_URL_LOADER); } if (ul && ul->stream_to_file) { struct PP_CompletionCallback ccb = ul->stream_to_file_ccb; PP_Resource ccb_ml = ul->stream_to_file_ccb_ml; pp_resource_release(loader); ppb_message_loop_post_work_with_result(ccb_ml, ccb, 0, PP_OK, 0, __func__); return NPERR_NO_ERROR; } pp_resource_release(loader); return NPERR_NO_ERROR; } int32_t NPP_WriteReady(NPP npp, NPStream *stream) { trace_info_f("[NPP] {full} %s npp=%p, stream=%p\n", __func__, npp, stream); return 1024*1024; } int32_t NPP_Write(NPP npp, NPStream *stream, int32_t offset, int32_t len, void *buffer) { trace_info_f("[NPP] {full} %s npp=%p, stream={.pdata=%p, .ndata=%p, .url=%s, end=%u, " "lastmodified=%u, .notifyData=%u, .headers=}, offset=%d, len=%d, " "buffer=%p\n", __func__, npp, stream->pdata, stream->ndata, stream->url, stream->end, stream->lastmodified, (unsigned)(size_t)stream->notifyData, offset, len, buffer); if (config.quirks.plugin_missing) return len; PP_Resource loader = (PP_Resource)(size_t)stream->pdata; if (!loader) return len; struct pp_url_loader_s *ul = pp_resource_acquire(loader, PP_RESOURCE_URL_LOADER); if (!ul) { trace_info_f("[NPP] %s, ignoring stream content\n", __func__); return -1; } if (ul->fd == -1 || len <= 0) { pp_resource_release(loader); return len; } if (lseek(ul->fd, offset, SEEK_SET) == (off_t) -1) { pp_resource_release(loader); return -1; } RETRY_ON_EINTR(write(ul->fd, buffer, len)); if (ul->read_tasks == NULL) { pp_resource_release(loader); return len; } GList *llink = g_list_first(ul->read_tasks); struct url_loader_read_task_s *rt = llink->data; ul->read_tasks = g_list_delete_link(ul->read_tasks, llink); int32_t read_bytes = -1; off_t ofs = lseek(ul->fd, ul->read_pos, SEEK_SET); if (ofs != (off_t) -1) read_bytes = RETRY_ON_EINTR(read(ul->fd, rt->buffer, rt->bytes_to_read)); if (read_bytes > 0) ul->read_pos += read_bytes; if (read_bytes > 0) { pp_resource_release(loader); ppb_message_loop_post_work_with_result(rt->ccb_ml, PP_MakeCCB(url_read_task_wrapper_comt, rt), 0, read_bytes, 0, __func__); return len; } else { // reschedule task ul->read_tasks = g_list_prepend(ul->read_tasks, rt); pp_resource_release(loader); return len; } } void NPP_StreamAsFile(NPP npp, NPStream *stream, const char *fname) { trace_info_z("[NPP] {zilch} %s npp=%p, stream=%p, fname=%s\n", __func__, npp, stream, fname); return; } void NPP_Print(NPP npp, NPPrint *platformPrint) { trace_info_z("[NPP] {zilch} %s npp=%p, platformPrint=%p\n", __func__, npp, platformPrint); return; } static void graphics_ccb_wrapper_comt(void *user_data, int32_t result) { PP_Instance instance = GPOINTER_TO_SIZE(user_data); struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) return; pthread_mutex_lock(&display.lock); struct PP_CompletionCallback ccb = pp_i->graphics_ccb; pp_i->graphics_ccb = PP_MakeCCB(NULL, NULL); pp_i->graphics_in_progress = 0; pthread_mutex_unlock(&display.lock); if (ccb.func) ccb.func(ccb.user_data, result); } static void draw_drawable_on_drawable(Display *dpy, int screen, int is_transparent, Drawable src, int32_t source_x, int32_t source_y, Drawable dst, int32_t target_x, int32_t target_y, int32_t target_width, int32_t target_height) { XVisualInfo vi_src, vi_dst; struct { Window root; int x, y; unsigned int width, height, border, depth; } d_src = {}, d_dst = {}; XGetGeometry(dpy, src, &d_src.root, &d_src.x, &d_src.y, &d_src.width, &d_src.height, &d_src.border, &d_src.depth); XGetGeometry(dpy, dst, &d_dst.root, &d_dst.x, &d_dst.y, &d_dst.width, &d_dst.height, &d_dst.border, &d_dst.depth); if (!XMatchVisualInfo(dpy, screen, d_src.depth, TrueColor, &vi_src) || !XMatchVisualInfo(dpy, screen, d_dst.depth, TrueColor, &vi_dst)) { static int reported = 0; if (!reported) trace_error("%s, can't find visual\n", __func__); reported = 1; return; } cairo_surface_t *src_surf, *dst_surf; dst_surf = cairo_xlib_surface_create(dpy, dst, vi_dst.visual, d_dst.width, d_dst.height); src_surf = cairo_xlib_surface_create(dpy, src, vi_src.visual, d_src.width, d_src.height); cairo_t *cr = cairo_create(dst_surf); cairo_set_source_surface(cr, src_surf, target_x - source_x, target_y - source_y); cairo_set_operator(cr, is_transparent ? CAIRO_OPERATOR_OVER : CAIRO_OPERATOR_SOURCE); cairo_rectangle(cr, target_x, target_y, target_width, target_height); cairo_fill(cr); cairo_destroy(cr); cairo_surface_destroy(dst_surf); cairo_surface_destroy(src_surf); } static void draw_argb32_on_drawable(Display *dpy, int screen, int is_transparent, char *data, int32_t width, int32_t height, int32_t stride, int32_t source_x, int32_t source_y, Drawable drawable, int32_t target_x, int32_t target_y, int32_t target_width, int32_t target_height) { XVisualInfo vi; struct { Window root; int x, y; unsigned int width, height, border, depth; } d = {}; XGetGeometry(dpy, drawable, &d.root, &d.x, &d.y, &d.width, &d.height, &d.border, &d.depth); if (!XMatchVisualInfo(dpy, screen, d.depth, TrueColor, &vi)) { static int reported = 0; if (!reported) trace_error("%s, can't find visual\n", __func__); reported = 1; return; } cairo_surface_t *src_surf, *dst_surf; dst_surf = cairo_xlib_surface_create(dpy, drawable, vi.visual, d.width, d.height); src_surf = cairo_image_surface_create_for_data((unsigned char *)data, CAIRO_FORMAT_ARGB32, width, height, stride); cairo_t *cr = cairo_create(dst_surf); cairo_set_source_surface(cr, src_surf, target_x - source_x, target_y - source_y); cairo_set_operator(cr, is_transparent ? CAIRO_OPERATOR_OVER : CAIRO_OPERATOR_SOURCE); cairo_rectangle(cr, target_x, target_y, target_width, target_height); cairo_fill(cr); cairo_destroy(cr); cairo_surface_destroy(dst_surf); cairo_surface_destroy(src_surf); } static int16_t handle_graphics_expose_event(NPP npp, void *event) { XGraphicsExposeEvent *ev = event; struct pp_instance_s *pp_i = npp->pdata; struct pp_graphics2d_s *g2d = pp_resource_acquire(pp_i->graphics, PP_RESOURCE_GRAPHICS2D); struct pp_graphics3d_s *g3d = pp_resource_acquire(pp_i->graphics, PP_RESOURCE_GRAPHICS3D); Display *dpy = ev->display; Drawable drawable = ev->drawable; int screen = DefaultScreen(dpy); int retval; if (pp_i->windowed_mode && pp_i->browser_wnd != None) { int wnd_x, wnd_y; int browser_x, browser_y; Window child; pthread_mutex_lock(&display.lock); XTranslateCoordinates(dpy, (Window)drawable, DefaultRootWindow(dpy), 0, 0, &wnd_x, &wnd_y, &child); XTranslateCoordinates(dpy, pp_i->browser_wnd, DefaultRootWindow(dpy), 0, 0, &browser_x, &browser_y, &child); pthread_mutex_unlock(&display.lock); pp_i->offset_x = wnd_x - browser_x; pp_i->offset_y = wnd_y - browser_y; } const int32_t source_x = pp_i->windowed_mode ? 0 : pp_i->clip_rect.left - pp_i->x; const int32_t source_y = pp_i->windowed_mode ? 0 : pp_i->clip_rect.top - pp_i->y; pthread_mutex_lock(&display.lock); if (g2d) { Visual *visual = DefaultVisual(dpy, screen); const int depth = pp_i->is_transparent ? 32 : 24; XVisualInfo vi_template = { .depth = depth, }; int nitems = 0; XVisualInfo *vi = XGetVisualInfo(display.x, VisualDepthMask, &vi_template, &nitems); if (vi && nitems >= 1) { visual = vi[0].visual; XFree(vi); } else { trace_warning("%s, can't get visual for depth %d, using default\n", __func__, depth); } if (display.have_xrender) { XImage *xi = XCreateImage(dpy, visual, depth, ZPixmap, 0, g2d->second_buffer, g2d->scaled_width, g2d->scaled_height, 32, g2d->scaled_stride); XPutImage(dpy, pp_i->is_transparent ? g2d->pixmap : drawable, pp_i->is_transparent ? g2d->gc : DefaultGC(dpy, screen), xi, 0, 0, ev->x, ev->y, MIN(g2d->scaled_width, ev->width), MIN(g2d->scaled_height, ev->height)); if (pp_i->is_transparent) { Picture dst_pict = XRenderCreatePicture(dpy, drawable, display.pictfmt_rgb24, 0, 0); XRenderComposite(dpy, PictOpOver, g2d->xr_pict, None, dst_pict, ev->x, ev->y, 0, 0, ev->x, ev->y, ev->width, ev->height); XRenderFreePicture(dpy, dst_pict); } XFree(xi); } else { // software compositing fallback draw_argb32_on_drawable(dpy, screen, pp_i->is_transparent, g2d->second_buffer, g2d->scaled_width, g2d->scaled_height, g2d->scaled_stride, source_x, source_y, drawable, ev->x, ev->y, ev->width, ev->height); } XFlush(dpy); } else if (g3d) { if (display.have_xrender) { Picture dst_pict = XRenderCreatePicture(dpy, drawable, display.pictfmt_rgb24, 0, 0); XRenderComposite(dpy, pp_i->is_transparent ? PictOpOver : PictOpSrc, g3d->xr_pict[1], None, dst_pict, ev->x, ev->y, 0, 0, ev->x, ev->y, ev->width, ev->height); XRenderFreePicture(dpy, dst_pict); XFlush(dpy); } else { // software compositing fallback draw_drawable_on_drawable(dpy, screen, pp_i->is_transparent, g3d->pixmap[1], source_x, source_y, drawable, ev->x, ev->y, ev->width, ev->height); } } else { retval = 0; goto done; } pp_resource_release(pp_i->graphics); if (pp_i->graphics_in_progress) { if (pp_i->graphics_ccb.func) ppb_message_loop_post_work_with_result(pp_i->graphics_ccb_ml, PP_MakeCCB(graphics_ccb_wrapper_comt, GSIZE_TO_POINTER(pp_i->id)), 0, PP_OK, 0, __func__); } retval = 1; done: pthread_mutex_unlock(&display.lock); return retval; } /// diplay plugin placeholder and error message in it static int16_t handle_placeholder_graphics_expose_event(NPP npp, void *event) { XGraphicsExposeEvent *ev = event; Display *dpy = ev->display; Drawable drawable = ev->drawable; int screen = DefaultScreen(dpy); unsigned int width, height, border_width, depth; Window root_wnd; int x, y; XGetGeometry(dpy, drawable, &root_wnd, &x, &y, &width, &height, &border_width, &depth); cairo_surface_t *xlib_surf = cairo_xlib_surface_create(dpy, drawable, DefaultVisual(dpy, screen), width, height); cairo_t *cr = cairo_create(xlib_surf); double bg_color[3] = {0.35, 0.35, 0.3}; double fg_color[3] = {0.9, 0.9, 0.5}; // clear box cairo_rectangle(cr, 0, 0, width, height); cairo_set_source_rgb(cr, bg_color[0], bg_color[1], bg_color[2]); cairo_fill(cr); // draw crossed box cairo_set_source_rgb(cr, fg_color[0], fg_color[1], fg_color[2]); cairo_set_line_width(cr, 3); cairo_rectangle(cr, 0, 0, width, height); cairo_stroke(cr); cairo_move_to(cr, 0, 0); cairo_line_to(cr, width, height); cairo_move_to(cr, 0, height); cairo_line_to(cr, width, 0); cairo_stroke(cr); // compose error text gchar *txt; if (config.quirks.incompatible_npapi_version) { txt = g_strdup_printf("NPAPI version too old (%d)", npn.version); } else { const char *plugin_name = fpp_config_get_plugin_file_name(); txt = g_strdup_printf( "Failed to load \"%s\".\n" "Freshwrapper is a translation layer which needs\n" "a PPAPI plugin backend. Ensure your system have\n" "\"%s\" available.\n", plugin_name, plugin_name); } const double pos_x = 10.0; const double pos_y = 30.0; PangoLayout *layout = pango_cairo_create_layout(cr); pango_layout_set_text(layout, txt, -1); // prepare background PangoRectangle extents; pango_layout_get_pixel_extents(layout, &extents, NULL); cairo_rectangle(cr, pos_x, pos_y, extents.width + 6, extents.height + 6); cairo_set_source_rgb(cr, bg_color[0], bg_color[1], bg_color[2]); cairo_fill(cr); // draw text itself cairo_set_source_rgb(cr, fg_color[0], fg_color[1], fg_color[2]); cairo_move_to(cr, pos_x + 3, pos_y + 3); pango_cairo_show_layout(cr, layout); g_object_unref(layout); g_free(txt); cairo_destroy(cr); cairo_surface_destroy(xlib_surf); return 1; } static unsigned int x_state_mask_to_pp_inputevent_modifier(unsigned int state) { unsigned int mod = 0; // TODO: refine this if (state & ShiftMask) { mod |= PP_INPUTEVENT_MODIFIER_SHIFTKEY; mod |= PP_INPUTEVENT_MODIFIER_ISLEFT; } if (state & LockMask) { mod |= PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY; } if (state & ControlMask) { mod |= PP_INPUTEVENT_MODIFIER_CONTROLKEY; mod |= PP_INPUTEVENT_MODIFIER_ISLEFT; } if (state & Mod1Mask) { mod |= PP_INPUTEVENT_MODIFIER_ALTKEY; mod |= PP_INPUTEVENT_MODIFIER_ISLEFT; } if (state & Mod2Mask) { mod |= PP_INPUTEVENT_MODIFIER_NUMLOCKKEY; } if (state & Mod4Mask) { mod |= PP_INPUTEVENT_MODIFIER_METAKEY; mod |= PP_INPUTEVENT_MODIFIER_ISLEFT; } if (state & Button1Mask) { mod |= PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN; } if (state & Button2Mask) { mod |= PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN; } if (state & Button3Mask) { mod |= PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN; } return mod; } static int16_t handle_enter_leave_event(NPP npp, void *event) { XCrossingEvent *ev = event; struct pp_instance_s *pp_i = npp->pdata; if (ev->type == LeaveNotify) { g_atomic_int_set(&pp_i->cursor_inside_instance, 1); ppb_cursor_control_set_cursor(pp_i->id, PP_CURSORTYPE_POINTER, 0, NULL); } g_atomic_int_set(&pp_i->cursor_inside_instance, ev->type == EnterNotify); // ignore NotifyGrab and NotifyUngrab if (ev->mode != NotifyNormal) return 0; // quit if plugin doesn't handle input events if (!pp_i->ppp_input_event) return 0; const uint32_t combined_mask = pp_i->event_mask | pp_i->filtered_event_mask; if (!(PP_INPUTEVENT_CLASS_MOUSE & combined_mask)) return 0; struct PP_Point mouse_position = {.x = ev->x / config.device_scale + 0.5, .y = ev->y / config.device_scale + 0.5 }; struct PP_Point zero_point = {.x = 0, .y = 0}; unsigned int mod = x_state_mask_to_pp_inputevent_modifier(ev->state); PP_InputEvent_Type event_type = (ev->type == EnterNotify) ? PP_INPUTEVENT_TYPE_MOUSEENTER : PP_INPUTEVENT_TYPE_MOUSELEAVE; PP_Resource pp_event; pp_event = ppb_mouse_input_event_create(pp_i->id, event_type, ev->time/1.0e3, mod, PP_INPUTEVENT_MOUSEBUTTON_NONE, &mouse_position, 0, &zero_point); ppp_handle_input_event_helper(pp_i, pp_event); return 1; } static int16_t handle_motion_event(NPP npp, void *event) { XMotionEvent *ev = event; struct pp_instance_s *pp_i = npp->pdata; // quit if plugin doesn't handle input events if (!pp_i->ppp_input_event) return 0; const uint32_t combined_mask = pp_i->event_mask | pp_i->filtered_event_mask; if (!(PP_INPUTEVENT_CLASS_MOUSE & combined_mask)) return 0; struct PP_Point mouse_position = {.x = ev->x / config.device_scale + 0.5, .y = ev->y / config.device_scale + 0.5 }; struct PP_Point zero_point = {.x = 0, .y = 0}; unsigned int mod = x_state_mask_to_pp_inputevent_modifier(ev->state); PP_Resource pp_event; pp_event = ppb_mouse_input_event_create(pp_i->id, PP_INPUTEVENT_TYPE_MOUSEMOVE, ev->time/1.0e3, mod, PP_INPUTEVENT_MOUSEBUTTON_NONE, &mouse_position, 0, &zero_point); ppp_handle_input_event_helper(pp_i, pp_event); return 1; } static int16_t handle_button_press_release_event(NPP npp, void *event) { XButtonEvent *ev = event; struct pp_instance_s *pp_i = npp->pdata; uint32_t event_class = 0; PP_InputEvent_MouseButton mouse_button = PP_INPUTEVENT_MOUSEBUTTON_NONE; // quit if plugin doesn't handle input events if (!pp_i->ppp_input_event) return 0; struct PP_Point mouse_position = {.x = ev->x / config.device_scale + 0.5, .y = ev->y / config.device_scale + 0.5 }; struct PP_Point zero_point = {.x = 0, .y = 0}; unsigned int mod = x_state_mask_to_pp_inputevent_modifier(ev->state); float wheel_x = 0.0, wheel_y = 0.0; int ev_button = ev->button; switch (ev_button) { case 1: mouse_button = PP_INPUTEVENT_MOUSEBUTTON_LEFT; event_class = PP_INPUTEVENT_CLASS_MOUSE; break; case 2: mouse_button = PP_INPUTEVENT_MOUSEBUTTON_MIDDLE; event_class = PP_INPUTEVENT_CLASS_MOUSE; break; case 3: mouse_button = PP_INPUTEVENT_MOUSEBUTTON_RIGHT; event_class = PP_INPUTEVENT_CLASS_MOUSE; break; case 4: // wheel up wheel_y = 1; event_class = PP_INPUTEVENT_CLASS_WHEEL; break; case 5: // wheel down wheel_y = -1; event_class = PP_INPUTEVENT_CLASS_WHEEL; break; case 6: // wheel left wheel_x = -1; event_class = PP_INPUTEVENT_CLASS_WHEEL; break; case 7: // wheel right wheel_x = 1; event_class = PP_INPUTEVENT_CLASS_WHEEL; break; } const uint32_t combined_mask = pp_i->event_mask | pp_i->filtered_event_mask; if (!(event_class & combined_mask)) return 0; if (event_class == PP_INPUTEVENT_CLASS_MOUSE) { PP_Resource pp_event; PP_InputEvent_Type event_type; int click_count = 1; event_type = (ev->type == ButtonPress) ? PP_INPUTEVENT_TYPE_MOUSEDOWN : PP_INPUTEVENT_TYPE_MOUSEUP; if (ev->time < config.double_click_delay_ms + pp_i->last_button_release_timestamp) click_count = 2; pp_event = ppb_mouse_input_event_create(pp_i->id, event_type, ev->time/1.0e3, mod, mouse_button, &mouse_position, click_count, &zero_point); ppp_handle_input_event_helper(pp_i, pp_event); if (ev->type == ButtonRelease) pp_i->last_button_release_timestamp = ev->time; // context menu event if (ev->type == ButtonRelease && ev_button == 3) { pp_event = ppb_mouse_input_event_create(pp_i->id, PP_INPUTEVENT_TYPE_CONTEXTMENU, ev->time/1.0e3, mod, mouse_button, &mouse_position, 1, &zero_point); ppp_handle_input_event_helper(pp_i, pp_event); } } else { // event_class == PP_INPUTEVENT_CLASS_WHEEL if (ev->type == ButtonPress) { const float scroll_by_tick = 10.0; struct PP_FloatPoint wheel_delta = { .x = wheel_x * scroll_by_tick, .y = wheel_y * scroll_by_tick }; struct PP_FloatPoint wheel_ticks = { .x = wheel_x, .y = wheel_y }; PP_Resource pp_event = ppb_wheel_input_event_create(pp_i->id, ev->time/1.0e3, mod, &wheel_delta, &wheel_ticks, PP_FALSE); ppp_handle_input_event_helper(pp_i, pp_event); } } return 1; } static GdkEvent * make_gdk_key_event_from_x_key(XKeyEvent *ev) { GdkDisplay *gdpy = gw_gdk_x11_lookup_xdisplay(ev->display); if (!gdpy) gdpy = gw_gdk_display_get_default(); if (!gdpy) { trace_error("%s, gdpy is NULL\n", __func__); return NULL; } KeySym keysym = NoSymbol; guint8 keyboard_group = 0; XLookupString(ev, NULL, 0, &keysym, NULL); GdkKeymap *keymap = gw_gdk_keymap_get_for_display(gdpy); GdkKeymapKey *keys = NULL; guint *keyvals = NULL; gint n_entries = 0; if (keymap && gw_gdk_keymap_get_entries_for_keycode(keymap, ev->keycode, &keys, &keyvals, &n_entries)) { for (gint i = 0; i < n_entries; ++i) { if (keyvals[i] == keysym) { keyboard_group = keys[i].group; break; } } } g_free(keys); keys = NULL; g_free(keyvals); keyvals = NULL; // Get a GdkWindow. GdkWindow *gwnd = gw_gdk_x11_window_lookup_for_display(gdpy, ev->window); if (gwnd) g_object_ref(gwnd); else gwnd = gw_gdk_x11_window_foreign_new_for_display(gdpy, ev->window); if (!gwnd) { trace_error("%s, gdpy is NULL (2)\n", __func__); return NULL; } // Create a GdkEvent. GdkEventType event_type = ev->type == KeyPress ? GDK_KEY_PRESS : GDK_KEY_RELEASE; GdkEvent *event = gw_gdk_event_new(event_type); event->key.type = event_type; event->key.window = gwnd; event->key.send_event = ev->send_event; event->key.time = ev->time; event->key.state = ev->state; event->key.keyval = keysym; event->key.length = 0; event->key.string = NULL; event->key.hardware_keycode = ev->keycode; event->key.group = keyboard_group; event->key.is_modifier = 0; //is_modifier; return event; } int16_t handle_key_press_release_event(NPP npp, void *event) { XKeyEvent *ev = event; struct pp_instance_s *pp_i = npp->pdata; PP_InputEvent_Type event_type; // quit if plugin doesn't handle input events if (!pp_i->ppp_input_event) return 0; const uint32_t combined_mask = pp_i->event_mask | pp_i->filtered_event_mask; if (!(PP_INPUTEVENT_CLASS_KEYBOARD & combined_mask)) return 0; if (pp_i->im_context && ev->type == KeyPress) { Window browser_window; if (npn.getvalue(npp, NPNVnetscapeWindow, &browser_window) != NPERR_NO_ERROR) { trace_error("%s, failed to get NPNVnetscapeWindow\n", __func__); browser_window = None; } ev->window = browser_window; pthread_mutex_lock(&display.lock); GdkEvent *gev = make_gdk_key_event_from_x_key(ev); if (gev) { // tie catcher_widget to GdkWindow gw_gdk_window_set_user_data(gev->key.window, pp_i->catcher_widget); gw_gtk_im_context_set_client_window(pp_i->im_context, gev->key.window); gboolean stop = gw_gtk_im_context_filter_keypress(pp_i->im_context, &gev->key); if (!stop) { // stop == 0 means gev and its GdkWindow is no longer needed and will be freed // by subsequent gdk_event_free, therefore we untie auxiliary widget, just in case. gw_gdk_window_set_user_data(gev->key.window, NULL); } gw_gdk_event_free(gev); if (stop) { pthread_mutex_unlock(&display.lock); return 1; } } pthread_mutex_unlock(&display.lock); } char buffer[20]; KeySym keysym; XComposeStatus compose_status; int charcount; int pp_keycode; PP_Resource pp_event; unsigned int mod; pthread_mutex_lock(&display.lock); charcount = XLookupString(ev, buffer, sizeof(buffer), &keysym, &compose_status); pthread_mutex_unlock(&display.lock); pp_keycode = xkeycode_to_pp_keycode(keysym); mod = x_state_mask_to_pp_inputevent_modifier(ev->state); mod = mod | get_left_right_pp_flag(keysym); // left flag is always set, it needs to be dropped if there is right flag if (mod & PP_INPUTEVENT_MODIFIER_ISRIGHT) mod = mod & (~(unsigned)PP_INPUTEVENT_MODIFIER_ISLEFT); event_type = (ev->type == KeyPress) ? PP_INPUTEVENT_TYPE_KEYDOWN : PP_INPUTEVENT_TYPE_KEYUP; pp_event = ppb_keyboard_input_event_create_1_0(pp_i->id, event_type, ev->time/1.0e3, mod, pp_keycode, PP_MakeUndefined()); ppp_handle_input_event_helper(pp_i, pp_event); if (ev->type == KeyPress && is_printable_sequence(buffer, charcount)) { struct PP_Var character_text = ppb_var_var_from_utf8(buffer, charcount); pp_event = ppb_keyboard_input_event_create_1_0( pp_i->id, PP_INPUTEVENT_TYPE_CHAR, ev->time/1.0e3, mod, pp_keycode, character_text); ppb_var_release(character_text); ppp_handle_input_event_helper(pp_i, pp_event); } return 1; } static void call_ppp_did_change_focus_comt(void *user_data, int32_t result) { PP_Instance instance = GPOINTER_TO_INT(user_data); struct pp_instance_s *pp_i = tables_get_pp_instance(instance); // check if instance is still alive if (!pp_i) return; PP_Bool has_focus = result; // determine whenever we should pass focus event to the plugin instance pthread_mutex_lock(&display.lock); int muffle_event = (pp_i->ignore_focus_events_cnt > 0); if (pp_i->ignore_focus_events_cnt > 0) pp_i->ignore_focus_events_cnt -= 1; pthread_mutex_unlock(&display.lock); if (pp_i->ppp_instance_1_1 && pp_i->ppp_instance_1_1->DidChangeFocus && !muffle_event) pp_i->ppp_instance_1_1->DidChangeFocus(pp_i->id, has_focus); } int16_t handle_focus_in_out_event(NPP npp, void *event) { struct pp_instance_s *pp_i = npp->pdata; XFocusChangeEvent *ev = event; PP_Bool has_focus = (ev->type == FocusIn) ? PP_TRUE : PP_FALSE; if (pp_i->im_context) { if (ev->type == FocusIn) gw_gtk_im_context_focus_in(pp_i->im_context); else gw_gtk_im_context_focus_out(pp_i->im_context); } ppb_core_call_on_main_thread2(0, PP_MakeCCB(call_ppp_did_change_focus_comt, GINT_TO_POINTER(pp_i->id)), has_focus, __func__); return 1; } int16_t NPP_HandleEvent(NPP npp, void *event) { XAnyEvent *xaev = event; struct pp_instance_s *pp_i = npp->pdata; if (config.quirks.plugin_missing) { if (xaev->type == GraphicsExpose) handle_placeholder_graphics_expose_event(npp, event); return 0; } if (!pp_i) return 0; if (pp_i->is_fullscreen && pp_i->fs_wnd != xaev->window) return 0; #define TRACE_HELPER(implstatus, f) \ trace_info_##f("[NPP] " implstatus " %s npp=%p, event={.type=%s, .serial=%lu, " \ ".send_event=%d, .display=%p, .window=0x%x}\n", __func__, npp, \ reverse_xevent_type(xaev->type), xaev->serial, xaev->send_event, \ xaev->display, (uint32_t)xaev->window) switch (xaev->type) { case Expose: TRACE_HELPER("{full}", f); // its event have similar layout to GraphicsExpose, so let ge handler to do the work return handle_graphics_expose_event(npp, event); case GraphicsExpose: TRACE_HELPER("{full}", f); return handle_graphics_expose_event(npp, event); case EnterNotify: TRACE_HELPER("{full}", f); return handle_enter_leave_event(npp, event); case LeaveNotify: TRACE_HELPER("{full}", f); return handle_enter_leave_event(npp, event); case MotionNotify: TRACE_HELPER("{full}", f); return handle_motion_event(npp, event); case ButtonPress: TRACE_HELPER("{full}", f); return handle_button_press_release_event(npp, event); case ButtonRelease: TRACE_HELPER("{full}", f); return handle_button_press_release_event(npp, event); case KeyPress: TRACE_HELPER("{full}", f); return handle_key_press_release_event(npp, event); case KeyRelease: TRACE_HELPER("{full}", f); return handle_key_press_release_event(npp, event); case FocusIn: TRACE_HELPER("{full}", f); return handle_focus_in_out_event(npp, event); case FocusOut: TRACE_HELPER("{full}", f); return handle_focus_in_out_event(npp, event); default: TRACE_HELPER("{zilch}", z); return 0; } #undef TRACE_HELPER } void NPP_URLNotify(NPP npp, const char *url, NPReason reason, void *notifyData) { trace_info_f("[NPP] {full} %s npp=%p, url=%s, reason=%d, notifyData=%u\n", __func__, npp, url, reason, (unsigned)(size_t)notifyData); if (reason != NPRES_NETWORK_ERR) // no network error, nothing to do return; if (!notifyData) // no associated url loader, nothing to do return; PP_Resource url_loader = (PP_Resource)(size_t)notifyData; struct pp_url_loader_s *ul = pp_resource_acquire(url_loader, PP_RESOURCE_URL_LOADER); if (!ul) return; struct PP_CompletionCallback ccb = ul->ccb; PP_Resource ccb_ml = ul->ccb_ml; ul->ccb = PP_MakeCCB(NULL, NULL); // prevent callback from being called twice pp_resource_release(url_loader); // notify plugin that download have failed if (ccb.func) ppb_message_loop_post_work_with_result(ccb_ml, ccb, 0, PP_ERROR_FAILED, 0, __func__); } NPError NPP_GetValue(NPP npp, NPPVariable variable, void *value) { int status = NPERR_INVALID_PARAM; struct pp_instance_s *pp_i = npp->pdata; if (config.quirks.plugin_missing) return NPERR_INVALID_PARAM; const char *var_name = reverse_npp_variable(variable); switch (variable) { case NPPVpluginNameString: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; case NPPVpluginDescriptionString: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; case NPPVpluginWindowBool: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; case NPPVpluginTransparentBool: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; case NPPVjavaClass: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; case NPPVpluginWindowSize: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; case NPPVpluginTimerInterval: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; case NPPVpluginScriptableInstance: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; case NPPVpluginScriptableIID: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; case NPPVjavascriptPushCallerBool: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; case NPPVpluginKeepLibraryInMemory: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; case NPPVpluginNeedsXEmbed: trace_info_f("[NPP] {full} %s npp=%p, variable=%s\n", __func__, npp, var_name); *(NPBool *)value = pp_i->use_xembed; status = NPERR_NO_ERROR; break; case NPPVpluginScriptableNPObject: trace_info_f("[NPP] {full} %s npp=%p, variable=%s\n", __func__, npp, var_name); do { NPVariant np_var = pp_var_to_np_variant(pp_i->scriptable_pp_obj); *(void **)value = np_var.value.objectValue; tables_add_npobj_npp_mapping(np_var.value.objectValue, npp); } while (0); status = NPERR_NO_ERROR; break; case NPPVformValue: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; case NPPVpluginUrlRequestsDisplayedBool: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; case NPPVpluginWantsAllNetworkStreams: trace_info_f("[NPP] {full} %s npp=%p, variable=%s\n", __func__, npp, var_name); *(int *)value = 1; status = NPERR_NO_ERROR; break; case NPPVpluginNativeAccessibleAtkPlugId: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; case NPPVpluginCancelSrcStream: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; case NPPVsupportsAdvancedKeyHandling: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; case NPPVpluginUsesDOMForCursorBool: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; case NPPVpluginDrawingModel: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; default: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s\n", __func__, npp, var_name); break; } return status; } NPError NPP_SetValue(NPP npp, NPNVariable variable, void *value) { const char *var_name = reverse_npn_variable(variable); struct pp_instance_s *pp_i = npp->pdata; NPBool bool_value = 0; switch (variable) { case NPNVmuteAudioBool: trace_info_f("[NPP] {full} %s npp=%p, variable=%s, value=%p\n", __func__, npp, var_name, value); // TODO: spec says it should be value, not pointer, but implementation definitely uses // pointer to NPBool. Which is right? if (value) memcpy(&bool_value, value, sizeof(NPBool)); if (pp_i) g_atomic_int_set(&pp_i->is_muted, !!bool_value); break; default: trace_info_z("[NPP] {zilch} %s npp=%p, variable=%s, value=%p\n", __func__, npp, var_name, value); break; } return NPERR_NO_ERROR; } NPBool NPP_GotFocus(NPP npp, NPFocusDirection direction) { trace_info_z("[NPP] {zilch} %s npp=%p, direction=%d\n", __func__, npp, direction); return 1; } void NPP_LostFocus(NPP npp) { trace_info_z("[NPP] {zilch} %s npp=%p\n", __func__, npp); return; } void NPP_URLRedirectNotify(NPP npp, const char *url, int32_t status, void *notifyData) { trace_info_f("[NPP] {full} %s npp=%p, url=%s, status=%d, notifyData=%u\n", __func__, npp, url, status, (unsigned)(size_t)notifyData); PP_Resource loader = (size_t)notifyData; if (loader) { struct pp_url_loader_s *ul = pp_resource_acquire(loader, PP_RESOURCE_URL_LOADER); if (ul) { free_and_nullify(ul->redirect_url); ul->redirect_url = strdup(url); pp_resource_release(loader); } } // We are handling redirects ourselves. Tell browser to stop. npn.urlredirectresponse(npp, notifyData, false); return; } NPError NPP_ClearSiteData(const char *site, uint64_t flags, uint64_t maxAge) { trace_info_z("[NPP] {zilch} %s site=%s, flags=%"PRIu64", maxAge=%"PRIu64"\n", __func__, site, flags, maxAge); return NPERR_NO_ERROR; } char** NPP_GetSitesWithData(void) { trace_info_z("[NPP] {zilch} %s\n", __func__); return NULL; } void NPP_DidComposite(NPP npp) { trace_info_z("[NPP] {zilch} %s npp=%p\n", __func__, npp); return; } freshplayerplugin-0.3.9/src/p2n_proxy_class.c000066400000000000000000000413441321746453100213620ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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. */ /* * proxy class which wraps PP_Var object to provide NPObject interface */ #include "p2n_proxy_class.h" #include "ppb_core.h" #include "ppb_message_loop.h" #include "ppb_var.h" #include "tables.h" #include "trace_core.h" #include "utils.h" #include #include #include #include #include #include #include #include #include #include #include #include NPObject * p2n_allocate(NPP npp, NPClass *aClass) { (void)npp; struct np_proxy_object_s *obj = npn.memalloc(sizeof(*obj)); obj->npobj.referenceCount = 1; obj->npobj._class = aClass; obj->ppobj = PP_MakeUndefined(); return (NPObject*)obj; } void p2n_deallocate(NPObject *npobj) { struct np_proxy_object_s *obj = (void *)npobj; if (--obj->npobj.referenceCount <= 0) { ppb_var_release(obj->ppobj); npn.memfree(npobj); } } void p2n_invalidate(NPObject *npobj) { // No-op. // According to spec, this call is always followed by deallocate(), so it's safe // to do nothing here. } struct has_method_param_s { NPObject *npobj; char *name; PP_Resource m_loop; int depth; bool result; }; static void p2n_has_method_comt(void *user_data, int32_t result) { struct has_method_param_s *p = user_data; struct np_proxy_object_s *obj = (void *)p->npobj; struct PP_Var exception = PP_MakeUndefined(); struct PP_Var method_name = ppb_var_var_from_utf8_z(p->name); p->result = ppb_var_has_method(obj->ppobj, method_name, &exception); ppb_var_release(method_name); ppb_var_release(exception); ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void p2n_has_method_prepare_comt(void *user_data, int32_t result) { ppb_core_trampoline_to_main_thread(PP_MakeCCB(p2n_has_method_comt, user_data), PP_OK, __func__); } bool p2n_has_method(NPObject *npobj, NPIdentifier name) { if (!npn.identifierisstring(name)) { trace_error("%s, name is not a string\n", __func__); return false; } if (npobj->_class == &p2n_proxy_class) { struct has_method_param_s *p = g_slice_alloc(sizeof(*p)); p->npobj = npobj; p->name = npn.utf8fromidentifier(name); p->m_loop = ppb_message_loop_get_for_browser_thread(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(p2n_has_method_prepare_comt, p), 0, PP_OK, 0, __func__); ppb_message_loop_run_nested(p->m_loop); bool result = p->result; npn.memfree(p->name); g_slice_free1(sizeof(*p), p); return result; } else { return npobj->_class->hasMethod(npobj, name); } } struct invoke_param_s { NPObject *npobj; char *name; const NPVariant *args; uint32_t argCount; NPVariant *np_result; bool result; PP_Resource m_loop; int depth; }; static void p2n_invoke_comt(void *user_data, int32_t result) { struct invoke_param_s *p = user_data; unsigned int k; p->result = true; struct np_proxy_object_s *obj = (void *)p->npobj; struct PP_Var exception = PP_MakeUndefined(); struct PP_Var method_name = ppb_var_var_from_utf8_z(p->name); struct PP_Var res; struct PP_Var *pp_args = malloc(p->argCount * sizeof(*pp_args)); for (k = 0; k < p->argCount; k ++) { pp_args[k] = np_variant_to_pp_var(p->args[k]); } res = ppb_var_call(obj->ppobj, method_name, p->argCount, pp_args, &exception); for (k = 0; k < p->argCount; k ++) ppb_var_release(pp_args[k]); free(pp_args); if (p->np_result) { *p->np_result = pp_var_to_np_variant(res); if (p->np_result->type == NPVariantType_Object) { NPP npp = tables_get_npobj_npp_mapping(p->npobj); tables_add_npobj_npp_mapping(p->np_result->value.objectValue, npp); } } ppb_var_release(res); ppb_var_release(method_name); ppb_var_release(exception); ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void p2n_invoke_prepare_comt(void *user_data, int32_t result) { ppb_core_trampoline_to_main_thread(PP_MakeCCB(p2n_invoke_comt, user_data), PP_OK, __func__); } bool p2n_invoke(NPObject *npobj, NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *np_result) { if (!npn.identifierisstring(name)) { trace_error("%s, name is not a string\n", __func__); return false; } if (npobj->_class == &p2n_proxy_class) { struct invoke_param_s *p = g_slice_alloc(sizeof(*p)); p->npobj = npobj; p->name = npn.utf8fromidentifier(name); p->args = args; p->argCount = argCount; p->np_result = np_result; p->m_loop = ppb_message_loop_get_for_browser_thread(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(p2n_invoke_prepare_comt, p), 0, PP_OK, 0, __func__); ppb_message_loop_run_nested(p->m_loop); bool result = p->result; npn.memfree(p->name); g_slice_free1(sizeof(*p), p); return result; } else { return npobj->_class->invoke(npobj, name, args, argCount, np_result); } } bool p2n_invoke_default(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *np_result) { return true; } struct has_property_param_s { NPObject *npobj; char *name; PP_Resource m_loop; int depth; bool result; }; static void p2n_has_property_comt(void *user_data, int32_t result) { struct has_property_param_s *p = user_data; struct np_proxy_object_s *obj = (void *)p->npobj; struct PP_Var exception = PP_MakeUndefined(); struct PP_Var property_name = ppb_var_var_from_utf8_z(p->name); p->result = ppb_var_has_property(obj->ppobj, property_name, &exception); ppb_var_release(property_name); ppb_var_release(exception); ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void p2n_has_property_prepare_comt(void *user_data, int32_t result) { ppb_core_trampoline_to_main_thread(PP_MakeCCB(p2n_has_property_comt, user_data), PP_OK, __func__); } bool p2n_has_property(NPObject *npobj, NPIdentifier name) { if (!npn.identifierisstring(name)) { trace_error("%s, name is not a string\n", __func__); return false; } if (npobj->_class == &p2n_proxy_class) { struct has_property_param_s *p = g_slice_alloc(sizeof(*p)); p->npobj = npobj; p->name = npn.utf8fromidentifier(name); p->m_loop = ppb_message_loop_get_for_browser_thread(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(p2n_has_property_prepare_comt, p), 0, PP_OK, 0, __func__); ppb_message_loop_run_nested(p->m_loop); bool result = p->result; npn.memfree(p->name); g_slice_free1(sizeof(*p), p); return result; } else { return npobj->_class->hasProperty(npobj, name); } } struct get_property_param_s { NPObject *npobj; char *name; NPVariant *np_result; bool result; PP_Resource m_loop; int depth; }; static void p2n_get_property_comt(void *user_data, int32_t result) { struct get_property_param_s *p = user_data; struct np_proxy_object_s *obj = (void *)p->npobj; struct PP_Var exception = PP_MakeUndefined(); struct PP_Var property_name = ppb_var_var_from_utf8_z(p->name); struct PP_Var res = ppb_var_get_property(obj->ppobj, property_name, &exception); p->result = true; *p->np_result = pp_var_to_np_variant(res); ppb_var_release(res); ppb_var_release(exception); ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void p2n_get_property_prepare_comt(void *user_data, int32_t result) { ppb_core_trampoline_to_main_thread(PP_MakeCCB(p2n_get_property_comt, user_data), PP_OK, __func__); } bool p2n_get_property(NPObject *npobj, NPIdentifier name, NPVariant *np_result) { if (!npn.identifierisstring(name)) { trace_error("%s, name is not a string\n", __func__); return false; } if (npobj->_class == &p2n_proxy_class) { struct get_property_param_s *p = g_slice_alloc(sizeof(*p)); p->npobj = npobj; p->name = npn.utf8fromidentifier(name); p->np_result = np_result; p->m_loop = ppb_message_loop_get_for_browser_thread(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(p2n_get_property_prepare_comt, p), 0, PP_OK, 0, __func__); ppb_message_loop_run_nested(p->m_loop); bool result = p->result; npn.memfree(p->name); g_slice_free1(sizeof(*p), p); return result; } else { return npobj->_class->getProperty(npobj, name, np_result); } } bool p2n_set_property(NPObject *npobj, NPIdentifier name, const NPVariant *value) { return true; } bool p2n_remove_property(NPObject *npobj, NPIdentifier name) { return true; } struct enumerate_param_s { NPObject *npobj; uint32_t count; struct PP_Var *values; bool result; PP_Resource m_loop; int depth; }; static void p2n_enumerate_comt(void *user_data, int32_t result) { struct enumerate_param_s *p = user_data; struct np_proxy_object_s *obj = (void *)p->npobj; struct PP_Var exception; p->count = 0; p->values = NULL; p->result = true; ppb_var_get_all_property_names(obj->ppobj, &p->count, &p->values, &exception); ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void p2n_enumerate_prepare_comt(void *user_data, int32_t result) { ppb_core_trampoline_to_main_thread(PP_MakeCCB(p2n_enumerate_comt, user_data), PP_OK, __func__); } bool p2n_enumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count) { if (npobj->_class == &p2n_proxy_class) { struct enumerate_param_s *p = g_slice_alloc(sizeof(*p)); p->npobj = npobj; p->m_loop = ppb_message_loop_get_for_browser_thread(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(p2n_enumerate_prepare_comt, p), 0, PP_OK, 0, __func__); ppb_message_loop_run_nested(p->m_loop); bool result = p->result; *count = p->count; *value = npn.memalloc(p->count * sizeof(NPIdentifier)); char *tmpbuf = malloc(1); for (uint32_t k = 0; k < p->count; k ++) { uint32_t len = 0; const char *s = ppb_var_var_to_utf8(p->values[k], &len); // make zero-terminated string char *ptr = realloc(tmpbuf, len + 1); if (!ptr) { result = false; goto err; } tmpbuf = ptr; memcpy(tmpbuf, s, len); tmpbuf[len] = 0; value[k] = npn.getstringidentifier(tmpbuf); } err: free(tmpbuf); g_slice_free1(sizeof(*p), p); return result; } else { return npobj->_class->enumerate(npobj, value, count); } } bool p2n_construct(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { return false; } // trace wrappers TRACE_WRAPPER NPObject * trace_p2n_allocate(NPP npp, NPClass *aClass) { trace_info("[CLS] {full} %s\n", __func__+6); return p2n_allocate(npp, aClass); } TRACE_WRAPPER void trace_p2n_deallocate(NPObject *npobj) { trace_info("[CLS] {full} %s\n", __func__+6); p2n_deallocate(npobj); } TRACE_WRAPPER void trace_p2n_invalidate(NPObject *npobj) { trace_info("[CLS] {full} %s npobj=%p\n", __func__+6, npobj); p2n_invalidate(npobj); } TRACE_WRAPPER bool trace_p2n_has_method(NPObject *npobj, NPIdentifier name) { char *s_name = npn.utf8fromidentifier(name); trace_info("[CLS] {full} %s npobj=%p, name=%s\n", __func__+6, npobj, s_name); npn.memfree(s_name); return p2n_has_method(npobj, name); } TRACE_WRAPPER bool trace_p2n_invoke(NPObject *npobj, NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result) { char *s_name = npn.utf8fromidentifier(name); trace_info("[CLS] {full} %s npobj=%p, name=%s, args=%p, argCount=%u\n", __func__+6, npobj, s_name, args, argCount); npn.memfree(s_name); return p2n_invoke(npobj, name, args, argCount, result); } TRACE_WRAPPER bool trace_p2n_invoke_default(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { trace_info("[CLS] {zilch} %s\n", __func__+6); return p2n_invoke_default(npobj, args, argCount, result); } TRACE_WRAPPER bool trace_p2n_has_property(NPObject *npobj, NPIdentifier name) { char *s_name = npn.utf8fromidentifier(name); trace_info("[CLS] {full} %s npobj=%p, name=%s\n", __func__+6, npobj, s_name); npn.memfree(s_name); return p2n_has_property(npobj, name); } TRACE_WRAPPER bool trace_p2n_get_property(NPObject *npobj, NPIdentifier name, NPVariant *result) { trace_info("[CLS] {full} %s\n", __func__+6); return p2n_get_property(npobj, name, result); } TRACE_WRAPPER bool trace_p2n_set_property(NPObject *npobj, NPIdentifier name, const NPVariant *value) { trace_info("[CLS] {zilch} %s\n", __func__+6); return p2n_set_property(npobj, name, value); } TRACE_WRAPPER bool trace_p2n_remove_property(NPObject *npobj, NPIdentifier name) { trace_info("[CLS] {zilch} %s\n", __func__+6); return p2n_remove_property(npobj, name); } TRACE_WRAPPER bool trace_p2n_enumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count) { trace_info("[CLS] {full} %s npobj=%p\n", __func__+6, npobj); return p2n_enumerate(npobj, value, count); } TRACE_WRAPPER bool trace_p2n_construct(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { trace_info("[CLS] {zilch} %s\n", __func__+6); return p2n_construct(npobj, args, argCount, result); } // can't be const due to npapi restrictions struct NPClass p2n_proxy_class = { .structVersion = NP_CLASS_STRUCT_VERSION, .allocate = TWRAPF(p2n_allocate), .deallocate = TWRAPF(p2n_deallocate), .invalidate = TWRAPF(p2n_invalidate), .hasMethod = TWRAPF(p2n_has_method), .invoke = TWRAPF(p2n_invoke), .invokeDefault = TWRAPZ(p2n_invoke_default), .hasProperty = TWRAPF(p2n_has_property), .getProperty = TWRAPF(p2n_get_property), .setProperty = TWRAPZ(p2n_set_property), .removeProperty = TWRAPZ(p2n_remove_property), .enumerate = TWRAPF(p2n_enumerate), .construct = TWRAPZ(p2n_construct), }; freshplayerplugin-0.3.9/src/p2n_proxy_class.h000066400000000000000000000025501321746453100213630ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include #include struct np_proxy_object_s { NPObject npobj; struct PP_Var ppobj; }; extern struct NPClass p2n_proxy_class; freshplayerplugin-0.3.9/src/pp_interface.c000066400000000000000000000044011321746453100206650ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "trace_core.h" #include #include #include static GHashTable *interface_ht = NULL; static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; const void *(*ppp_get_interface)(const char *interface_name); const void * ppb_get_interface(const char *interface_name) { trace_info_f("[PPB] {full} %s interface_name=%s\n", __func__, interface_name); pthread_mutex_lock(&lock); void *impl = g_hash_table_lookup(interface_ht, interface_name); pthread_mutex_unlock(&lock); if (impl) return impl; trace_info("not implemented: %s\n", interface_name); return NULL; } void register_interface(const char *name, const void *implementation) { pthread_mutex_lock(&lock); if (!interface_ht) interface_ht = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); g_hash_table_insert(interface_ht, g_strdup(name), (void *)implementation); pthread_mutex_unlock(&lock); } static void __attribute__((destructor)) destructor_pp_interface(void) { g_hash_table_unref(interface_ht); interface_ht = NULL; } freshplayerplugin-0.3.9/src/pp_interface.h000066400000000000000000000025541321746453100207010ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 extern const void *(*ppp_get_interface)(const char *interface_name); const void * ppb_get_interface(const char *interface_name); void register_interface(const char *name, const void *implementation); freshplayerplugin-0.3.9/src/pp_resource.c000066400000000000000000000166121321746453100205630ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "config.h" #include "pp_resource.h" #include "trace_core.h" #include #include #include #include #include #include static GHashTable *res_tbl; static GHashTable *destructors_ht = NULL; static int res_tbl_next = 0; static pthread_mutex_t res_tbl_lock = PTHREAD_MUTEX_INITIALIZER; struct pp_resource_generic_s { COMMON_STRUCTURE_FIELDS }; static __attribute__((constructor)) void constructor_pp_resource(void) { pthread_mutex_lock(&res_tbl_lock); res_tbl = g_hash_table_new(g_direct_hash, g_direct_equal); res_tbl_next = 1; pthread_mutex_unlock(&res_tbl_lock); } PP_Resource pp_resource_allocate(enum pp_resource_type_e type, struct pp_instance_s *instance) { struct pp_resource_generic_s *res = g_slice_alloc0(LARGEST_RESOURCE_SIZE); res->resource_type = type; res->ref_cnt = 1; pthread_mutex_init(&res->lock, NULL); res->instance = instance; pthread_mutex_lock(&res_tbl_lock); res->self_id = res_tbl_next ++; g_hash_table_insert(res_tbl, GINT_TO_POINTER(res->self_id), res); pthread_mutex_unlock(&res_tbl_lock); return res->self_id; } void pp_resource_expunge(PP_Resource resource) { pthread_mutex_lock(&res_tbl_lock); void *ptr = g_hash_table_lookup(res_tbl, GINT_TO_POINTER(resource)); if (ptr) { g_slice_free1(LARGEST_RESOURCE_SIZE, ptr); g_hash_table_remove(res_tbl, GINT_TO_POINTER(resource)); } pthread_mutex_unlock(&res_tbl_lock); } void * pp_resource_acquire(PP_Resource resource, enum pp_resource_type_e type) { struct pp_resource_generic_s *gr = NULL; while (1) { pthread_mutex_lock(&res_tbl_lock); gr = g_hash_table_lookup(res_tbl, GINT_TO_POINTER(resource)); if (!gr || gr->resource_type != type) { gr = NULL; break; } if (pthread_mutex_trylock(&gr->lock) == 0) break; pthread_mutex_unlock(&res_tbl_lock); usleep(1); } // reference to avoid freeing acquired resource if (gr) gr->ref_cnt++; pthread_mutex_unlock(&res_tbl_lock); return gr; } void pp_resource_release(PP_Resource resource) { pthread_mutex_lock(&res_tbl_lock); struct pp_resource_generic_s *gr = g_hash_table_lookup(res_tbl, GINT_TO_POINTER(resource)); if (gr) { pthread_mutex_unlock(&gr->lock); } pthread_mutex_unlock(&res_tbl_lock); // unref referenced in pp_resource_acquire() pp_resource_unref(resource); } enum pp_resource_type_e pp_resource_get_type(PP_Resource resource) { enum pp_resource_type_e type = PP_RESOURCE_UNKNOWN; pthread_mutex_lock(&res_tbl_lock); struct pp_resource_generic_s *ptr = g_hash_table_lookup(res_tbl, GINT_TO_POINTER(resource)); if (ptr) { type = ptr->resource_type; } pthread_mutex_unlock(&res_tbl_lock); return type; } PP_Resource pp_resource_ref(PP_Resource resource) { pthread_mutex_lock(&res_tbl_lock); struct pp_resource_generic_s *ptr = g_hash_table_lookup(res_tbl, GINT_TO_POINTER(resource)); if (ptr) { ptr->ref_cnt ++; } else { trace_warning("%s, no such resource %d\n", __func__, resource); } pthread_mutex_unlock(&res_tbl_lock); return resource; } static void count_resources_cb(gpointer key, gpointer value, gpointer user_data) { int *counts = user_data; struct pp_resource_generic_s *r = value; if (r->resource_type < PP_RESOURCE_TYPES_COUNT) counts[r->resource_type] ++; else counts[PP_RESOURCE_TYPES_COUNT] ++; } void pp_resource_unref(PP_Resource resource) { void (*resource_destructor)(void *) = NULL; int ref_cnt = 0; pthread_mutex_lock(&res_tbl_lock); struct pp_resource_generic_s *ptr = g_hash_table_lookup(res_tbl, GINT_TO_POINTER(resource)); if (ptr) { ref_cnt = --ptr->ref_cnt; // reference count should always be non-negative if (ref_cnt < 0) trace_error("%s, logic error, ref count gone negative\n", __func__); // prevent from being destroyed twice if (ref_cnt <= 0) g_hash_table_remove(res_tbl, GINT_TO_POINTER(resource)); // find destructor resource_destructor = g_hash_table_lookup(destructors_ht, GSIZE_TO_POINTER(ptr->resource_type)); } pthread_mutex_unlock(&res_tbl_lock); if (!ptr) return; if (ref_cnt <= 0) { if (resource_destructor) resource_destructor(ptr); else trace_error("%s, no destructor for type %d\n", __func__, ptr->resource_type); // finally, free memory occupied by resource g_slice_free1(LARGEST_RESOURCE_SIZE, ptr); } if (config.quirks.dump_resource_histogram) { time_t current_time = time(NULL); static uintptr_t throttling = 0; if (current_time % 5 == 0) { if (!throttling) { int counts[PP_RESOURCE_TYPES_COUNT + 1] = {}; pthread_mutex_lock(&res_tbl_lock); g_hash_table_foreach(res_tbl, count_resources_cb, counts); pthread_mutex_unlock(&res_tbl_lock); trace_error("-- %10lu ------------\n", (unsigned long)current_time); for (int k = 0; k < PP_RESOURCE_TYPES_COUNT; k ++) if (counts[k] > 0) trace_error("counts[%2d] = %d\n", k, counts[k]); if (counts[PP_RESOURCE_TYPES_COUNT] > 0) trace_error("%d unknown resources (should never happen)\n", counts[PP_RESOURCE_TYPES_COUNT]); trace_error("==========================\n"); throttling = 1; } } else { throttling = 0; } } } void register_resource(enum pp_resource_type_e type, void (*destructor)(void *ptr)) { pthread_mutex_lock(&res_tbl_lock); if (!destructors_ht) destructors_ht = g_hash_table_new(g_direct_hash, g_direct_equal); g_hash_table_insert(destructors_ht, GSIZE_TO_POINTER(type), (void *)destructor); pthread_mutex_unlock(&res_tbl_lock); } static void __attribute__((destructor)) destructor_pp_resource(void) { g_hash_table_unref(destructors_ht); destructors_ht = NULL; } freshplayerplugin-0.3.9/src/pp_resource.h000066400000000000000000000066341321746453100205730ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include #include enum pp_resource_type_e { PP_RESOURCE_UNKNOWN = 0, PP_RESOURCE_URL_LOADER, PP_RESOURCE_URL_REQUEST_INFO, PP_RESOURCE_URL_RESPONSE_INFO, PP_RESOURCE_VIEW, PP_RESOURCE_GRAPHICS3D, PP_RESOURCE_IMAGE_DATA, PP_RESOURCE_GRAPHICS2D, PP_RESOURCE_NETWORK_MONITOR, PP_RESOURCE_BROWSER_FONT, PP_RESOURCE_AUDIO_CONFIG, PP_RESOURCE_AUDIO, PP_RESOURCE_INPUT_EVENT, PP_RESOURCE_FLASH_FONT_FILE, PP_RESOURCE_PRINTING, PP_RESOURCE_VIDEO_CAPTURE, PP_RESOURCE_AUDIO_INPUT, PP_RESOURCE_FLASH_MENU, PP_RESOURCE_FLASH_MESSAGE_LOOP, PP_RESOURCE_TCP_SOCKET, PP_RESOURCE_FILE_REF, PP_RESOURCE_FILE_IO, PP_RESOURCE_MESSAGE_LOOP, PP_RESOURCE_FLASH_DRM, PP_RESOURCE_VIDEO_DECODER, PP_RESOURCE_BUFFER, PP_RESOURCE_FILE_CHOOSER, PP_RESOURCE_UDP_SOCKET, PP_RESOURCE_X509_CERTIFICATE, PP_RESOURCE_FONT, PP_RESOURCE_DEVICE_REF, PP_RESOURCE_HOST_RESOLVER, PP_RESOURCE_NET_ADDRESS, PP_RESOURCE_TYPES_COUNT, // must be the last item in the list }; enum pp_request_method_e { PP_METHOD_UNKNOWN, PP_METHOD_GET, PP_METHOD_POST, }; struct pp_instance_s; #define LARGEST_RESOURCE_SIZE 1536 #define COMMON_STRUCTURE_FIELDS \ uint32_t resource_type; \ int ref_cnt; \ struct pp_instance_s *instance; \ PP_Resource self_id; \ pthread_mutex_t lock; PP_Resource pp_resource_allocate(enum pp_resource_type_e type, struct pp_instance_s *instance); void pp_resource_expunge(PP_Resource resource); void *pp_resource_acquire(PP_Resource resource, enum pp_resource_type_e type); void pp_resource_release(PP_Resource resource); enum pp_resource_type_e pp_resource_get_type(PP_Resource resource); PP_Resource pp_resource_ref(PP_Resource resource); void pp_resource_unref(PP_Resource resource); void register_resource(enum pp_resource_type_e type, void (*destructor)(void *ptr)); freshplayerplugin-0.3.9/src/ppb_audio.c000066400000000000000000000240211321746453100201700ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "audio_thread.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_audio.h" #include "ppb_audio_config.h" #include "ppb_core.h" #include "ppb_instance.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include #include #include #include #include #include #include struct pp_audio_s { COMMON_STRUCTURE_FIELDS uint32_t sample_rate; uint32_t sample_frame_count; PPB_Audio_Callback_1_0 callback_1_0; PPB_Audio_Callback callback_1_1; void *user_data; audio_stream_ops *stream_ops; audio_stream *stream; int is_playing; }; STATIC_ASSERT(sizeof(struct pp_audio_s) <= LARGEST_RESOURCE_SIZE); static void playback_cb(void *buf, uint32_t sz, double latency, void *user_data) { struct pp_audio_s *a = user_data; if (a->callback_1_0) { a->callback_1_0(buf, sz, a->user_data); } else if (a->callback_1_1) { a->callback_1_1(buf, sz, latency,a->user_data); } // discard acquired audio data if instance is muted if (g_atomic_int_get(&a->instance->is_muted)) memset(buf, 0, sz); } static PP_Resource do_ppb_audio_create(PP_Instance instance, PP_Resource audio_config, PPB_Audio_Callback_1_0 audio_callback_1_0, PPB_Audio_Callback audio_callback_1_1, void *user_data) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } if (!audio_callback_1_0 && !audio_callback_1_1) return PP_ERROR_BADARGUMENT; PP_Resource audio = pp_resource_allocate(PP_RESOURCE_AUDIO, pp_i); struct pp_audio_s *a = pp_resource_acquire(audio, PP_RESOURCE_AUDIO); if (!a) { trace_error("%s, resource allocation failure\n", __func__); return 0; } struct pp_audio_config_s *ac = pp_resource_acquire(audio_config, PP_RESOURCE_AUDIO_CONFIG); if (!ac) { trace_error("%s, bad audio config\n", __func__); goto err; } a->sample_rate = ac->sample_rate; a->sample_frame_count = ac->sample_frame_count; pp_resource_release(audio_config); a->callback_1_0 = audio_callback_1_0; a->callback_1_1 = audio_callback_1_1; a->user_data = user_data; a->stream_ops = audio_select_implementation(); if (a->stream_ops == NULL) { trace_error("%s, no viable audio implementation\n", __func__); goto err; } a->stream = a->stream_ops->create_playback_stream(a->sample_rate, a->sample_frame_count, playback_cb, a); if (!a->stream) { trace_error("%s, can't create playback stream\n", __func__); goto err; } pp_resource_release(audio); return audio; err: pp_resource_release(audio); pp_resource_expunge(audio); return 0; } PP_Resource ppb_audio_create_1_0(PP_Instance instance, PP_Resource audio_config, PPB_Audio_Callback_1_0 audio_callback_1_0, void *user_data) { return do_ppb_audio_create(instance, audio_config, audio_callback_1_0, NULL, user_data); } PP_Resource ppb_audio_create_1_1(PP_Instance instance, PP_Resource audio_config, PPB_Audio_Callback audio_callback_1_1, void *user_data) { return do_ppb_audio_create(instance, audio_config, NULL, audio_callback_1_1, user_data); } static void ppb_audio_destroy(void *p) { struct pp_audio_s *a = p; if (a->is_playing) { g_atomic_int_add(&a->instance->audio_source_count, -1); a->is_playing = 0; } a->stream_ops->destroy(a->stream); } PP_Bool ppb_audio_is_audio(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_AUDIO; } PP_Resource ppb_audio_get_current_config(PP_Resource audio) { struct pp_audio_s *a = pp_resource_acquire(audio, PP_RESOURCE_AUDIO); if (!a) { trace_error("%s, bad resource\n", __func__); return 0; } PP_Resource audio_config = pp_resource_allocate(PP_RESOURCE_AUDIO_CONFIG, a->instance); struct pp_audio_config_s *ac = pp_resource_acquire(audio_config, PP_RESOURCE_AUDIO_CONFIG); if (!ac) { trace_error("%s, resource allocation failure\n", __func__); audio_config = 0; goto err; } ac->sample_rate = a->sample_rate; ac->sample_frame_count = a->sample_frame_count; pp_resource_release(audio_config); err: pp_resource_release(audio); return audio_config; } static void update_instance_playing_audio_status_ptac(void *p) { PP_Instance instance = GPOINTER_TO_SIZE(p); struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) return; int is_playing_audio = g_atomic_int_get(&pp_i->audio_source_count) > 0; NPError err = npn.setvalue(pp_i->npp, NPPVpluginIsPlayingAudio, GINT_TO_POINTER(is_playing_audio)); if (err != NPERR_NO_ERROR) trace_info_f("%s, failed to set NPPVpluginIsPlayingAudio\n", __func__); } PP_Bool ppb_audio_start_playback(PP_Resource audio) { struct pp_audio_s *a = pp_resource_acquire(audio, PP_RESOURCE_AUDIO); if (!a) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } a->stream_ops->pause(a->stream, 0); if (!a->is_playing) { g_atomic_int_add(&a->instance->audio_source_count, 1); a->is_playing = 1; } pp_resource_release(audio); ppb_core_call_on_browser_thread(a->instance->id, update_instance_playing_audio_status_ptac, GSIZE_TO_POINTER(a->instance->id)); return PP_TRUE; } PP_Bool ppb_audio_stop_playback(PP_Resource audio) { struct pp_audio_s *a = pp_resource_acquire(audio, PP_RESOURCE_AUDIO); if (!a) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } a->stream_ops->pause(a->stream, 1); if (a->is_playing) { g_atomic_int_add(&a->instance->audio_source_count, -1); a->is_playing = 0; } pp_resource_release(audio); ppb_core_call_on_browser_thread(a->instance->id, update_instance_playing_audio_status_ptac, GSIZE_TO_POINTER(a->instance->id)); return PP_TRUE; } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_audio_create_1_0(PP_Instance instance, PP_Resource audio_config, PPB_Audio_Callback_1_0 audio_callback, void *user_data) { trace_info("[PPB] {full} %s instance=%d, audio_config=%d, audio_callback=%p, user_data=%p\n", __func__+6, instance, audio_config, audio_callback, user_data); return ppb_audio_create_1_0(instance, audio_config, audio_callback, user_data); } TRACE_WRAPPER PP_Resource trace_ppb_audio_create_1_1(PP_Instance instance, PP_Resource audio_config, PPB_Audio_Callback audio_callback, void *user_data) { trace_info("[PPB] {full} %s instance=%d, audio_config=%d, audio_callback=%p, user_data=%p\n", __func__+6, instance, audio_config, audio_callback, user_data); return ppb_audio_create_1_1(instance, audio_config, audio_callback, user_data); } TRACE_WRAPPER PP_Bool trace_ppb_audio_is_audio(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_audio_is_audio(resource); } TRACE_WRAPPER PP_Resource trace_ppb_audio_get_current_config(PP_Resource audio) { trace_info("[PPB] {full} %s audio=%d\n", __func__+6, audio); return ppb_audio_get_current_config(audio); } TRACE_WRAPPER PP_Bool trace_ppb_audio_start_playback(PP_Resource audio) { trace_info("[PPB] {full} %s audio=%d\n", __func__+6, audio); return ppb_audio_start_playback(audio); } TRACE_WRAPPER PP_Bool trace_ppb_audio_stop_playback(PP_Resource audio) { trace_info("[PPB] {full} %s audio=%d\n", __func__+6, audio); return ppb_audio_stop_playback(audio); } const struct PPB_Audio_1_0 ppb_audio_interface_1_0 = { .Create = TWRAPF(ppb_audio_create_1_0), .IsAudio = TWRAPF(ppb_audio_is_audio), .GetCurrentConfig = TWRAPF(ppb_audio_get_current_config), .StartPlayback = TWRAPF(ppb_audio_start_playback), .StopPlayback = TWRAPF(ppb_audio_stop_playback), }; const struct PPB_Audio_1_1 ppb_audio_interface_1_1 = { .Create = TWRAPF(ppb_audio_create_1_1), .IsAudio = TWRAPF(ppb_audio_is_audio), .GetCurrentConfig = TWRAPF(ppb_audio_get_current_config), .StartPlayback = TWRAPF(ppb_audio_start_playback), .StopPlayback = TWRAPF(ppb_audio_stop_playback), }; static void __attribute__((constructor)) constructor_ppb_audio(void) { register_interface(PPB_AUDIO_INTERFACE_1_0, &ppb_audio_interface_1_0); register_interface(PPB_AUDIO_INTERFACE_1_1, &ppb_audio_interface_1_1); register_resource(PP_RESOURCE_AUDIO, ppb_audio_destroy); } freshplayerplugin-0.3.9/src/ppb_audio.h000066400000000000000000000033311321746453100201760ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include PP_Resource ppb_audio_create_1_0(PP_Instance instance, PP_Resource audio_config, PPB_Audio_Callback_1_0 audio_callback, void *user_data); PP_Resource ppb_audio_create_1_1(PP_Instance instance, PP_Resource audio_config, PPB_Audio_Callback audio_callback, void *user_data); PP_Bool ppb_audio_is_audio(PP_Resource resource); PP_Resource ppb_audio_get_current_config(PP_Resource audio); PP_Bool ppb_audio_start_playback(PP_Resource audio); PP_Bool ppb_audio_stop_playback(PP_Resource audio); freshplayerplugin-0.3.9/src/ppb_audio_config.c000066400000000000000000000141641321746453100215240ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "pp_resource.h" #include "ppb_audio_config.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include STATIC_ASSERT(sizeof(struct pp_audio_config_s) <= LARGEST_RESOURCE_SIZE); PP_Resource ppb_audio_config_create_stereo_16_bit(PP_Instance instance, PP_AudioSampleRate sample_rate, uint32_t sample_frame_count) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource audio_config = pp_resource_allocate(PP_RESOURCE_AUDIO_CONFIG, pp_i); struct pp_audio_config_s *ac = pp_resource_acquire(audio_config, PP_RESOURCE_AUDIO_CONFIG); if (!ac) { trace_error("%s, resource allocation failure\n", __func__); return 0; } ac->sample_rate = sample_rate; ac->sample_frame_count = CLAMP(sample_frame_count, PP_AUDIOMINSAMPLEFRAMECOUNT, PP_AUDIOMAXSAMPLEFRAMECOUNT); pp_resource_release(audio_config); return audio_config; } static void ppb_audio_config_destroy(void *ptr) { (void)ptr; } uint32_t ppb_audio_config_recommend_sample_frame_count(PP_Instance instance, PP_AudioSampleRate sample_rate, uint32_t requested_sample_frame_count) { (void)instance; (void)sample_rate; return CLAMP(requested_sample_frame_count, PP_AUDIOMINSAMPLEFRAMECOUNT, PP_AUDIOMAXSAMPLEFRAMECOUNT); } PP_Bool ppb_audio_config_is_audio_config(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_AUDIO_CONFIG; } PP_AudioSampleRate ppb_audio_config_get_sample_rate(PP_Resource config) { struct pp_audio_config_s *ac = pp_resource_acquire(config, PP_RESOURCE_AUDIO_CONFIG); if (!ac) { trace_error("%s, bad resource\n", __func__); return PP_AUDIOSAMPLERATE_NONE; } PP_AudioSampleRate sample_rate = ac->sample_rate; pp_resource_release(config); return sample_rate; } uint32_t ppb_audio_config_get_sample_frame_count(PP_Resource config) { struct pp_audio_config_s *ac = pp_resource_acquire(config, PP_RESOURCE_AUDIO_CONFIG); if (!ac) { trace_error("%s, bad resource\n", __func__); return 0; } uint32_t sample_frame_count = ac->sample_frame_count; pp_resource_release(config); return sample_frame_count; } PP_AudioSampleRate ppb_audio_config_recommend_sample_rate(PP_Instance instance) { (void)instance; return PP_AUDIOSAMPLERATE_48000; } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_audio_config_create_stereo_16_bit(PP_Instance instance, PP_AudioSampleRate sample_rate, uint32_t sample_frame_count) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_audio_config_create_stereo_16_bit(instance, sample_rate, sample_frame_count); } TRACE_WRAPPER uint32_t trace_ppb_audio_config_recommend_sample_frame_count(PP_Instance instance, PP_AudioSampleRate sample_rate, uint32_t requested_sample_frame_count) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_audio_config_recommend_sample_frame_count(instance, sample_rate, requested_sample_frame_count); } TRACE_WRAPPER PP_Bool trace_ppb_audio_config_is_audio_config(PP_Resource resource) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_audio_config_is_audio_config(resource); } TRACE_WRAPPER PP_AudioSampleRate trace_ppb_audio_config_get_sample_rate(PP_Resource config) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_audio_config_get_sample_rate(config); } TRACE_WRAPPER uint32_t trace_ppb_audio_config_get_sample_frame_count(PP_Resource config) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_audio_config_get_sample_frame_count(config); } TRACE_WRAPPER PP_AudioSampleRate trace_ppb_audio_config_recommend_sample_rate(PP_Instance instance) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_audio_config_recommend_sample_rate(instance); } const struct PPB_AudioConfig_1_1 ppb_audio_config_interface_1_1 = { .CreateStereo16Bit = TWRAPF(ppb_audio_config_create_stereo_16_bit), .RecommendSampleFrameCount = TWRAPF(ppb_audio_config_recommend_sample_frame_count), .IsAudioConfig = TWRAPF(ppb_audio_config_is_audio_config), .GetSampleRate = TWRAPF(ppb_audio_config_get_sample_rate), .GetSampleFrameCount = TWRAPF(ppb_audio_config_get_sample_frame_count), .RecommendSampleRate = TWRAPF(ppb_audio_config_recommend_sample_rate), }; static void __attribute__((constructor)) constructor_ppb_audio_config(void) { register_interface(PPB_AUDIO_CONFIG_INTERFACE_1_1, &ppb_audio_config_interface_1_1); register_resource(PP_RESOURCE_AUDIO_CONFIG, ppb_audio_config_destroy); } freshplayerplugin-0.3.9/src/ppb_audio_config.h000066400000000000000000000040361321746453100215260ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include "pp_resource.h" #include #include struct pp_audio_config_s { COMMON_STRUCTURE_FIELDS PP_AudioSampleRate sample_rate; uint32_t sample_frame_count; }; PP_Resource ppb_audio_config_create_stereo_16_bit(PP_Instance instance, PP_AudioSampleRate sample_rate, uint32_t sample_frame_count); uint32_t ppb_audio_config_recommend_sample_frame_count(PP_Instance instance, PP_AudioSampleRate sample_rate, uint32_t requested_sample_frame_count); PP_Bool ppb_audio_config_is_audio_config(PP_Resource resource); PP_AudioSampleRate ppb_audio_config_get_sample_rate(PP_Resource config); uint32_t ppb_audio_config_get_sample_frame_count(PP_Resource config); PP_AudioSampleRate ppb_audio_config_recommend_sample_rate(PP_Instance instance); freshplayerplugin-0.3.9/src/ppb_audio_input.c000066400000000000000000000343441321746453100214200ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "audio_thread.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_audio_config.h" #include "ppb_audio_input.h" #include "ppb_core.h" #include "ppb_device_ref.h" #include "ppb_instance.h" #include "ppb_message_loop.h" #include "ppb_var.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include #include struct pp_audio_input_s { COMMON_STRUCTURE_FIELDS uint32_t sample_rate; uint32_t sample_frame_count; PPB_AudioInput_Callback_0_3 cb_0_3; PPB_AudioInput_Callback cb_0_4; void *cb_user_data; audio_stream_ops *stream_ops; audio_stream *stream; }; STATIC_ASSERT(sizeof(struct pp_audio_input_s) <= LARGEST_RESOURCE_SIZE); PP_Resource ppb_audio_input_create(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource audio_input = pp_resource_allocate(PP_RESOURCE_AUDIO_INPUT, pp_i); struct pp_audio_input_s *ai = pp_resource_acquire(audio_input, PP_RESOURCE_AUDIO_INPUT); if (!ai) { trace_error("%s, resource allocation failed\n", __func__); return 0; } ai->stream_ops = audio_select_implementation(); pp_resource_release(audio_input); return audio_input; } static void ppb_audio_input_destroy(void *ptr) { struct pp_audio_input_s *ai = ptr; if (ai->stream) ai->stream_ops->destroy(ai->stream); } PP_Bool ppb_audio_input_is_audio_input(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_AUDIO_INPUT; } int32_t ppb_audio_input_enumerate_devices(PP_Resource audio_input, struct PP_ArrayOutput output, struct PP_CompletionCallback callback) { struct pp_audio_input_s *ai = pp_resource_acquire(audio_input, PP_RESOURCE_AUDIO_INPUT); if (!ai) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_FAILED; } audio_device_name *list = ai->stream_ops->enumerate_capture_devices(); size_t cnt = 0; while (list && list[cnt].name) cnt ++; PP_Resource *refs = output.GetDataBuffer(output.user_data, cnt, sizeof(PP_Resource)); for (uintptr_t k = 0; k < cnt; k ++) { struct PP_Var name = ppb_var_var_from_utf8_z(list[k].name); struct PP_Var longname = ppb_var_var_from_utf8_z(list[k].longname); refs[k] = ppb_device_ref_create(ai->instance->id, name, longname, PP_DEVICETYPE_DEV_AUDIOCAPTURE); ppb_var_release(name); ppb_var_release(longname); } audio_capture_device_list_free(list); ppb_message_loop_post_work_with_result(ppb_message_loop_get_current(), callback, 0, PP_OK, 0, __func__); pp_resource_release(audio_input); return PP_OK_COMPLETIONPENDING; } int32_t ppb_audio_input_monitor_device_change(PP_Resource audio_input, PP_MonitorDeviceChangeCallback callback, void *user_data) { return 0; } static void capture_cb(const void *buf, uint32_t sz, double latency, void *user_data) { struct pp_audio_input_s *ai = user_data; if (ai->cb_0_3) { ai->cb_0_3(buf, sz, ai->cb_user_data); } else if (ai->cb_0_4) { ai->cb_0_4(buf, sz, latency, ai->cb_user_data); } } static int32_t do_ppb_audio_input_open(PP_Resource audio_input, PP_Resource device_ref, PP_Resource config, PPB_AudioInput_Callback_0_3 audio_input_callback_0_3, PPB_AudioInput_Callback audio_input_callback_0_4, void *user_data, struct PP_CompletionCallback callback) { int32_t retval = PP_ERROR_FAILED; const char *longname = NULL; struct PP_Var longname_var = ppb_device_ref_get_longname(device_ref); if (longname_var.type == PP_VARTYPE_STRING) longname = ppb_var_var_to_utf8(longname_var, NULL); struct pp_audio_input_s *ai = pp_resource_acquire(audio_input, PP_RESOURCE_AUDIO_INPUT); if (!ai) { trace_error("%s, bad resource\n", __func__); goto err_1; } struct pp_audio_config_s *ac = pp_resource_acquire(config, PP_RESOURCE_AUDIO_CONFIG); if (!ac) { trace_error("%s, bad audio config\n", __func__); goto err_2; } ai->sample_rate = ac->sample_rate; ai->sample_frame_count = ac->sample_frame_count; ai->cb_0_3 = audio_input_callback_0_3; ai->cb_0_4 = audio_input_callback_0_4; ai->cb_user_data = user_data; ai->stream = ai->stream_ops->create_capture_stream(ai->sample_rate, ai->sample_frame_count, capture_cb, ai, longname); if (!ai->stream) { trace_error("%s, can't create capture stream\n", __func__); goto err_3; } ppb_message_loop_post_work_with_result(ppb_message_loop_get_current(), callback, 0, PP_OK, 0, __func__); retval = PP_OK_COMPLETIONPENDING; err_3: pp_resource_release(config); err_2: pp_resource_release(audio_input); err_1: return retval; } int32_t ppb_audio_input_open_0_3(PP_Resource audio_input, PP_Resource device_ref, PP_Resource config, PPB_AudioInput_Callback_0_3 audio_input_callback, void *user_data, struct PP_CompletionCallback callback) { return do_ppb_audio_input_open(audio_input, device_ref, config, audio_input_callback, NULL, user_data, callback); } int32_t ppb_audio_input_open(PP_Resource audio_input, PP_Resource device_ref, PP_Resource config, PPB_AudioInput_Callback audio_input_callback, void *user_data, struct PP_CompletionCallback callback) { return do_ppb_audio_input_open(audio_input, device_ref, config, NULL, audio_input_callback, user_data, callback); } PP_Resource ppb_audio_input_get_current_config(PP_Resource audio_input) { struct pp_audio_input_s *ai = pp_resource_acquire(audio_input, PP_RESOURCE_AUDIO_INPUT); if (!ai) { trace_error("%s, bad resource\n", __func__); return 0; } PP_Resource audio_config = pp_resource_allocate(PP_RESOURCE_AUDIO_CONFIG, ai->instance); struct pp_audio_config_s *ac = pp_resource_acquire(audio_config, PP_RESOURCE_AUDIO_CONFIG); if (!ac) { trace_error("%s, resource allocation failure\n", __func__); audio_config = 0; goto err; } ac->sample_rate = ai->sample_rate; ac->sample_frame_count = ai->sample_frame_count; pp_resource_release(audio_config); err: pp_resource_release(audio_input); return audio_config; } PP_Bool ppb_audio_input_start_capture(PP_Resource audio_input) { struct pp_audio_input_s *ai = pp_resource_acquire(audio_input, PP_RESOURCE_AUDIO_INPUT); if (!ai) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } if (ai->stream) ai->stream_ops->pause(ai->stream, 0); pp_resource_release(audio_input); return PP_TRUE; } PP_Bool ppb_audio_input_stop_capture(PP_Resource audio_input) { struct pp_audio_input_s *ai = pp_resource_acquire(audio_input, PP_RESOURCE_AUDIO_INPUT); if (!ai) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } if (ai->stream) ai->stream_ops->pause(ai->stream, 1); pp_resource_release(audio_input); return PP_TRUE; } void ppb_audio_input_close(PP_Resource audio_input) { ppb_core_release_resource(audio_input); return; } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_audio_input_create(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_audio_input_create(instance); } TRACE_WRAPPER PP_Bool trace_ppb_audio_input_is_audio_input(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_audio_input_is_audio_input(resource); } TRACE_WRAPPER int32_t trace_ppb_audio_input_enumerate_devices(PP_Resource audio_input, struct PP_ArrayOutput output, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s audio_input=%d, output={.GetDataBuffer=%p, .user_data=%p}, " "callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, audio_input, output.GetDataBuffer, output.user_data, callback.func, callback.user_data, callback.flags); return ppb_audio_input_enumerate_devices(audio_input, output, callback); } TRACE_WRAPPER int32_t trace_ppb_audio_input_monitor_device_change(PP_Resource audio_input, PP_MonitorDeviceChangeCallback callback, void *user_data) { trace_info("[PPB] {zilch} %s audio_input=%d, callback=%p, user_data=%p\n", __func__+6, audio_input, callback, user_data); return ppb_audio_input_monitor_device_change(audio_input, callback, user_data); } TRACE_WRAPPER int32_t trace_ppb_audio_input_open_0_3(PP_Resource audio_input, PP_Resource device_ref, PP_Resource config, PPB_AudioInput_Callback_0_3 audio_input_callback, void *user_data, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s audio_input=%d, device_ref=%d, config=%d, audio_input_callback=%p, " "user_data=%p, callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, audio_input, device_ref, config, audio_input_callback, user_data, callback.func, callback.user_data, callback.flags); return ppb_audio_input_open_0_3(audio_input, device_ref, config, audio_input_callback, user_data, callback); } TRACE_WRAPPER int32_t trace_ppb_audio_input_open(PP_Resource audio_input, PP_Resource device_ref, PP_Resource config, PPB_AudioInput_Callback audio_input_callback, void *user_data, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s audio_input=%d, device_ref=%d, config=%d, audio_input_callback=%p, " "user_data=%p, callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, audio_input, device_ref, config, audio_input_callback, user_data, callback.func, callback.user_data, callback.flags); return ppb_audio_input_open(audio_input, device_ref, config, audio_input_callback, user_data, callback); } TRACE_WRAPPER PP_Resource trace_ppb_audio_input_get_current_config(PP_Resource audio_input) { trace_info("[PPB] {full} %s audio_input=%d\n", __func__+6, audio_input); return ppb_audio_input_get_current_config(audio_input); } TRACE_WRAPPER PP_Bool trace_ppb_audio_input_start_capture(PP_Resource audio_input) { trace_info("[PPB] {full} %s audio_input=%d\n", __func__+6, audio_input); return ppb_audio_input_start_capture(audio_input); } TRACE_WRAPPER PP_Bool trace_ppb_audio_input_stop_capture(PP_Resource audio_input) { trace_info("[PPB] {full} %s audio_input=%d\n", __func__+6, audio_input); return ppb_audio_input_stop_capture(audio_input); } TRACE_WRAPPER void trace_ppb_audio_input_close(PP_Resource audio_input) { trace_info("[PPB] {full} %s audio_input=%d\n", __func__+6, audio_input); ppb_audio_input_close(audio_input); } const struct PPB_AudioInput_Dev_0_3 ppb_audio_input_dev_interface_0_3 = { .Create = TWRAPF(ppb_audio_input_create), .IsAudioInput = TWRAPF(ppb_audio_input_is_audio_input), .EnumerateDevices = TWRAPF(ppb_audio_input_enumerate_devices), .MonitorDeviceChange = TWRAPZ(ppb_audio_input_monitor_device_change), .Open = TWRAPF(ppb_audio_input_open_0_3), .GetCurrentConfig = TWRAPF(ppb_audio_input_get_current_config), .StartCapture = TWRAPF(ppb_audio_input_start_capture), .StopCapture = TWRAPF(ppb_audio_input_stop_capture), .Close = TWRAPF(ppb_audio_input_close), }; const struct PPB_AudioInput_Dev_0_4 ppb_audio_input_dev_interface_0_4 = { .Create = TWRAPF(ppb_audio_input_create), .IsAudioInput = TWRAPF(ppb_audio_input_is_audio_input), .EnumerateDevices = TWRAPF(ppb_audio_input_enumerate_devices), .MonitorDeviceChange = TWRAPZ(ppb_audio_input_monitor_device_change), .Open = TWRAPF(ppb_audio_input_open), .GetCurrentConfig = TWRAPF(ppb_audio_input_get_current_config), .StartCapture = TWRAPF(ppb_audio_input_start_capture), .StopCapture = TWRAPF(ppb_audio_input_stop_capture), .Close = TWRAPF(ppb_audio_input_close), }; static void __attribute__((constructor)) constructor_ppb_audio_input(void) { register_interface(PPB_AUDIO_INPUT_DEV_INTERFACE_0_3, &ppb_audio_input_dev_interface_0_3); register_interface(PPB_AUDIO_INPUT_DEV_INTERFACE_0_4, &ppb_audio_input_dev_interface_0_4); register_resource(PP_RESOURCE_AUDIO_INPUT, ppb_audio_input_destroy); } freshplayerplugin-0.3.9/src/ppb_audio_input.h000066400000000000000000000046271321746453100214260ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include PP_Resource ppb_audio_input_create(PP_Instance instance); PP_Bool ppb_audio_input_is_audio_input(PP_Resource resource); int32_t ppb_audio_input_enumerate_devices(PP_Resource audio_input, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); int32_t ppb_audio_input_monitor_device_change(PP_Resource audio_input, PP_MonitorDeviceChangeCallback callback, void *user_data); int32_t ppb_audio_input_open_0_3(PP_Resource audio_input, PP_Resource device_ref, PP_Resource config, PPB_AudioInput_Callback_0_3 audio_input_callback, void *user_data, struct PP_CompletionCallback callback); int32_t ppb_audio_input_open(PP_Resource audio_input, PP_Resource device_ref, PP_Resource config, PPB_AudioInput_Callback audio_input_callback, void *user_data, struct PP_CompletionCallback callback); PP_Resource ppb_audio_input_get_current_config(PP_Resource audio_input); PP_Bool ppb_audio_input_start_capture(PP_Resource audio_input); PP_Bool ppb_audio_input_stop_capture(PP_Resource audio_input); void ppb_audio_input_close(PP_Resource audio_input); freshplayerplugin-0.3.9/src/ppb_browser_font.c000066400000000000000000000266541321746453100216160ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "font.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_browser_font.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include #include struct pp_browser_font_s { COMMON_STRUCTURE_FIELDS struct fpp_font ff; }; STATIC_ASSERT(sizeof(struct pp_browser_font_s) <= LARGEST_RESOURCE_SIZE); struct PP_Var ppb_browser_font_get_font_families(PP_Instance instance) { return fpp_font_get_font_families(); } PP_Resource ppb_browser_font_create(PP_Instance instance, const struct PP_BrowserFont_Trusted_Description *description) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource font = pp_resource_allocate(PP_RESOURCE_BROWSER_FONT, pp_i); struct pp_browser_font_s *bf = pp_resource_acquire(font, PP_RESOURCE_BROWSER_FONT); if (!bf) { trace_error("%s, resource allocation failure\n", __func__); return 0; } struct PP_FontDescription_Dev font_descr = pp_browser_font_desc_to_pp_font_desc(description); fpp_font_init(&bf->ff, &font_descr); pp_resource_release(font); return font; } static void ppb_browser_font_destroy(void *p) { struct pp_browser_font_s *bf = p; if (!bf) return; fpp_font_destroy(&bf->ff); } PP_Bool ppb_browser_font_is_font(PP_Resource resource) { return PP_RESOURCE_BROWSER_FONT == pp_resource_get_type(resource); } PP_Bool ppb_browser_font_describe(PP_Resource font, struct PP_BrowserFont_Trusted_Description *description, struct PP_BrowserFont_Trusted_Metrics *metrics) { struct pp_browser_font_s *bf = pp_resource_acquire(font, PP_RESOURCE_BROWSER_FONT); if (!bf) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } struct PP_FontDescription_Dev font_descr = {}; struct PP_FontMetrics_Dev font_metrics = {}; PP_Bool ret = fpp_font_describe(&bf->ff, &font_descr, &font_metrics); description->face = font_descr.face; description->family = (PP_BrowserFont_Trusted_Family)font_descr.family; description->size = font_descr.size; description->weight = (PP_BrowserFont_Trusted_Weight)font_descr.weight; description->italic = font_descr.italic; description->small_caps = font_descr.small_caps; description->letter_spacing = font_descr.letter_spacing; description->word_spacing = font_descr.word_spacing; description->padding = font_descr.padding; metrics->height = font_metrics.height; metrics->ascent = font_metrics.ascent; metrics->descent = font_metrics.descent; metrics->line_spacing = font_metrics.line_spacing; metrics->x_height = font_metrics.x_height; pp_resource_release(font); return ret; } PP_Bool ppb_browser_font_draw_text_at(PP_Resource font, PP_Resource image_data, const struct PP_BrowserFont_Trusted_TextRun *text, const struct PP_Point *position, uint32_t color, const struct PP_Rect *clip, PP_Bool image_data_is_opaque) { struct pp_browser_font_s *bf = pp_resource_acquire(font, PP_RESOURCE_BROWSER_FONT); if (!bf) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } struct PP_TextRun_Dev text_run = { .text = text->text, .rtl = text->rtl, .override_direction = text->override_direction }; PP_Bool ret = fpp_font_draw_text_at(&bf->ff, image_data, &text_run, position, color, clip, image_data_is_opaque); pp_resource_release(font); return ret; } int32_t ppb_browser_font_measure_text(PP_Resource font, const struct PP_BrowserFont_Trusted_TextRun *text) { struct pp_browser_font_s *bf = pp_resource_acquire(font, PP_RESOURCE_BROWSER_FONT); if (!bf) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_FAILED; } struct PP_TextRun_Dev text_run = { .text = text->text, .rtl = text->rtl, .override_direction = text->override_direction }; int32_t width = fpp_font_measure_text(&bf->ff, &text_run); pp_resource_release(font); return width; } uint32_t ppb_browser_font_character_offset_for_pixel(PP_Resource font, const struct PP_BrowserFont_Trusted_TextRun *text, int32_t pixel_position) { return 0; } int32_t ppb_browser_font_pixel_offset_for_character(PP_Resource font, const struct PP_BrowserFont_Trusted_TextRun *text, uint32_t char_offset) { return 0; } // trace wrappers TRACE_WRAPPER struct PP_Var trace_ppb_browser_font_get_font_families(PP_Instance instance) { trace_info("[PPB] {zilch} %s instance=%d\n", __func__+6, instance); return ppb_browser_font_get_font_families(instance); } TRACE_WRAPPER PP_Resource trace_ppb_browser_font_create(PP_Instance instance, const struct PP_BrowserFont_Trusted_Description *description) { char *s_face = trace_var_as_string(description->face); trace_info("[PPB] {full} %s instance=%d, description={.face=%s, .family=%d, .size=%u, " ".weight=%d, .italic=%u, .small_caps=%u, .letter_spacing=%d, .word_spacing=%d}\n", __func__+6, instance, s_face, description->family, description->size, description->weight, description->italic, description->small_caps, description->letter_spacing, description->word_spacing); g_free(s_face); return ppb_browser_font_create(instance, description); } TRACE_WRAPPER PP_Bool trace_ppb_browser_font_is_font(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_browser_font_is_font(resource); } TRACE_WRAPPER PP_Bool trace_ppb_browser_font_describe(PP_Resource font, struct PP_BrowserFont_Trusted_Description *description, struct PP_BrowserFont_Trusted_Metrics *metrics) { trace_info("[PPB] {full} %s font=%d\n", __func__+6, font); return ppb_browser_font_describe(font, description, metrics); } TRACE_WRAPPER PP_Bool trace_ppb_browser_font_draw_text_at(PP_Resource font, PP_Resource image_data, const struct PP_BrowserFont_Trusted_TextRun *text, const struct PP_Point *position, uint32_t color, const struct PP_Rect *clip, PP_Bool image_data_is_opaque) { char *s_text_text = trace_var_as_string(text->text); char *s_position = trace_point_as_string(position); char *s_clip = trace_rect_as_string(clip); trace_info("[PPB] {full} %s font=%d, image_data=%d, text={.text=%s, .rtl=%u, " ".override_direction=%u}, position=%s, color=0x%06x, clip=%s, " "image_data_is_opaque=%u\n", __func__+6, font, image_data, s_text_text, text->rtl, text->override_direction, s_position, color, s_clip, image_data_is_opaque); g_free(s_text_text); g_free(s_position); g_free(s_clip); return ppb_browser_font_draw_text_at(font, image_data, text, position, color, clip, image_data_is_opaque); } TRACE_WRAPPER int32_t trace_ppb_browser_font_measure_text(PP_Resource font, const struct PP_BrowserFont_Trusted_TextRun *text) { char *s_text_text = trace_var_as_string(text->text); trace_info("[PPB] {full} %s font=%d, text={.text=%s, .rtl=%u, .override_direction=%u}\n", __func__+6, font, s_text_text, text->rtl, text->override_direction); g_free(s_text_text); return ppb_browser_font_measure_text(font, text); } TRACE_WRAPPER uint32_t trace_ppb_browser_font_character_offset_for_pixel(PP_Resource font, const struct PP_BrowserFont_Trusted_TextRun *text, int32_t pixel_position) { char *s_text_text = trace_var_as_string(text->text); trace_info("[PPB] {zilch} %s font=%d, text={.text=%s, .rtl=%u, .override_direction=%u}, " "pixel_position=%d\n", __func__+6, font, s_text_text, text->rtl, text->override_direction, pixel_position); g_free(s_text_text); return ppb_browser_font_character_offset_for_pixel(font, text, pixel_position); } TRACE_WRAPPER int32_t trace_ppb_browser_font_pixel_offset_for_character(PP_Resource font, const struct PP_BrowserFont_Trusted_TextRun *text, uint32_t char_offset) { char *s_text_text = trace_var_as_string(text->text); trace_info("[PPB] {zilch} %s font=%d, text={.text=%s, .rtl=%u, .override_direction=%u}, " "char_offset=%u\n", __func__+6, font, s_text_text, text->rtl, text->override_direction, char_offset); g_free(s_text_text); return ppb_browser_font_pixel_offset_for_character(font, text, char_offset); } const struct PPB_BrowserFont_Trusted_1_0 ppb_browser_font_trusted_interface_1_0 = { .GetFontFamilies = TWRAPF(ppb_browser_font_get_font_families), .Create = TWRAPF(ppb_browser_font_create), .IsFont = TWRAPF(ppb_browser_font_is_font), .Describe = TWRAPF(ppb_browser_font_describe), .DrawTextAt = TWRAPF(ppb_browser_font_draw_text_at), .MeasureText = TWRAPF(ppb_browser_font_measure_text), .CharacterOffsetForPixel = TWRAPZ(ppb_browser_font_character_offset_for_pixel), .PixelOffsetForCharacter = TWRAPZ(ppb_browser_font_pixel_offset_for_character), }; static void __attribute__((constructor)) constructor_ppb_browser_font(void) { register_interface(PPB_BROWSERFONT_TRUSTED_INTERFACE_1_0, &ppb_browser_font_trusted_interface_1_0); register_resource(PP_RESOURCE_BROWSER_FONT, ppb_browser_font_destroy); } freshplayerplugin-0.3.9/src/ppb_browser_font.h000066400000000000000000000050601321746453100216070ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include struct PP_Var ppb_browser_font_get_font_families(PP_Instance instance); PP_Resource ppb_browser_font_create(PP_Instance instance, const struct PP_BrowserFont_Trusted_Description *description); PP_Bool ppb_browser_font_is_font(PP_Resource resource); PP_Bool ppb_browser_font_describe(PP_Resource font, struct PP_BrowserFont_Trusted_Description *description, struct PP_BrowserFont_Trusted_Metrics *metrics); PP_Bool ppb_browser_font_draw_text_at(PP_Resource font, PP_Resource image_data, const struct PP_BrowserFont_Trusted_TextRun *text, const struct PP_Point *position, uint32_t color, const struct PP_Rect *clip, PP_Bool image_data_is_opaque); int32_t ppb_browser_font_measure_text(PP_Resource font, const struct PP_BrowserFont_Trusted_TextRun *text); uint32_t ppb_browser_font_character_offset_for_pixel(PP_Resource font, const struct PP_BrowserFont_Trusted_TextRun *text, int32_t pixel_position); int32_t ppb_browser_font_pixel_offset_for_character(PP_Resource font, const struct PP_BrowserFont_Trusted_TextRun *text, uint32_t char_offset); freshplayerplugin-0.3.9/src/ppb_buffer.c000066400000000000000000000111271321746453100203430ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "pp_resource.h" #include "ppb_buffer.h" #include "ppb_core.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include struct pp_buffer_s { COMMON_STRUCTURE_FIELDS void *data; uint32_t len; }; STATIC_ASSERT(sizeof(struct pp_buffer_s) <= LARGEST_RESOURCE_SIZE); PP_Resource ppb_buffer_create(PP_Instance instance, uint32_t size_in_bytes) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource buffer = pp_resource_allocate(PP_RESOURCE_BUFFER, pp_i); struct pp_buffer_s *b = pp_resource_acquire(buffer, PP_RESOURCE_BUFFER); if (!b) { trace_error("%s, failed to create resource\n", __func__); return 0; } b->len = size_in_bytes; b->data = calloc(size_in_bytes, 1); pp_resource_release(buffer); return buffer; } static void ppb_buffer_destroy(void *p) { struct pp_buffer_s *b = p; free(b->data); b->data = NULL; } PP_Bool ppb_buffer_is_buffer(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_BUFFER; } PP_Bool ppb_buffer_describe(PP_Resource resource, uint32_t *size_in_bytes) { struct pp_buffer_s *b = pp_resource_acquire(resource, PP_RESOURCE_BUFFER); if (!b) return PP_FALSE; if (size_in_bytes) *size_in_bytes = b->len; pp_resource_release(resource); return PP_TRUE; } void * ppb_buffer_map(PP_Resource resource) { struct pp_buffer_s *b = pp_resource_acquire(resource, PP_RESOURCE_BUFFER); if (!b) return NULL; ppb_core_add_ref_resource(resource); void *ptr = b->data; pp_resource_release(resource); return ptr; } void ppb_buffer_unmap(PP_Resource resource) { if (ppb_buffer_is_buffer(resource)) ppb_core_release_resource(resource); } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_buffer_create(PP_Instance instance, uint32_t size_in_bytes) { trace_info("[PPB] {full} %s instance=%d, size_in_bytes=%u\n", __func__+6, instance, size_in_bytes); return ppb_buffer_create(instance, size_in_bytes); } TRACE_WRAPPER PP_Bool trace_ppb_buffer_is_buffer(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_buffer_is_buffer(resource); } TRACE_WRAPPER PP_Bool trace_ppb_buffer_describe(PP_Resource resource, uint32_t *size_in_bytes) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_buffer_describe(resource, size_in_bytes); } TRACE_WRAPPER void * trace_ppb_buffer_map(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_buffer_map(resource); } TRACE_WRAPPER void trace_ppb_buffer_unmap(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); ppb_buffer_unmap(resource); } const struct PPB_Buffer_Dev_0_4 ppb_buffer_dev_interface_0_4 = { .Create = TWRAPF(ppb_buffer_create), .IsBuffer = TWRAPF(ppb_buffer_is_buffer), .Describe = TWRAPF(ppb_buffer_describe), .Map = TWRAPF(ppb_buffer_map), .Unmap = TWRAPF(ppb_buffer_unmap), }; static void __attribute__((constructor)) constructor_ppb_buffer(void) { register_interface(PPB_BUFFER_DEV_INTERFACE_0_4, &ppb_buffer_dev_interface_0_4); register_resource(PP_RESOURCE_BUFFER, ppb_buffer_destroy); } freshplayerplugin-0.3.9/src/ppb_buffer.h000066400000000000000000000027661321746453100203610ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include PP_Resource ppb_buffer_create(PP_Instance instance, uint32_t size_in_bytes); PP_Bool ppb_buffer_is_buffer(PP_Resource resource); PP_Bool ppb_buffer_describe(PP_Resource resource, uint32_t *size_in_bytes); void * ppb_buffer_map(PP_Resource resource); void ppb_buffer_unmap(PP_Resource resource); freshplayerplugin-0.3.9/src/ppb_char_set.c000066400000000000000000000243511321746453100206650ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "encoding_alias.h" #include "pp_interface.h" #include "ppb_char_set.h" #include "ppb_memory.h" #include "ppb_var.h" #include "reverse_constant.h" #include "trace_core.h" #include #include #include #include #include #include #include char * ppb_char_set_utf16_to_char_set(PP_Instance instance, const uint16_t *utf16, uint32_t utf16_len, const char *output_char_set, enum PP_CharSet_ConversionError on_error, uint32_t *output_length) { // each character could take up to 4 bytes in UTF-8; with additional zero-terminator byte const uint32_t output_buffer_length = (utf16_len + 1) * 4 + 1; char *output = ppb_memory_mem_alloc(output_buffer_length); if (!output) { trace_error("%s, can't allocate memory, %u bytes\n", __func__, output_buffer_length); goto err; } const char *charset = encoding_alias_get_canonical_name(output_char_set); const UChar subst = '?'; UErrorCode st = U_ZERO_ERROR; UConverter *u = ucnv_open(charset, &st); if (!U_SUCCESS(st)) { trace_error("%s, wrong charset %s\n", __func__, output_char_set); goto err; } switch (on_error) { default: case PP_CHARSET_CONVERSIONERROR_FAIL: st = U_ZERO_ERROR; ucnv_setFromUCallBack(u, UCNV_FROM_U_CALLBACK_STOP, NULL, NULL, NULL, &st); break; case PP_CHARSET_CONVERSIONERROR_SKIP: st = U_ZERO_ERROR; ucnv_setFromUCallBack(u, UCNV_FROM_U_CALLBACK_SKIP, NULL, NULL, NULL, &st); break; case PP_CHARSET_CONVERSIONERROR_SUBSTITUTE: st = U_ZERO_ERROR; ucnv_setFromUCallBack(u, UCNV_FROM_U_CALLBACK_SUBSTITUTE, NULL, NULL, NULL, &st); st = U_ZERO_ERROR; ucnv_setSubstString(u, &subst, 1, &st); break; } *output_length = ucnv_fromUChars(u, output, output_buffer_length, utf16, utf16_len, &st); if (st != U_BUFFER_OVERFLOW_ERROR && !U_SUCCESS(st)) goto err; ucnv_close(u); return output; err: *output_length = 0; ppb_memory_mem_free(output); if (u) ucnv_close(u); return NULL; } uint16_t * ppb_char_set_char_set_to_utf16(PP_Instance instance, const char *input, uint32_t input_len, const char *input_char_set, enum PP_CharSet_ConversionError on_error, uint32_t *output_length) { // each character could be converted into a surrogate pair const uint32_t output_buffer_length = (input_len + 2) * 2 * sizeof(uint16_t); uint16_t *output = ppb_memory_mem_alloc(output_buffer_length); if (!output) { trace_error("%s, can't allocate memory, %u bytes\n", __func__, output_buffer_length); goto err; } const char *charset = encoding_alias_get_canonical_name(input_char_set); const UChar subst = '?'; UErrorCode st = U_ZERO_ERROR; UConverter *u = ucnv_open(charset, &st); if (!U_SUCCESS(st)) { trace_error("%s, wrong charset %s\n", __func__, input_char_set); goto err; } switch (on_error) { default: case PP_CHARSET_CONVERSIONERROR_FAIL: st = U_ZERO_ERROR; ucnv_setToUCallBack(u, UCNV_TO_U_CALLBACK_STOP, NULL, NULL, NULL, &st); break; case PP_CHARSET_CONVERSIONERROR_SKIP: st = U_ZERO_ERROR; ucnv_setToUCallBack(u, UCNV_TO_U_CALLBACK_SKIP, NULL, NULL, NULL, &st); break; case PP_CHARSET_CONVERSIONERROR_SUBSTITUTE: st = U_ZERO_ERROR; ucnv_setToUCallBack(u, UCNV_TO_U_CALLBACK_SUBSTITUTE, NULL, NULL, NULL, &st); st = U_ZERO_ERROR; ucnv_setSubstString(u, &subst, 1, &st); break; } st = U_ZERO_ERROR; *output_length = ucnv_toUChars(u, output, output_buffer_length / sizeof(uint16_t), input, input_len, &st); if (st != U_BUFFER_OVERFLOW_ERROR && !U_SUCCESS(st)) goto err; ucnv_close(u); return output; err: *output_length = 0; ppb_memory_mem_free(output); if (u) ucnv_close(u); return NULL; } static char * extract_relevant_part_from_locale_name(const char *locale_name) { char *lang = strdup(locale_name ? locale_name : "en"); if (strncmp(lang, "zh", 2) == 0) { // starts with zh. For Chinese languages country is required too // replace "_" by "-". That way "zh_CN.utf8" becomes "zh-CN.utf8" char *ptr = strchr(lang, '_'); if (ptr) *ptr = '-'; // cut at ".". That way "zh-CN.utf8" becomes "zh-CN" ptr = strchr(lang, '.'); if (ptr) *ptr = '\0'; return lang; } // otherwise, leave only language. Cut at "_". That makes "ru" from "ru_RU.utf8" char *ptr = strchr(lang, '_'); if (ptr) *ptr = '\0'; return lang; } struct PP_Var ppb_char_set_get_default_char_set(PP_Instance instance) { char *lang = extract_relevant_part_from_locale_name(getenv("LANG")); struct lang_encoding { const char *lang; const char *encoding; }; static const struct lang_encoding pairs[] = { {"am", "windows-1252"}, {"ar", "windows-1256"}, {"bg", "windows-1251"}, {"bn", "windows-1252"}, {"ca", "windows-1252"}, {"cs", "windows-1250"}, {"da", "windows-1252"}, {"de", "windows-1252"}, {"el", "ISO-8859-7"}, {"en", "windows-1252"}, {"es", "windows-1252"}, {"et", "windows-1257"}, {"fa", "windows-1256"}, {"fil", "windows-1252"}, {"fi", "windows-1252"}, {"fr", "windows-1252"}, {"gu", "windows-1252"}, {"he", "windows-1255"}, {"hi", "windows-1252"}, {"hr", "windows-1250"}, {"hu", "ISO-8859-2"}, {"id", "windows-1252"}, {"it", "windows-1252"}, {"ja", "Shift_JIS"}, {"kn", "windows-1252"}, {"ko", "windows-949"}, {"lt", "windows-1257"}, {"lv", "windows-1257"}, {"ml", "windows-1252"}, {"mr", "windows-1252"}, {"nb", "windows-1252"}, {"nl", "windows-1252"}, {"pl", "ISO-8859-2"}, {"pt", "windows-1252"}, {"pt", "windows-1252"}, {"ro", "ISO-8859-2"}, {"ru", "windows-1251"}, {"sk", "windows-1250"}, {"sl", "ISO-8859-2"}, {"sr", "windows-1251"}, {"sv", "windows-1252"}, {"sw", "windows-1252"}, {"ta", "windows-1252"}, {"te", "windows-1252"}, {"th", "windows-874"}, {"tr", "ISO-8859-9"}, {"uk", "windows-1251"}, {"vi", "windows-1258"}, {"zh-CN", "GBK"}, {"zh-TW", "Big5"}, }; const char *enc = "windows-1252"; for (uint32_t k = 0; k < sizeof(pairs)/sizeof(pairs[0]); k ++) { if (strcasecmp(pairs[k].lang, lang) == 0) { enc = pairs[k].encoding; break; } } struct PP_Var ret = ppb_var_var_from_utf8_z(enc); free(lang); return ret; } // trace wrappers TRACE_WRAPPER char * trace_ppb_char_set_utf16_to_char_set(PP_Instance instance, const uint16_t *utf16, uint32_t utf16_len, const char *output_char_set, enum PP_CharSet_ConversionError on_error, uint32_t *output_length) { trace_info("[PPB] {full} %s instance=%d, utf16=%p, utf16_len=%u, output_char_set=%s, " "on_error=%s\n", __func__+6, instance, utf16, utf16_len, output_char_set, reverse_char_set_conversion_error(on_error)); return ppb_char_set_utf16_to_char_set(instance, utf16, utf16_len, output_char_set, on_error, output_length); } TRACE_WRAPPER uint16_t * trace_ppb_char_set_char_set_to_utf16(PP_Instance instance, const char *input, uint32_t input_len, const char *input_char_set, enum PP_CharSet_ConversionError on_error, uint32_t *output_length) { trace_info("[PPB] {full} %s instance=%d, input=%.*s, input_len=%u, input_char_set=%s, " "on_error=%s\n", __func__+6, instance, input_len, input, input_len, input_char_set, reverse_char_set_conversion_error(on_error)); return ppb_char_set_char_set_to_utf16(instance, input, input_len, input_char_set, on_error, output_length); } TRACE_WRAPPER struct PP_Var trace_ppb_char_set_get_default_char_set(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_char_set_get_default_char_set(instance); } const struct PPB_CharSet_Dev_0_4 ppb_char_set_dev_interface_0_4 = { .UTF16ToCharSet = TWRAPF(ppb_char_set_utf16_to_char_set), .CharSetToUTF16 = TWRAPF(ppb_char_set_char_set_to_utf16), .GetDefaultCharSet = TWRAPF(ppb_char_set_get_default_char_set), }; static void __attribute__((constructor)) constructor_ppb_char_set(void) { register_interface(PPB_CHAR_SET_DEV_INTERFACE_0_4, &ppb_char_set_dev_interface_0_4); } freshplayerplugin-0.3.9/src/ppb_char_set.h000066400000000000000000000034411321746453100206670ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include char * ppb_char_set_utf16_to_char_set(PP_Instance instance, const uint16_t *utf16, uint32_t utf16_len, const char *output_char_set, enum PP_CharSet_ConversionError on_error, uint32_t *output_length); uint16_t * ppb_char_set_char_set_to_utf16(PP_Instance instance, const char *input, uint32_t input_len, const char *input_char_set, enum PP_CharSet_ConversionError on_error, uint32_t *output_length); struct PP_Var ppb_char_set_get_default_char_set(PP_Instance instance); freshplayerplugin-0.3.9/src/ppb_core.c000066400000000000000000000171061321746453100200250ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "pp_resource.h" #include "ppb_core.h" #include "ppb_instance.h" #include "ppb_message_loop.h" #include "tables.h" #include "trace_core.h" #include "utils.h" #include #include #include #include #include void ppb_core_add_ref_resource(PP_Resource resource) { pp_resource_ref(resource); } void ppb_core_release_resource(PP_Resource resource) { pp_resource_unref(resource); } PP_Time ppb_core_get_time(void) { struct timespec t; clock_gettime(CLOCK_REALTIME, &t); return t.tv_sec + t.tv_nsec / 1e9; } PP_TimeTicks ppb_core_get_time_ticks(void) { struct timespec t; clock_gettime(CLOCK_REALTIME, &t); return t.tv_sec + t.tv_nsec / 1e9; } void ppb_core_trampoline_to_main_thread(struct PP_CompletionCallback callback, int32_t result, const char *origin) { PP_Resource main_message_loop = ppb_message_loop_get_for_main_thread(); if (main_message_loop == 0) trace_error("%s, no main loop\n", __func__); const int depth = ppb_message_loop_get_depth(main_message_loop); const int32_t delay_in_milliseconds = 0; ppb_message_loop_post_work_with_result(main_message_loop, callback, delay_in_milliseconds, result, depth, origin); } void ppb_core_call_on_main_thread2(int32_t delay_in_milliseconds, struct PP_CompletionCallback callback, int32_t result, const char *origin) { PP_Resource main_message_loop = ppb_message_loop_get_for_main_thread(); if (main_message_loop == 0) trace_error("%s, no main loop\n", __func__); const int depth = 1; ppb_message_loop_post_work_with_result(main_message_loop, callback, delay_in_milliseconds, result, depth, origin); } void ppb_core_call_on_main_thread(int32_t delay_in_milliseconds, struct PP_CompletionCallback callback, int32_t result) { return ppb_core_call_on_main_thread2(delay_in_milliseconds, callback, result, __func__); } struct call_on_browser_thread_task_s { void (*func)(void *); void *user_data; }; static void call_on_browser_thread_comt(void *user_data, int32_t result) { struct call_on_browser_thread_task_s *task = user_data; task->func(task->user_data); g_slice_free(struct call_on_browser_thread_task_s, task); } static void activate_browser_thread_ml_ptac(void *param) { // If task was already executed and queue is empty, ppb_message_loop_run_int() will return // without waiting. PP_Resource m_loop = ppb_message_loop_get_for_browser_thread(); ppb_message_loop_run_int(m_loop, ML_INCREASE_DEPTH | ML_EXIT_ON_EMPTY | ML_NESTED); } // Schedules task for execution on browser thread. // // Since there is no access to browser event loop, we start a nested event loop which is terminated // as long as there is no tasks left. That way we can implement waiting as entering a nested loop // and thus avoid deadlocks. void ppb_core_call_on_browser_thread(PP_Instance instance, void (*func)(void *), void *user_data) { struct call_on_browser_thread_task_s *task = g_slice_alloc(sizeof(*task)); task->func = func; task->user_data = user_data; // Push task into queue. The only purpose is to put task into queue even if message loop // is currently terminating (in teardown state), so we are ignoring that. There are three // possible loop states. Message loop is either running, stopped, or terminating. If it's // still running, task will be executed in the context of that loop. If it's stopped or // stopping right now, task will be pushed to a queue. After that code below will schedule // nested loop on browser thread. PP_Resource m_loop = ppb_message_loop_get_for_browser_thread(); ppb_message_loop_post_work_with_result(m_loop, PP_MakeCCB(call_on_browser_thread_comt, task), 0, PP_OK, 0, __func__); struct pp_instance_s *pp_i = instance ? tables_get_pp_instance(instance) : tables_get_some_pp_instance(); if (!pp_i) { trace_error("%s, no alive instance available\n", __func__); return; } // Schedule activation routine. pthread_mutex_lock(&display.lock); if (pp_i->npp) npn.pluginthreadasynccall(pp_i->npp, activate_browser_thread_ml_ptac, user_data); pthread_mutex_unlock(&display.lock); } PP_Bool ppb_core_is_main_thread(void) { return ppb_message_loop_get_current() == ppb_message_loop_get_for_main_thread(); } // trace wrappers TRACE_WRAPPER void trace_ppb_core_add_ref_resource(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); ppb_core_add_ref_resource(resource); } TRACE_WRAPPER void trace_ppb_core_release_resource(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); ppb_core_release_resource(resource); } TRACE_WRAPPER PP_Time trace_ppb_core_get_time(void) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_core_get_time(); } TRACE_WRAPPER PP_TimeTicks trace_ppb_core_get_time_ticks(void) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_core_get_time_ticks(); } TRACE_WRAPPER void trace_ppb_core_call_on_main_thread(int32_t delay_in_milliseconds, struct PP_CompletionCallback callback, int32_t result) { trace_info("[PPB] {full} %s delay_in_milliseconds=%d, callback={.func=%p, .user_data=%p, " ".flags=%d}, result=%d\n", __func__+6, delay_in_milliseconds, callback.func, callback.user_data, callback.flags, result); ppb_core_call_on_main_thread(delay_in_milliseconds, callback, result); } TRACE_WRAPPER PP_Bool trace_ppb_core_is_main_thread(void) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_core_is_main_thread(); } const struct PPB_Core_1_0 ppb_core_interface_1_0 = { .AddRefResource = TWRAPF(ppb_core_add_ref_resource), .ReleaseResource = TWRAPF(ppb_core_release_resource), .GetTime = TWRAPF(ppb_core_get_time), .GetTimeTicks = TWRAPF(ppb_core_get_time_ticks), .CallOnMainThread = TWRAPF(ppb_core_call_on_main_thread), .IsMainThread = TWRAPF(ppb_core_is_main_thread), }; static void __attribute__((constructor)) constructor_ppb_core(void) { register_interface(PPB_CORE_INTERFACE_1_0, &ppb_core_interface_1_0); } freshplayerplugin-0.3.9/src/ppb_core.h000066400000000000000000000042121321746453100200240ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include void ppb_core_add_ref_resource(PP_Resource resource); void ppb_core_release_resource(PP_Resource resource); PP_Time ppb_core_get_time(void); PP_TimeTicks ppb_core_get_time_ticks(void); void ppb_core_trampoline_to_main_thread(struct PP_CompletionCallback callback, int32_t result, const char *origin); void ppb_core_call_on_main_thread(int32_t delay_in_milliseconds, struct PP_CompletionCallback callback, int32_t result); void ppb_core_call_on_main_thread2(int32_t delay_in_milliseconds, struct PP_CompletionCallback callback, int32_t result, const char *origin); /// schedule task for execution on browser thread /// /// @param instance is optional, pass 0 if there are no instance id available void ppb_core_call_on_browser_thread(PP_Instance instance, void (*func)(void *), void *user_data); PP_Bool ppb_core_is_main_thread(void); freshplayerplugin-0.3.9/src/ppb_crypto.c000066400000000000000000000042041321746453100204100ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "ppb_crypto.h" #include "tables.h" #include "trace_core.h" #include #include void ppb_crypto_get_random_bytes(char *buffer, uint32_t num_bytes) { ssize_t bytes_read = read(tables_get_urandom_fd(), buffer, num_bytes); if (bytes_read < num_bytes) { // can't read from file, falling back to rand() for (uint32_t k = 0; k < num_bytes; k ++) buffer[k] = ((uint32_t)rand() >> 1) & 0xffu; } } // trace wrapper TRACE_WRAPPER void trace_ppb_crypto_get_random_bytes(char *buffer, uint32_t num_bytes) { trace_info("[PPB] {full} %s num_bytes=%d\n", __func__+6, num_bytes); ppb_crypto_get_random_bytes(buffer, num_bytes); } const struct PPB_Crypto_Dev_0_1 ppb_crypto_dev_interface_0_1 = { .GetRandomBytes = TWRAPF(ppb_crypto_get_random_bytes), }; static void __attribute__((constructor)) constructor_ppb_crypto(void) { register_interface(PPB_CRYPTO_DEV_INTERFACE_0_1, &ppb_crypto_dev_interface_0_1); } freshplayerplugin-0.3.9/src/ppb_crypto.h000066400000000000000000000024171321746453100204210ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include void ppb_crypto_get_random_bytes(char *buffer, uint32_t num_bytes); freshplayerplugin-0.3.9/src/ppb_cursor_control.c000066400000000000000000000253331321746453100221530ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "pp_resource.h" #include "ppb_core.h" #include "ppb_cursor_control.h" #include "ppb_image_data.h" #include "ppb_instance.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include #include #include #include #include #include struct comt_param_s { PP_Instance instance_id; int xtype; int hide_cursor; PP_Resource custom_image; int hotspot_x; int hotspot_y; }; static Cursor create_cursor_from_image_data_resource(Display *dpy, Window wnd, PP_Resource image_data, int hotspot_x, int hotspot_y) { struct pp_image_data_s *id = pp_resource_acquire(image_data, PP_RESOURCE_IMAGE_DATA); if (!id) { trace_warning("%s, bad resource\n", __func__); return None; } XcursorImage *cursor_image = XcursorImageCreate(id->width, id->height); cursor_image->xhot = hotspot_x; cursor_image->yhot = hotspot_y; memcpy(cursor_image->pixels, id->data, id->stride * id->height); Cursor cursor = XcursorImageLoadCursor(dpy, cursor_image); XcursorImageDestroy(cursor_image); pp_resource_release(image_data); return cursor; } void set_cursor_ptac(void *user_data) { Window wnd = None; Cursor cursor; struct comt_param_s *params = user_data; struct pp_instance_s *pp_i = tables_get_pp_instance(params->instance_id); if (!pp_i) goto quit; if (pp_i->is_fullscreen) { wnd = pp_i->fs_wnd; } else if (pp_i->windowed_mode) { wnd = pp_i->wnd; } else { if (npn.getvalue(pp_i->npp, NPNVnetscapeWindow, &wnd) != NPERR_NO_ERROR) { trace_error("%s, failed to get NPNnetscapeWindow\n", __func__); wnd = None; } } pthread_mutex_lock(&display.lock); if (params->hide_cursor) { cursor = display.transparent_cursor; } else { if (params->custom_image != 0) { cursor = create_cursor_from_image_data_resource(display.x, wnd, params->custom_image, params->hotspot_x, params->hotspot_y); } else { cursor = XCreateFontCursor(display.x, params->xtype); } } if (wnd != None && cursor != None) { XDefineCursor(display.x, wnd, cursor); XFlush(display.x); // remember to free cursor unless we hid it pp_i->have_prev_cursor = !params->hide_cursor; pp_i->prev_cursor = cursor; } pthread_mutex_unlock(&display.lock); quit: g_slice_free(struct comt_param_s, params); } PP_Bool ppb_cursor_control_set_cursor(PP_Instance instance, enum PP_CursorType_Dev type, PP_Resource custom_image, const struct PP_Point *hot_spot) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_FALSE; } if (!g_atomic_int_get(&pp_i->cursor_inside_instance)) { // avoid changing pointer shape return PP_TRUE; } int xtype = XC_arrow; int hide_cursor = 0; switch (type) { case PP_CURSORTYPE_CUSTOM: xtype = XC_arrow; break; case PP_CURSORTYPE_POINTER: xtype = XC_left_ptr; break; case PP_CURSORTYPE_CROSS: xtype = XC_crosshair; break; case PP_CURSORTYPE_HAND: xtype = XC_hand2; break; case PP_CURSORTYPE_IBEAM: xtype = XC_xterm; break; case PP_CURSORTYPE_WAIT: xtype = XC_watch; break; case PP_CURSORTYPE_HELP: xtype = XC_question_arrow; break; case PP_CURSORTYPE_EASTRESIZE: xtype = XC_right_side; break; case PP_CURSORTYPE_NORTHRESIZE: xtype = XC_top_side; break; case PP_CURSORTYPE_NORTHEASTRESIZE: xtype = XC_top_right_corner; break; case PP_CURSORTYPE_NORTHWESTRESIZE: xtype = XC_top_left_corner; break; case PP_CURSORTYPE_SOUTHRESIZE: xtype = XC_bottom_side; break; case PP_CURSORTYPE_SOUTHEASTRESIZE: xtype = XC_bottom_right_corner; break; case PP_CURSORTYPE_SOUTHWESTRESIZE: xtype = XC_bottom_left_corner; break; case PP_CURSORTYPE_WESTRESIZE: xtype = XC_left_side; break; case PP_CURSORTYPE_NORTHSOUTHRESIZE: xtype = XC_sb_v_double_arrow; break; case PP_CURSORTYPE_EASTWESTRESIZE: xtype = XC_sb_h_double_arrow; break; case PP_CURSORTYPE_NORTHEASTSOUTHWESTRESIZE: xtype = XC_left_ptr; break; case PP_CURSORTYPE_NORTHWESTSOUTHEASTRESIZE: xtype = XC_left_ptr; break; case PP_CURSORTYPE_COLUMNRESIZE: xtype = XC_sb_h_double_arrow; break; case PP_CURSORTYPE_ROWRESIZE: xtype = XC_sb_v_double_arrow; break; case PP_CURSORTYPE_MIDDLEPANNING: xtype = XC_fleur; break; case PP_CURSORTYPE_EASTPANNING: xtype = XC_sb_right_arrow; break; case PP_CURSORTYPE_NORTHPANNING: xtype = XC_sb_up_arrow; break; case PP_CURSORTYPE_NORTHEASTPANNING: xtype = XC_top_right_corner; break; case PP_CURSORTYPE_NORTHWESTPANNING: xtype = XC_top_left_corner; break; case PP_CURSORTYPE_SOUTHPANNING: xtype = XC_sb_down_arrow; break; case PP_CURSORTYPE_SOUTHEASTPANNING: xtype = XC_bottom_right_corner; break; case PP_CURSORTYPE_SOUTHWESTPANNING: xtype = XC_bottom_left_corner; break; case PP_CURSORTYPE_WESTPANNING: xtype = XC_sb_left_arrow; break; case PP_CURSORTYPE_MOVE: xtype = XC_fleur; break; case PP_CURSORTYPE_VERTICALTEXT: xtype = XC_left_ptr; break; case PP_CURSORTYPE_CELL: xtype = XC_left_ptr; break; case PP_CURSORTYPE_CONTEXTMENU: xtype = XC_left_ptr; break; case PP_CURSORTYPE_ALIAS: xtype = XC_left_ptr; break; case PP_CURSORTYPE_PROGRESS: xtype = XC_watch; break; case PP_CURSORTYPE_NODROP: xtype = XC_left_ptr; break; case PP_CURSORTYPE_COPY: xtype = XC_left_ptr; break; case PP_CURSORTYPE_NONE: xtype = XC_left_ptr; hide_cursor = 1; break; case PP_CURSORTYPE_NOTALLOWED: xtype = XC_left_ptr; break; case PP_CURSORTYPE_ZOOMIN: xtype = XC_left_ptr; break; case PP_CURSORTYPE_ZOOMOUT: xtype = XC_left_ptr; break; case PP_CURSORTYPE_GRAB: xtype = XC_left_ptr; break; case PP_CURSORTYPE_GRABBING: xtype = XC_left_ptr; break; } struct comt_param_s *comt_params = g_slice_alloc0(sizeof(*comt_params)); comt_params->instance_id = instance; comt_params->xtype = xtype; comt_params->hide_cursor = hide_cursor; comt_params->custom_image = (type == PP_CURSORTYPE_CUSTOM) ? custom_image : 0; if (hot_spot) { comt_params->hotspot_x = hot_spot->x; comt_params->hotspot_y = hot_spot->y; } ppb_core_call_on_browser_thread(instance, set_cursor_ptac, comt_params); return PP_TRUE; } PP_Bool ppb_cursor_control_lock_cursor(PP_Instance instance) { return PP_TRUE; } PP_Bool ppb_cursor_control_unlock_cursor(PP_Instance instance) { return PP_TRUE; } PP_Bool ppb_cursor_control_has_cursor_lock(PP_Instance instance) { return PP_TRUE; } PP_Bool ppb_cursor_control_can_lock_cursor(PP_Instance instance) { return PP_TRUE; } // trace wrappers TRACE_WRAPPER PP_Bool trace_ppb_cursor_control_set_cursor(PP_Instance instance, enum PP_CursorType_Dev type, PP_Resource custom_image, const struct PP_Point *hot_spot) { char *s_hot_spot = trace_point_as_string(hot_spot); trace_info("[PPB] {full} %s instance=%d, type=%d, custom_image=%d, hot_spot=%s\n", __func__+6, instance, type, custom_image, s_hot_spot); g_free(s_hot_spot); return ppb_cursor_control_set_cursor(instance, type, custom_image, hot_spot); } TRACE_WRAPPER PP_Bool trace_ppb_cursor_control_lock_cursor(PP_Instance instance) { trace_info("[PPB] {zilch} %s instance=%d\n", __func__+6, instance); return ppb_cursor_control_lock_cursor(instance); } TRACE_WRAPPER PP_Bool trace_ppb_cursor_control_unlock_cursor(PP_Instance instance) { trace_info("[PPB] {zilch} %s instance=%d\n", __func__+6, instance); return ppb_cursor_control_unlock_cursor(instance); } TRACE_WRAPPER PP_Bool trace_ppb_cursor_control_has_cursor_lock(PP_Instance instance) { trace_info("[PPB] {zilch} %s instance=%d\n", __func__+6, instance); return ppb_cursor_control_has_cursor_lock(instance); } TRACE_WRAPPER PP_Bool trace_ppb_cursor_control_can_lock_cursor(PP_Instance instance) { trace_info("[PPB] {zilch} %s instance=%d\n", __func__+6, instance); return ppb_cursor_control_can_lock_cursor(instance); } const struct PPB_CursorControl_Dev_0_4 ppb_cursor_control_dev_interface_0_4 = { .SetCursor = TWRAPF(ppb_cursor_control_set_cursor), .LockCursor = TWRAPZ(ppb_cursor_control_lock_cursor), .UnlockCursor = TWRAPZ(ppb_cursor_control_unlock_cursor), .HasCursorLock = TWRAPZ(ppb_cursor_control_has_cursor_lock), .CanLockCursor = TWRAPZ(ppb_cursor_control_can_lock_cursor), }; static void __attribute__((constructor)) constructor_ppb_cursor_control(void) { register_interface(PPB_CURSOR_CONTROL_DEV_INTERFACE_0_4, &ppb_cursor_control_dev_interface_0_4); } freshplayerplugin-0.3.9/src/ppb_cursor_control.h000066400000000000000000000032141321746453100221520ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include PP_Bool ppb_cursor_control_set_cursor(PP_Instance instance, enum PP_CursorType_Dev type, PP_Resource custom_image, const struct PP_Point *hot_spot); PP_Bool ppb_cursor_control_lock_cursor(PP_Instance instance); PP_Bool ppb_cursor_control_unlock_cursor(PP_Instance instance); PP_Bool ppb_cursor_control_has_cursor_lock(PP_Instance instance); PP_Bool ppb_cursor_control_can_lock_cursor(PP_Instance instance); freshplayerplugin-0.3.9/src/ppb_device_ref.c000066400000000000000000000115321321746453100211650ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "pp_resource.h" #include "ppb_device_ref.h" #include "ppb_var.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" struct pp_device_ref_s { COMMON_STRUCTURE_FIELDS struct PP_Var name; struct PP_Var longname; PP_DeviceType_Dev type; }; STATIC_ASSERT(sizeof(struct pp_device_ref_s) <= LARGEST_RESOURCE_SIZE); PP_Resource ppb_device_ref_create(PP_Instance instance, struct PP_Var name, struct PP_Var longname, PP_DeviceType_Dev type) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource device_ref = pp_resource_allocate(PP_RESOURCE_DEVICE_REF, pp_i); struct pp_device_ref_s *dr = pp_resource_acquire(device_ref, PP_RESOURCE_DEVICE_REF); if (!dr) { trace_error("%s, resource allocation failure\n", __func__); return 0; } // no type checking is perfomed as it's an internal function dr->name = ppb_var_add_ref2(name); dr->longname = ppb_var_add_ref2(longname); dr->type = type; pp_resource_release(device_ref); return device_ref; } static void ppb_device_ref_destroy(void *ptr) { struct pp_device_ref_s *dr = ptr; ppb_var_release(dr->name); ppb_var_release(dr->longname); } PP_Bool ppb_device_ref_is_device_ref(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_DEVICE_REF; } PP_DeviceType_Dev ppb_device_ref_get_type(PP_Resource device_ref) { struct pp_device_ref_s *dr = pp_resource_acquire(device_ref, PP_RESOURCE_DEVICE_REF); if (!dr) { trace_error("%s, bad resource\n", __func__); return PP_DEVICETYPE_DEV_INVALID; } PP_DeviceType_Dev type = dr->type; pp_resource_release(device_ref); return type; } struct PP_Var ppb_device_ref_get_name(PP_Resource device_ref) { struct pp_device_ref_s *dr = pp_resource_acquire(device_ref, PP_RESOURCE_DEVICE_REF); if (!dr) { trace_error("%s, bad resource\n", __func__); return PP_MakeUndefined(); } struct PP_Var name = ppb_var_add_ref2(dr->name); pp_resource_release(device_ref); return name; } struct PP_Var ppb_device_ref_get_longname(PP_Resource device_ref) { struct pp_device_ref_s *dr = pp_resource_acquire(device_ref, PP_RESOURCE_DEVICE_REF); if (!dr) { trace_error("%s, bad resource\n", __func__); return PP_MakeUndefined(); } struct PP_Var name = ppb_var_add_ref2(dr->longname); pp_resource_release(device_ref); return name; } // trace wrappers TRACE_WRAPPER PP_Bool trace_ppb_device_ref_is_device_ref(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_device_ref_is_device_ref(resource); } TRACE_WRAPPER PP_DeviceType_Dev trace_ppb_device_ref_get_type(PP_Resource device_ref) { trace_info("[PPB] {full} %s device_ref=%d\n", __func__+6, device_ref); return ppb_device_ref_get_type(device_ref); } TRACE_WRAPPER struct PP_Var trace_ppb_device_ref_get_name(PP_Resource device_ref) { trace_info("[PPB] {full} %s device_ref=%d\n", __func__+6, device_ref); return ppb_device_ref_get_name(device_ref); } const struct PPB_DeviceRef_Dev_0_1 ppb_device_ref_dev_interface_0_1 = { .IsDeviceRef = TWRAPF(ppb_device_ref_is_device_ref), .GetType = TWRAPF(ppb_device_ref_get_type), .GetName = TWRAPF(ppb_device_ref_get_name), }; static void __attribute__((constructor)) constructor_ppb_device_ref(void) { register_interface(PPB_DEVICEREF_DEV_INTERFACE_0_1, &ppb_device_ref_dev_interface_0_1); register_resource(PP_RESOURCE_DEVICE_REF, ppb_device_ref_destroy); } freshplayerplugin-0.3.9/src/ppb_device_ref.h000066400000000000000000000032101321746453100211640ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include PP_Resource ppb_device_ref_create(PP_Instance instance, struct PP_Var name, struct PP_Var longname, PP_DeviceType_Dev type); PP_Bool ppb_device_ref_is_device_ref(PP_Resource resource); PP_DeviceType_Dev ppb_device_ref_get_type(PP_Resource device_ref); struct PP_Var ppb_device_ref_get_name(PP_Resource device_ref); struct PP_Var ppb_device_ref_get_longname(PP_Resource device_ref); freshplayerplugin-0.3.9/src/ppb_file_chooser.c000066400000000000000000000254401321746453100215360ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "gtk_wrapper.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_core.h" #include "ppb_file_chooser.h" #include "ppb_file_ref.h" #include "ppb_instance.h" #include "ppb_message_loop.h" #include "ppb_var.h" #include "reverse_constant.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include #include #include #include struct pp_file_chooser_s { COMMON_STRUCTURE_FIELDS PP_FileChooserMode_Dev mode; struct PP_Var accept_types; }; STATIC_ASSERT(sizeof(struct pp_file_chooser_s) <= LARGEST_RESOURCE_SIZE); PP_Resource ppb_file_chooser_create(PP_Instance instance, PP_FileChooserMode_Dev mode, struct PP_Var accept_types) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource file_chooser = pp_resource_allocate(PP_RESOURCE_FILE_CHOOSER, pp_i); struct pp_file_chooser_s *fc = pp_resource_acquire(file_chooser, PP_RESOURCE_FILE_CHOOSER); if (!fc) { trace_error("%s, failed to create file chooser resource\n", __func__); return 0; } fc->mode = mode; fc->accept_types = accept_types; ppb_var_add_ref(accept_types); pp_resource_release(file_chooser); return file_chooser; } static void ppb_file_chooser_destroy(void *p) { struct pp_file_chooser_s *fc = p; ppb_var_release(fc->accept_types); } PP_Bool ppb_file_chooser_is_file_chooser(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_FILE_CHOOSER; } int32_t ppb_file_chooser_show(PP_Resource chooser, struct PP_ArrayOutput output, struct PP_CompletionCallback callback) { return 0; } struct show_param_s { struct pp_instance_s *pp_i; PP_Bool save_as; struct PP_Var suggested_file_name; struct PP_ArrayOutput output; struct PP_CompletionCallback ccb; PP_FileChooserMode_Dev mode; struct PP_Var accept_types; PP_Resource chooser_id; PP_Resource message_loop; int dialog_closed; }; static void fcd_response_handler(GtkDialog *dialog, gint response_id, gpointer user_data) { struct show_param_s *p = user_data; int32_t callback_result; if (response_id == GTK_RESPONSE_OK) { PP_Resource *file_refs, *file_ref; GSList *fname_lst = gw_gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog)); guint cnt = g_slist_length(fname_lst); callback_result = PP_OK; file_refs = p->output.GetDataBuffer(p->output.user_data, cnt, sizeof(PP_Resource)); // TODO: what to do if file_refs == NULL? GSList *ll = fname_lst; file_ref = file_refs; while (ll) { *file_ref = ppb_file_ref_create_unrestricted((char *)ll->data, !p->save_as); ll = g_slist_next(ll); file_ref ++; } g_slist_free(fname_lst); } else { callback_result = PP_ERROR_USERCANCEL; } if (!p->dialog_closed) gw_gtk_widget_destroy(GTK_WIDGET(dialog)); ppb_message_loop_post_work_with_result(p->message_loop, p->ccb, 0, callback_result, 0, __func__); ppb_core_release_resource(p->chooser_id); g_slice_free(struct show_param_s, p); } static void fcd_close_handler(GtkDialog *arg0, gpointer user_data) { struct show_param_s *p = user_data; p->dialog_closed = 1; } static void show_without_user_guesture_ptac(void *param) { struct show_param_s *p = param; GtkWidget *fcd; const char *dialog_title; if (p->save_as) { dialog_title = "Save file"; } else if (p->mode == PP_FILECHOOSERMODE_OPENMULTIPLE) { dialog_title = "Open files"; } else { dialog_title = "Open file"; } const int gtk_version = gw_major_version(); void *open_button_title = gtk_version == 2 ? "gtk-open" : "_Open"; void *close_button_title = gtk_version == 2 ? "gtk-close" : "_Close"; fcd = gw_gtk_file_chooser_dialog_new(dialog_title, NULL, p->save_as ? GTK_FILE_CHOOSER_ACTION_SAVE : GTK_FILE_CHOOSER_ACTION_OPEN, close_button_title, GTK_RESPONSE_CANCEL, open_button_title, GTK_RESPONSE_OK, NULL); if (p->mode == PP_FILECHOOSERMODE_OPENMULTIPLE) gw_gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(fcd), 1); gw_gtk_widget_realize(fcd); Window parent_wnd; if (npn.getvalue(p->pp_i->npp, NPNVnetscapeWindow, &parent_wnd) == NPERR_NO_ERROR) { GdkWindow *fcd_wnd = gw_gtk_widget_get_window(fcd); XSetTransientForHint(GDK_WINDOW_XDISPLAY(fcd_wnd), GDK_WINDOW_XID(fcd_wnd), parent_wnd); } else { trace_error("%s, failed to get NPNVnetscapeWindow\n", __func__); } g_signal_connect(G_OBJECT(fcd), "response", G_CALLBACK(fcd_response_handler), p); g_signal_connect(G_OBJECT(fcd), "close", G_CALLBACK(fcd_close_handler), p); gw_gtk_widget_show(fcd); } int32_t ppb_file_chooser_show_without_user_gesture(PP_Resource chooser, PP_Bool save_as, struct PP_Var suggested_file_name, struct PP_ArrayOutput output, struct PP_CompletionCallback callback) { struct pp_file_chooser_s *fc = pp_resource_acquire(chooser, PP_RESOURCE_FILE_CHOOSER); if (!fc) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } struct show_param_s *p = g_slice_alloc0(sizeof(*p)); p->pp_i = fc->instance; p->save_as = save_as; p->suggested_file_name = ppb_var_add_ref2(suggested_file_name); p->output = output; p->ccb = callback; p->mode = fc->mode; p->accept_types = ppb_var_add_ref2(fc->accept_types); p->chooser_id = chooser; p->message_loop = ppb_message_loop_get_current(); ppb_core_add_ref_resource(chooser); ppb_core_call_on_browser_thread(p->pp_i->id, show_without_user_guesture_ptac, p); pp_resource_release(chooser); return PP_OK_COMPLETIONPENDING; } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_file_chooser_create(PP_Instance instance, PP_FileChooserMode_Dev mode, struct PP_Var accept_types) { gchar *s_accept_types = trace_var_as_string(accept_types); trace_info("[PPB] {full} %s instance=%d, mode=%s(%u), accept_types=%s\n", __func__+6, instance, reverse_file_chooser_mode(mode), mode, s_accept_types); g_free(s_accept_types); return ppb_file_chooser_create(instance, mode, accept_types); } TRACE_WRAPPER PP_Bool trace_ppb_file_chooser_is_file_chooser(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_file_chooser_is_file_chooser(resource); } TRACE_WRAPPER int32_t trace_ppb_file_chooser_show(PP_Resource chooser, struct PP_ArrayOutput output, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s chooser=%d, output={.GetDataBuffer=%p, .user_data=%p}, " "callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, chooser, output.GetDataBuffer, output.user_data, callback.func, callback.user_data, callback.flags); return ppb_file_chooser_show(chooser, output, callback); } TRACE_WRAPPER int32_t trace_ppb_file_chooser_show_without_user_gesture(PP_Resource chooser, PP_Bool save_as, struct PP_Var suggested_file_name, struct PP_ArrayOutput output, struct PP_CompletionCallback callback) { gchar *s_suggested_file_name = trace_var_as_string(suggested_file_name); trace_info("[PPB] {full} %s chooser=%d, save_as=%u, suggested_file_name=%s, output=" "{.GetDataBuffer=%p, .user_data=%p}, callback={.func=%p, .user_data=%p, " ".flags=%u}\n", __func__+6, chooser, save_as, s_suggested_file_name, output.GetDataBuffer, output.user_data, callback.func, callback.user_data, callback.flags); g_free(s_suggested_file_name); return ppb_file_chooser_show_without_user_gesture(chooser, save_as, suggested_file_name, output, callback); } const struct PPB_FileChooser_Dev_0_6 ppb_file_chooser_dev_interface_0_6 = { .Create = TWRAPF(ppb_file_chooser_create), .IsFileChooser = TWRAPF(ppb_file_chooser_is_file_chooser), .Show = TWRAPZ(ppb_file_chooser_show), }; const struct PPB_FileChooserTrusted_0_6 ppb_file_chooser_trusted_interface_0_6 = { .ShowWithoutUserGesture = TWRAPF(ppb_file_chooser_show_without_user_gesture), }; static void __attribute__((constructor)) constructor_ppb_file_chooser(void) { register_interface(PPB_FILECHOOSER_DEV_INTERFACE_0_6, &ppb_file_chooser_dev_interface_0_6); register_interface(PPB_FILECHOOSER_TRUSTED_INTERFACE_0_6, &ppb_file_chooser_trusted_interface_0_6); register_resource(PP_RESOURCE_FILE_CHOOSER, ppb_file_chooser_destroy); } freshplayerplugin-0.3.9/src/ppb_file_chooser.h000066400000000000000000000036501321746453100215420ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include PP_Resource ppb_file_chooser_create(PP_Instance instance, PP_FileChooserMode_Dev mode, struct PP_Var accept_types); PP_Bool ppb_file_chooser_is_file_chooser(PP_Resource resource); int32_t ppb_file_chooser_show(PP_Resource chooser, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); int32_t ppb_file_chooser_show_without_user_gesture(PP_Resource chooser, PP_Bool save_as, struct PP_Var suggested_file_name, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); freshplayerplugin-0.3.9/src/ppb_file_io.c000066400000000000000000000277101321746453100205050ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "pp_resource.h" #include "ppb_file_io.h" #include "ppb_file_ref.h" #include "ppb_message_loop.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include #include #include #include struct pp_file_io_s { COMMON_STRUCTURE_FIELDS int fd; }; STATIC_ASSERT(sizeof(struct pp_file_io_s) <= LARGEST_RESOURCE_SIZE); int32_t ppb_file_io_request_os_file_handle(PP_Resource file_io, PP_FileHandle *handle, struct PP_CompletionCallback callback) { struct pp_file_io_s *fio = pp_resource_acquire(file_io, PP_RESOURCE_FILE_IO); if (!fio) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } *handle = fio->fd; ppb_message_loop_post_work_with_result(ppb_message_loop_get_current(), callback, 0, PP_OK, 0, __func__); pp_resource_release(file_io); return PP_OK; } PP_Resource ppb_file_io_create(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource file_io = pp_resource_allocate(PP_RESOURCE_FILE_IO, pp_i); struct pp_file_io_s *fio = pp_resource_acquire(file_io, PP_RESOURCE_FILE_IO); if (!fio) { trace_error("%s, resource allocation failure\n", __func__); return 0; } fio->fd = -1; pp_resource_release(file_io); return file_io; } static void ppb_file_io_destroy(void *p) { struct pp_file_io_s *fio = p; if (fio->fd >= 0) close(fio->fd); } PP_Bool ppb_file_io_is_file_io(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_FILE_IO; } int32_t ppb_file_io_open(PP_Resource file_io, PP_Resource file_ref, int32_t open_flags, struct PP_CompletionCallback callback) { int32_t retval; struct pp_file_io_s *fio = pp_resource_acquire(file_io, PP_RESOURCE_FILE_IO); if (!fio) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } struct pp_file_ref_s *fr = pp_resource_acquire(file_ref, PP_RESOURCE_FILE_REF); if (!fr) { trace_error("%s, bad resource\n", __func__); pp_resource_release(file_io); return PP_ERROR_BADRESOURCE; } switch (fr->type) { case PP_FILE_REF_TYPE_FD: fio->fd = dup(fr->fd); if (fio->fd >= 0) { if (lseek(fio->fd, 0, SEEK_SET) == (off_t) -1) { retval = PP_ERROR_FAILED; goto out; } } else { retval = PP_ERROR_FAILED; goto out; } break; default: trace_error("%s, fr->type not implemented\n", __func__); retval = PP_ERROR_FAILED; goto out; } ppb_message_loop_post_work_with_result(ppb_message_loop_get_current(), callback, 0, PP_OK, 0, __func__); retval = PP_OK_COMPLETIONPENDING; out: pp_resource_release(file_io); pp_resource_release(file_ref); return retval; } int32_t ppb_file_io_query(PP_Resource file_io, struct PP_FileInfo *info, struct PP_CompletionCallback callback) { return PP_OK; } int32_t ppb_file_io_touch(PP_Resource file_io, PP_Time last_access_time, PP_Time last_modified_time, struct PP_CompletionCallback callback) { return PP_OK; } int32_t ppb_file_io_read(PP_Resource file_io, int64_t offset, char *buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback) { return PP_OK; } int32_t ppb_file_io_write(PP_Resource file_io, int64_t offset, const char *buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback) { return PP_OK; } int32_t ppb_file_io_set_length(PP_Resource file_io, int64_t length, struct PP_CompletionCallback callback) { return PP_OK; } int32_t ppb_file_io_flush(PP_Resource file_io, struct PP_CompletionCallback callback) { return PP_OK; } void ppb_file_io_close(PP_Resource file_io) { } int32_t ppb_file_io_read_to_array(PP_Resource file_io, int64_t offset, int32_t max_read_length, struct PP_ArrayOutput *output, struct PP_CompletionCallback callback) { return PP_OK; } // trace wrappers TRACE_WRAPPER int32_t trace_ppb_file_io_request_os_file_handle(PP_Resource file_io, PP_FileHandle *handle, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s file_io=%d, callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, file_io, callback.func, callback.user_data, callback.flags); return ppb_file_io_request_os_file_handle(file_io, handle, callback); } TRACE_WRAPPER PP_Resource trace_ppb_file_io_create(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_file_io_create(instance); } TRACE_WRAPPER PP_Bool trace_ppb_file_io_is_file_io(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_file_io_is_file_io(resource); } TRACE_WRAPPER int32_t trace_ppb_file_io_open(PP_Resource file_io, PP_Resource file_ref, int32_t open_flags, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s file_io=%d, file_ref=%d, open_flags=%u, callback={.func=%p, " ".user_data=%p, .flags=%u}\n", __func__+6, file_io, file_ref, open_flags, callback.func, callback.user_data, callback.flags); return ppb_file_io_open(file_io, file_ref, open_flags, callback); } TRACE_WRAPPER int32_t trace_ppb_file_io_query(PP_Resource file_io, struct PP_FileInfo *info, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s file_io=%d, callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, file_io, callback.func, callback.user_data, callback.flags); return ppb_file_io_query(file_io, info, callback); } TRACE_WRAPPER int32_t trace_ppb_file_io_touch(PP_Resource file_io, PP_Time last_access_time, PP_Time last_modified_time, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s file_io=%d, last_access_time=%f, last_modified_time=%f, " "callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, file_io, last_access_time, last_modified_time, callback.func, callback.user_data, callback.flags); return ppb_file_io_touch(file_io, last_access_time, last_modified_time, callback); } TRACE_WRAPPER int32_t trace_ppb_file_io_read(PP_Resource file_io, int64_t offset, char *buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s file_io=%d, offset=%"PRId64", bytes_to_read=%d, " "callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, file_io, offset, bytes_to_read, callback.func, callback.user_data, callback.flags); return ppb_file_io_read(file_io, offset, buffer, bytes_to_read, callback); } TRACE_WRAPPER int32_t trace_ppb_file_io_write(PP_Resource file_io, int64_t offset, const char *buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s file_io=%d, offset=%"PRId64", bytes_to_write=%d, " "callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, file_io, offset, bytes_to_write, callback.func, callback.user_data, callback.flags); return ppb_file_io_write(file_io, offset, buffer, bytes_to_write, callback); } TRACE_WRAPPER int32_t trace_ppb_file_io_set_length(PP_Resource file_io, int64_t length, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s file_io=%d, length=%"PRId64", callback={.func=%p, .user_data=%p, " ".flags=%u}\n", __func__+6, file_io, length, callback.func, callback.user_data, callback.flags); return ppb_file_io_set_length(file_io, length, callback); } TRACE_WRAPPER int32_t trace_ppb_file_io_flush(PP_Resource file_io, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s file_io=%d, callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, file_io, callback.func, callback.user_data, callback.flags); return ppb_file_io_flush(file_io, callback); } TRACE_WRAPPER void trace_ppb_file_io_close(PP_Resource file_io) { trace_info("[PPB] {zilch} %s file_io=%d\n", __func__+6, file_io); return ppb_file_io_close(file_io); } TRACE_WRAPPER int32_t trace_ppb_file_io_read_to_array(PP_Resource file_io, int64_t offset, int32_t max_read_length, struct PP_ArrayOutput *output, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s file_io=%d, offset=%"PRId64", max_read_length=%d, " "callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, file_io, offset, max_read_length, callback.func, callback.user_data, callback.flags); return ppb_file_io_read_to_array(file_io, offset, max_read_length, output, callback); } const struct PPB_FileIO_Private_0_1 ppb_file_io_private_interface_0_1 = { .RequestOSFileHandle = TWRAPF(ppb_file_io_request_os_file_handle), }; const struct PPB_FileIO_1_1 ppb_file_io_interface_1_1 = { .Create = TWRAPF(ppb_file_io_create), .IsFileIO = TWRAPF(ppb_file_io_is_file_io), .Open = TWRAPF(ppb_file_io_open), .Query = TWRAPZ(ppb_file_io_query), .Touch = TWRAPZ(ppb_file_io_touch), .Read = TWRAPZ(ppb_file_io_read), .Write = TWRAPZ(ppb_file_io_write), .SetLength = TWRAPZ(ppb_file_io_set_length), .Flush = TWRAPZ(ppb_file_io_flush), .Close = TWRAPZ(ppb_file_io_close), .ReadToArray = TWRAPZ(ppb_file_io_read_to_array), }; const struct PPB_FileIO_1_0 ppb_file_io_interface_1_0 = { .Create = TWRAPF(ppb_file_io_create), .IsFileIO = TWRAPF(ppb_file_io_is_file_io), .Open = TWRAPF(ppb_file_io_open), .Query = TWRAPZ(ppb_file_io_query), .Touch = TWRAPZ(ppb_file_io_touch), .Read = TWRAPZ(ppb_file_io_read), .Write = TWRAPZ(ppb_file_io_write), .SetLength = TWRAPZ(ppb_file_io_set_length), .Flush = TWRAPZ(ppb_file_io_flush), .Close = TWRAPZ(ppb_file_io_close), }; static void __attribute__((constructor)) constructor_ppb_file_io(void) { register_interface(PPB_FILEIO_PRIVATE_INTERFACE_0_1, &ppb_file_io_private_interface_0_1); register_interface(PPB_FILEIO_INTERFACE_1_0, &ppb_file_io_interface_1_0); register_interface(PPB_FILEIO_INTERFACE_1_1, &ppb_file_io_interface_1_1); register_resource(PP_RESOURCE_FILE_IO, ppb_file_io_destroy); } freshplayerplugin-0.3.9/src/ppb_file_io.h000066400000000000000000000052631321746453100205110ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include int32_t ppb_file_io_request_os_file_handle(PP_Resource file_io, PP_FileHandle *handle, struct PP_CompletionCallback callback); PP_Resource ppb_file_io_create(PP_Instance instance); PP_Bool ppb_file_io_is_file_io(PP_Resource resource); int32_t ppb_file_io_open(PP_Resource file_io, PP_Resource file_ref, int32_t open_flags, struct PP_CompletionCallback callback); int32_t ppb_file_io_query(PP_Resource file_io, struct PP_FileInfo *info, struct PP_CompletionCallback callback); int32_t ppb_file_io_touch(PP_Resource file_io, PP_Time last_access_time, PP_Time last_modified_time, struct PP_CompletionCallback callback); int32_t ppb_file_io_read(PP_Resource file_io, int64_t offset, char *buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback); int32_t ppb_file_io_write(PP_Resource file_io, int64_t offset, const char *buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback); int32_t ppb_file_io_set_length(PP_Resource file_io, int64_t length, struct PP_CompletionCallback callback); int32_t ppb_file_io_flush(PP_Resource file_io, struct PP_CompletionCallback callback); void ppb_file_io_close(PP_Resource file_io); int32_t ppb_file_io_read_to_array(PP_Resource file_io, int64_t offset, int32_t max_read_length, struct PP_ArrayOutput *output, struct PP_CompletionCallback callback); freshplayerplugin-0.3.9/src/ppb_file_ref.c000066400000000000000000000276551321746453100206620ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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. */ #define _FILE_OFFSET_BITS 64 #define _GNU_SOURCE // for basename() #include "pp_interface.h" #include "ppb_file_ref.h" #include "ppb_var.h" #include "static_assert.h" #include "trace_core.h" #include "utils.h" #include #include #include #include STATIC_ASSERT(sizeof(struct pp_file_ref_s) <= LARGEST_RESOURCE_SIZE); PP_Resource ppb_file_ref_create(PP_Resource file_system, const char *path) { return PP_ERROR_FAILED; } PP_Resource ppb_file_ref_create_unrestricted(const char *path, int read_only) { // TODO: should PP_Instance be required parameter here? PP_Resource file_ref = pp_resource_allocate(PP_RESOURCE_FILE_REF, NULL); struct pp_file_ref_s *fr = pp_resource_acquire(file_ref, PP_RESOURCE_FILE_REF); if (!fr) { trace_error("%s, resource allocation failure\n", __func__); return 0; } fr->type = PP_FILE_REF_TYPE_NAME; fr->path = nullsafe_strdup(path); pp_resource_release(file_ref); return file_ref; } static void ppb_file_ref_destroy(void *p) { struct pp_file_ref_s *fr = p; if (fr->type == PP_FILE_REF_TYPE_FD) close(fr->fd); free(fr->path); } PP_Bool ppb_file_ref_is_file_ref(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_FILE_REF; } PP_FileSystemType ppb_file_ref_get_file_system_type(PP_Resource file_ref) { return PP_ERROR_FAILED; } struct PP_Var ppb_file_ref_get_name(PP_Resource file_ref) { struct pp_file_ref_s *fr = pp_resource_acquire(file_ref, PP_RESOURCE_FILE_REF); if (!fr) { trace_error("%s, bad resource\n", __func__); return PP_MakeUndefined(); } struct PP_Var var = PP_MakeUndefined(); char *path = strdup(fr->path ? fr->path : ""); if (!path) goto quit; var = ppb_var_var_from_utf8_z(basename(path)); free(path); quit: pp_resource_release(file_ref); return var; } struct PP_Var ppb_file_ref_get_path(PP_Resource file_ref) { struct pp_file_ref_s *fr = pp_resource_acquire(file_ref, PP_RESOURCE_FILE_REF); if (!fr) { trace_error("%s, bad resource\n", __func__); return PP_MakeUndefined(); } struct PP_Var var = ppb_var_var_from_utf8_z(fr->path); pp_resource_release(file_ref); return var; } PP_Resource ppb_file_ref_get_parent(PP_Resource file_ref) { return PP_ERROR_FAILED; } int32_t ppb_file_ref_make_directory(PP_Resource directory_ref, PP_Bool make_ancestors, struct PP_CompletionCallback callback) { return PP_ERROR_FAILED; } int32_t ppb_file_ref_make_directory_1_2(PP_Resource directory_ref, int32_t make_directory_flags, struct PP_CompletionCallback callback) { return PP_ERROR_FAILED; } int32_t ppb_file_ref_touch(PP_Resource file_ref, PP_Time last_access_time, PP_Time last_modified_time, struct PP_CompletionCallback callback) { return PP_ERROR_FAILED; } int32_t ppb_file_ref_delete(PP_Resource file_ref, struct PP_CompletionCallback callback) { return PP_ERROR_FAILED; } int32_t ppb_file_ref_rename(PP_Resource file_ref, PP_Resource new_file_ref, struct PP_CompletionCallback callback) { return PP_ERROR_FAILED; } int32_t ppb_file_ref_query(PP_Resource file_ref, struct PP_FileInfo *info, struct PP_CompletionCallback callback) { return PP_ERROR_FAILED; } int32_t ppb_file_ref_read_directory_entries(PP_Resource file_ref, struct PP_ArrayOutput output, struct PP_CompletionCallback callback) { return PP_ERROR_FAILED; } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_file_ref_create(PP_Resource file_system, const char *path) { trace_info("[PPB] {zilch} %s file_system=%d, path=%s\n", __func__+6, file_system, path); return ppb_file_ref_create(file_system, path); } TRACE_WRAPPER PP_Bool trace_ppb_file_ref_is_file_ref(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_file_ref_is_file_ref(resource); } TRACE_WRAPPER PP_FileSystemType trace_ppb_file_ref_get_file_system_type(PP_Resource file_ref) { trace_info("[PPB] {zilch} %s file_ref=%d\n", __func__+6, file_ref); return ppb_file_ref_get_file_system_type(file_ref); } TRACE_WRAPPER struct PP_Var trace_ppb_file_ref_get_name(PP_Resource file_ref) { trace_info("[PPB] {full} %s file_ref=%d\n", __func__+6, file_ref); return ppb_file_ref_get_name(file_ref); } TRACE_WRAPPER struct PP_Var trace_ppb_file_ref_get_path(PP_Resource file_ref) { trace_info("[PPB] {full} %s file_ref=%d\n", __func__+6, file_ref); return ppb_file_ref_get_path(file_ref); } TRACE_WRAPPER PP_Resource trace_ppb_file_ref_get_parent(PP_Resource file_ref) { trace_info("[PPB] {zilch} %s file_ref=%d\n", __func__+6, file_ref); return ppb_file_ref_get_parent(file_ref); } TRACE_WRAPPER int32_t trace_ppb_file_ref_make_directory(PP_Resource directory_ref, PP_Bool make_ancestors, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s directory_ref=%d, make_ancestors=%u, callback={.func=%p, " ".user_data=%p, .flags=%u}\n", __func__+6, directory_ref, make_ancestors, callback.func, callback.user_data, callback.flags); return ppb_file_ref_make_directory(directory_ref, make_ancestors, callback); } TRACE_WRAPPER int32_t trace_ppb_file_ref_make_directory_1_2(PP_Resource directory_ref, int32_t make_directory_flags, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s directory_ref=%d, make_directory_flags=%d, callback={.func=%p, " ".user_data=%p, .flags=%u}\n", __func__+6, directory_ref, make_directory_flags, callback.func, callback.user_data, callback.flags); return ppb_file_ref_make_directory_1_2(directory_ref, make_directory_flags, callback); } TRACE_WRAPPER int32_t trace_ppb_file_ref_touch(PP_Resource file_ref, PP_Time last_access_time, PP_Time last_modified_time, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s file_ref=%d, last_access_time=%f, last_modified_time=%f, " "callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, file_ref, last_access_time, last_modified_time, callback.func, callback.user_data, callback.flags); return ppb_file_ref_touch(file_ref, last_access_time, last_modified_time, callback); } TRACE_WRAPPER int32_t trace_ppb_file_ref_delete(PP_Resource file_ref, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s file_ref=%d, callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, file_ref, callback.func, callback.user_data, callback.flags); return ppb_file_ref_delete(file_ref, callback); } TRACE_WRAPPER int32_t trace_ppb_file_ref_rename(PP_Resource file_ref, PP_Resource new_file_ref, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s file_ref=%d, new_file_ref=%d, callback={.func=%p, .user_data=%p, " ".flags=%u}\n", __func__+6, file_ref, new_file_ref, callback.func, callback.user_data, callback.flags); return ppb_file_ref_rename(file_ref, new_file_ref, callback); } TRACE_WRAPPER int32_t trace_ppb_file_ref_query(PP_Resource file_ref, struct PP_FileInfo *info, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s file_ref=%d, callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, file_ref, callback.func, callback.user_data, callback.flags); return ppb_file_ref_query(file_ref, info, callback); } TRACE_WRAPPER int32_t trace_ppb_file_ref_read_directory_entries(PP_Resource file_ref, struct PP_ArrayOutput output, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s file_ref=%d, output={.GetDataBuffer=%p, .user_data=%p}, " "callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, file_ref, output.GetDataBuffer, output.user_data, callback.func, callback.user_data, callback.flags); return ppb_file_ref_read_directory_entries(file_ref, output, callback); } const struct PPB_FileRef_1_1 ppb_file_ref_interface_1_1 = { .Create = TWRAPZ(ppb_file_ref_create), .IsFileRef = TWRAPF(ppb_file_ref_is_file_ref), .GetFileSystemType = TWRAPZ(ppb_file_ref_get_file_system_type), .GetName = TWRAPF(ppb_file_ref_get_name), .GetPath = TWRAPF(ppb_file_ref_get_path), .GetParent = TWRAPZ(ppb_file_ref_get_parent), .MakeDirectory = TWRAPZ(ppb_file_ref_make_directory), .Touch = TWRAPZ(ppb_file_ref_touch), .Delete = TWRAPZ(ppb_file_ref_delete), .Rename = TWRAPZ(ppb_file_ref_rename), .Query = TWRAPZ(ppb_file_ref_query), .ReadDirectoryEntries = TWRAPZ(ppb_file_ref_read_directory_entries), }; const struct PPB_FileRef_1_0 ppb_file_ref_interface_1_0 = { .Create = TWRAPZ(ppb_file_ref_create), .IsFileRef = TWRAPF(ppb_file_ref_is_file_ref), .GetFileSystemType = TWRAPZ(ppb_file_ref_get_file_system_type), .GetName = TWRAPF(ppb_file_ref_get_name), .GetPath = TWRAPF(ppb_file_ref_get_path), .GetParent = TWRAPZ(ppb_file_ref_get_parent), .MakeDirectory = TWRAPZ(ppb_file_ref_make_directory), .Touch = TWRAPZ(ppb_file_ref_touch), .Delete = TWRAPZ(ppb_file_ref_delete), .Rename = TWRAPZ(ppb_file_ref_rename), }; const struct PPB_FileRef_1_2 ppb_file_ref_interface_1_2 = { .Create = TWRAPZ(ppb_file_ref_create), .IsFileRef = TWRAPF(ppb_file_ref_is_file_ref), .GetFileSystemType = TWRAPZ(ppb_file_ref_get_file_system_type), .GetName = TWRAPF(ppb_file_ref_get_name), .GetPath = TWRAPF(ppb_file_ref_get_path), .GetParent = TWRAPZ(ppb_file_ref_get_parent), .MakeDirectory = TWRAPZ(ppb_file_ref_make_directory_1_2), .Touch = TWRAPZ(ppb_file_ref_touch), .Delete = TWRAPZ(ppb_file_ref_delete), .Rename = TWRAPZ(ppb_file_ref_rename), .Query = TWRAPZ(ppb_file_ref_query), .ReadDirectoryEntries = TWRAPZ(ppb_file_ref_read_directory_entries), }; static void __attribute__((constructor)) constructor_ppb_file_ref(void) { register_interface(PPB_FILEREF_INTERFACE_1_0, &ppb_file_ref_interface_1_0); register_interface(PPB_FILEREF_INTERFACE_1_1, &ppb_file_ref_interface_1_1); register_interface(PPB_FILEREF_INTERFACE_1_2, &ppb_file_ref_interface_1_2); register_resource(PP_RESOURCE_FILE_REF, ppb_file_ref_destroy); } freshplayerplugin-0.3.9/src/ppb_file_ref.h000066400000000000000000000055441321746453100206600ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include "pp_resource.h" #include enum file_ref_type_e { PP_FILE_REF_TYPE_NAME, PP_FILE_REF_TYPE_FD, }; struct pp_file_ref_s { COMMON_STRUCTURE_FIELDS int fd; char *path; enum file_ref_type_e type; }; PP_Resource ppb_file_ref_create(PP_Resource file_system, const char *path); /// can access any file, outside plugin's filesystem /// /// this function is not exported in any PPB interface PP_Resource ppb_file_ref_create_unrestricted(const char *path, int read_only); PP_Bool ppb_file_ref_is_file_ref(PP_Resource resource); PP_FileSystemType ppb_file_ref_get_file_system_type(PP_Resource file_ref); struct PP_Var ppb_file_ref_get_name(PP_Resource file_ref); struct PP_Var ppb_file_ref_get_path(PP_Resource file_ref); PP_Resource ppb_file_ref_get_parent(PP_Resource file_ref); int32_t ppb_file_ref_make_directory(PP_Resource directory_ref, PP_Bool make_ancestors, struct PP_CompletionCallback callback); int32_t ppb_file_ref_touch(PP_Resource file_ref, PP_Time last_access_time, PP_Time last_modified_time, struct PP_CompletionCallback callback); int32_t ppb_file_ref_delete(PP_Resource file_ref, struct PP_CompletionCallback callback); int32_t ppb_file_ref_rename(PP_Resource file_ref, PP_Resource new_file_ref, struct PP_CompletionCallback callback); int32_t ppb_file_ref_query(PP_Resource file_ref, struct PP_FileInfo *info, struct PP_CompletionCallback callback); int32_t ppb_file_ref_read_directory_entries(PP_Resource file_ref, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); freshplayerplugin-0.3.9/src/ppb_flash.c000066400000000000000000000543571321746453100202030ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "config.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_core.h" #include "ppb_flash.h" #include "ppb_image_data.h" #include "ppb_instance.h" #include "ppb_message_loop.h" #include "ppb_url_loader.h" #include "ppb_url_request_info.h" #include "ppb_var.h" #include "ppb_video_capture.h" #include "reverse_constant.h" #include "screensaver_control.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include "utils.h" #include #include #include #include #include #include #include #include #include #include #include #include void ppb_flash_set_instance_always_on_top(PP_Instance instance, PP_Bool on_top) { return; } PP_Bool ppb_flash_draw_glyphs(PP_Instance instance, PP_Resource pp_image_data, const struct PP_BrowserFont_Trusted_Description *font_desc, uint32_t color, const struct PP_Point *position, const struct PP_Rect *clip, const float transformation[3][3], PP_Bool allow_subpixel_aa, uint32_t glyph_count, const uint16_t glyph_indices[], const struct PP_Point glyph_advances[]) { struct pp_image_data_s *id = pp_resource_acquire(pp_image_data, PP_RESOURCE_IMAGE_DATA); if (!id) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } cairo_t *cr = cairo_create(id->cairo_surf); const char *font_family; if (font_desc->face.type == PP_VARTYPE_STRING) { font_family = ppb_var_var_to_utf8(font_desc->face, NULL); } else { switch (font_desc->family) { case PP_BROWSERFONT_TRUSTED_FAMILY_SERIF: font_family = "serif"; break; case PP_BROWSERFONT_TRUSTED_FAMILY_SANSSERIF: font_family = "sans-serif"; break; case PP_BROWSERFONT_TRUSTED_FAMILY_MONOSPACE: font_family = "monospace"; break; default: font_family = ""; break; } } cairo_select_font_face(cr, font_family, font_desc->italic ? CAIRO_FONT_SLANT_ITALIC : CAIRO_FONT_SLANT_NORMAL, font_desc->weight >= (int)PP_FONTWEIGHT_700 ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size(cr, font_desc->size); if (allow_subpixel_aa) { cairo_font_options_t *options = cairo_font_options_create(); cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_SUBPIXEL); cairo_set_font_options(cr, options); cairo_font_options_destroy(options); } if (clip) { cairo_rectangle(cr, clip->point.x, clip->point.y, clip->size.width, clip->size.height); cairo_clip(cr); } cairo_set_source_rgba(cr, ((color >> 16) & 0xffu) / 255.0, ((color >> 8) & 0xffu) / 255.0, ((color >> 0) & 0xffu) / 255.0, ((color >> 24) & 0xffu) / 255.0); cairo_matrix_t matrix; cairo_matrix_init(&matrix, transformation[0][0], transformation[0][1], transformation[1][0], transformation[1][1], transformation[0][2], transformation[1][2]); cairo_set_matrix(cr, &matrix); cairo_glyph_t *c_glyphs = malloc(glyph_count * sizeof(cairo_glyph_t)); struct PP_Point current = {.x = 0, .y = 0}; for (uint32_t k = 0; k < glyph_count; k ++) { c_glyphs[k].index = glyph_indices[k]; c_glyphs[k].x = current.x; c_glyphs[k].y = current.y; current.x += glyph_advances[k].x; current.y += glyph_advances[k].y; } cairo_show_glyphs(cr, c_glyphs, glyph_count); free(c_glyphs); cairo_surface_flush(id->cairo_surf); cairo_destroy(cr); pp_resource_release(pp_image_data); return PP_TRUE; } struct get_proxy_for_url_param_s { PP_Instance instance_id; const char *url; struct PP_Var result; PP_Resource m_loop; int depth; }; static void get_proxy_for_url_ptac(void *user_data) { struct get_proxy_for_url_param_s *p = user_data; struct pp_instance_s *pp_i = tables_get_pp_instance(p->instance_id); p->result = PP_MakeUndefined(); if (pp_i && pp_i->npp && npn.getvalueforurl) { char *value = NULL; uint32_t len = 0; NPError err; err = npn.getvalueforurl(pp_i->npp, NPNURLVProxy, p->url, &value, &len); if (err == NPERR_NO_ERROR) { p->result = ppb_var_var_from_utf8(value, len); } else { trace_info_f("%s, failed to get NPNURLVProxy, code %d\n", __func__, err); } } ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void get_proxy_for_url_comt(void *user_data, int32_t result) { ppb_core_call_on_browser_thread(0, get_proxy_for_url_ptac, user_data); } struct PP_Var ppb_flash_get_proxy_for_url(PP_Instance instance, const char *url) { struct get_proxy_for_url_param_s *p = g_slice_alloc(sizeof(*p)); p->instance_id = instance; p->url = url; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(get_proxy_for_url_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); struct PP_Var result = p->result; g_slice_free1(sizeof(*p), p); return result; } static void nop_callback(void *user_data, int32_t result) { (void)user_data; (void)result; // do nothing } int32_t ppb_flash_navigate(PP_Resource request_info, const char *target, PP_Bool from_user_action) { struct pp_url_request_info_s *ri = pp_resource_acquire(request_info, PP_RESOURCE_URL_REQUEST_INFO); if (!ri) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } pp_resource_release(request_info); PP_Resource url_loader = ppb_url_loader_create(ri->instance->id); int32_t result = ppb_url_loader_open_target(url_loader, request_info, PP_MakeCCB(nop_callback, NULL), target); ppb_core_release_resource(url_loader); if (result != PP_OK && result != PP_OK_COMPLETIONPENDING) return result; return PP_OK; } double ppb_flash_get_local_time_zone_offset(PP_Instance instance, PP_Time t) { time_t timep = t; struct tm lt = { }; localtime_r(&timep, <); return lt.tm_gmtoff; } struct PP_Var ppb_flash_get_command_line_args(PP_Module module) { return ppb_var_var_from_utf8_z(config.flash_command_line); } void ppb_flash_preload_font_win(const void *logfontw) { return; } struct topmost_rect_param_s { PP_Instance instance; struct PP_Rect rect; PP_Bool result; PP_Resource m_loop; int depth; }; static void topmost_rect_ptac(void *param) { struct topmost_rect_param_s *p = param; struct pp_instance_s *pp_i = tables_get_pp_instance(p->instance); if (!pp_i) { trace_error("%s, no instance\n", __func__); goto err_1; } p->result = PP_FALSE; NPString topmost_func_src = NPString_literal( "(function(elem, x, y) {" "var r = elem.getBoundingClientRect();" "return document.elementFromPoint(x + r.left, y + r.top) == elem;" "})"); NPVariant topmost_func; if (!npn.evaluate(pp_i->npp, pp_i->np_window_obj, &topmost_func_src, &topmost_func)) { trace_error("%s, NPN_Evaluate failed\n", __func__); goto err_1; } if (!NPVARIANT_IS_OBJECT(topmost_func)) goto err_1; NPObject *topmost_func_obj = NPVARIANT_TO_OBJECT(topmost_func); NPVariant is_topmost; NPVariant args[3]; OBJECT_TO_NPVARIANT(pp_i->np_plugin_element_obj, args[0]); INT32_TO_NPVARIANT(p->rect.point.x + p->rect.size.width / 2, args[1]); INT32_TO_NPVARIANT(p->rect.point.y + p->rect.size.height / 2, args[2]); if (!npn.invokeDefault(pp_i->npp, topmost_func_obj, args, 3, &is_topmost)) { trace_error("%s, NPN_InvokeDefault failed\n", __func__); goto err_2; } if (!NPVARIANT_IS_BOOLEAN(is_topmost)) goto err_3; p->result = NPVARIANT_TO_BOOLEAN(is_topmost); err_3: npn.releasevariantvalue(&is_topmost); err_2: npn.releasevariantvalue(&topmost_func); err_1: ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void topmost_rect_comt(void *user_data, int32_t result) { ppb_core_call_on_browser_thread(0, topmost_rect_ptac, user_data); } PP_Bool ppb_flash_is_rect_topmost(PP_Instance instance, const struct PP_Rect *rect) { if (!rect) return PP_FALSE; struct topmost_rect_param_s *p = g_slice_alloc(sizeof(*p)); p->instance = instance; p->rect = *rect; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(topmost_rect_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); PP_Bool result = p->result; g_slice_free1(sizeof(*p), p); return result; } void ppb_flash_update_activity(PP_Instance instance) { pthread_mutex_lock(&display.lock); screensaver_deactivate(display.x, display.screensaver_types); pthread_mutex_unlock(&display.lock); } struct PP_Var get_flashsetting_language(void) { char *lang = getenv("LANG"); if (!lang) return ppb_var_var_from_utf8_z("en-US"); // make a working copy lang = strdup(lang); // cut character encoding if exists char *ptr = strchr(lang, '.'); if (ptr) *ptr = 0; // replace _ by ptr = strchr(lang, '_'); if (ptr) *ptr = '-'; struct PP_Var res = ppb_var_var_from_utf8_z(lang); free(lang); return res; } struct PP_Var ppb_flash_get_setting(PP_Instance instance, PP_FlashSetting setting) { long cpu_count; struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_MakeUndefined(); } struct PP_Var var = PP_MakeUndefined(); switch (setting) { case PP_FLASHSETTING_3DENABLED: var.type = PP_VARTYPE_BOOL; var.value.as_bool = config.enable_3d ? PP_TRUE : PP_FALSE; break; case PP_FLASHSETTING_INCOGNITO: var.type = PP_VARTYPE_BOOL; var.value.as_bool = pp_i->incognito_mode ? PP_TRUE : PP_FALSE; break; case PP_FLASHSETTING_STAGE3DENABLED: var.type = PP_VARTYPE_BOOL; var.value.as_bool = config.enable_3d ? PP_TRUE : PP_FALSE; break; case PP_FLASHSETTING_LANGUAGE: var = get_flashsetting_language(); break; case PP_FLASHSETTING_NUMCORES: cpu_count = sysconf(_SC_NPROCESSORS_ONLN); var.type = PP_VARTYPE_INT32; var.value.as_int = cpu_count > 0 ? cpu_count : 1; break; case PP_FLASHSETTING_LSORESTRICTIONS: var.type = PP_VARTYPE_INT32; var.value.as_int = PP_FLASHLSORESTRICTIONS_NONE; break; case PP_FLASHSETTING_STAGE3DBASELINEENABLED: // TODO: check if driver reliable enough var.type = PP_VARTYPE_BOOL; var.value.as_bool = PP_FALSE; break; } return var; } PP_Bool ppb_flash_set_crash_data(PP_Instance instance, PP_FlashCrashKey key, struct PP_Var value) { return PP_TRUE; } int32_t ppb_flash_enumerate_video_capture_devices(PP_Instance instance, PP_Resource video_capture, struct PP_ArrayOutput devices) { int32_t ret = ppb_video_capture_enumerate_devices(video_capture, devices, PP_MakeCCB(nop_callback, NULL)); if (ret == PP_OK || ret == PP_OK_COMPLETIONPENDING) return PP_OK; return ret; } void ppb_flash_run_message_loop(PP_Instance instance) { return; } void ppb_flash_quit_message_loop(PP_Instance instance) { return; } int32_t ppb_flash_invoke_printing(PP_Instance instance) { return 0; } struct PP_Var ppb_flash_get_device_id(PP_Instance instance) { return PP_MakeUndefined(); } int32_t ppb_flash_get_setting_int(PP_Instance instance, PP_FlashSetting setting) { return 0; } // trace wrappers TRACE_WRAPPER void trace_ppb_flash_set_instance_always_on_top(PP_Instance instance, PP_Bool on_top) { trace_info("[PPB] {zilch} %s instance=%d, on_top=%d\n", __func__+6, instance, on_top); ppb_flash_set_instance_always_on_top(instance, on_top); } TRACE_WRAPPER PP_Bool trace_ppb_flash_draw_glyphs(PP_Instance instance, PP_Resource pp_image_data, const struct PP_BrowserFont_Trusted_Description *font_desc, uint32_t color, const struct PP_Point *position, const struct PP_Rect *clip, const float transformation[3][3], PP_Bool allow_subpixel_aa, uint32_t glyph_count, const uint16_t glyph_indices[], const struct PP_Point glyph_advances[]) { char *s_position = trace_point_as_string(position); char *s_clip = trace_rect_as_string(clip); char *s_face = trace_var_as_string(font_desc->face); trace_info("[PPB] {full} %s instance=%d, pp_image_data=%d, font_desc={.face=%s, .family=%d, " ".size=%u, .weight=%d, .italic=%u, .small_caps=%u, .letter_spacing=%d, " ".word_spacing=%d}, color=0x%x, position=%s, clip=%s, transformation={{%f,%f,%f}," "{%f,%f,%f},{%f,%f,%f}}, allow_subpixel_aa=%d, glyph_count=%u, glyph_indices=%p, " "glyph_advances=%p\n", __func__+6, instance, pp_image_data, s_face, font_desc->family, font_desc->size, font_desc->weight, font_desc->italic, font_desc->small_caps, font_desc->letter_spacing, font_desc->word_spacing, color, s_position, s_clip, transformation[0][0], transformation[0][1], transformation[0][2], transformation[1][0], transformation[1][1], transformation[1][2], transformation[2][0], transformation[2][1], transformation[2][2], allow_subpixel_aa, glyph_count, glyph_indices, glyph_advances); g_free(s_position); g_free(s_clip); g_free(s_face); return ppb_flash_draw_glyphs(instance, pp_image_data, font_desc, color, position, clip, transformation, allow_subpixel_aa, glyph_count, glyph_indices, glyph_advances); } TRACE_WRAPPER struct PP_Var trace_ppb_flash_get_proxy_for_url(PP_Instance instance, const char *url) { trace_info("[PPB] {full} %s instance=%d, url=%s\n", __func__+6, instance, url); return ppb_flash_get_proxy_for_url(instance, url); } TRACE_WRAPPER int32_t trace_ppb_flash_navigate(PP_Resource request_info, const char *target, PP_Bool from_user_action) { trace_info("[PPB] {full} %s request_info=%d, target=%s, from_user_action=%d\n", __func__+6, request_info, target, from_user_action); return ppb_flash_navigate(request_info, target, from_user_action); } TRACE_WRAPPER double trace_ppb_flash_get_local_time_zone_offset(PP_Instance instance, PP_Time t) { trace_info("[PPB] {full} %s instance=%d, t=%f\n", __func__+6, instance, t); return ppb_flash_get_local_time_zone_offset(instance, t); } TRACE_WRAPPER struct PP_Var trace_ppb_flash_get_command_line_args(PP_Module module) { trace_info("[PPB] {full} %s module=%d\n", __func__+6, module); return ppb_flash_get_command_line_args(module); } TRACE_WRAPPER void trace_ppb_flash_preload_font_win(const void *logfontw) { trace_info("[PPB] {zilch} %s logfontw=%p\n", __func__+6, logfontw); ppb_flash_preload_font_win(logfontw); } TRACE_WRAPPER PP_Bool trace_ppb_flash_is_rect_topmost(PP_Instance instance, const struct PP_Rect *rect) { char *rect_str = trace_rect_as_string(rect); trace_info("[PPB] {full} %s instance=%d, rect=%s\n", __func__+6, instance, rect_str); g_free(rect_str); return ppb_flash_is_rect_topmost(instance, rect); } TRACE_WRAPPER void trace_ppb_flash_update_activity(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); ppb_flash_update_activity(instance); } TRACE_WRAPPER struct PP_Var trace_ppb_flash_get_setting(PP_Instance instance, PP_FlashSetting setting) { trace_info("[PPB] {full} %s instance=%d, setting=%s\n", __func__+6, instance, reverse_pp_flash_setting(setting)); return ppb_flash_get_setting(instance, setting); } TRACE_WRAPPER PP_Bool trace_ppb_flash_set_crash_data(PP_Instance instance, PP_FlashCrashKey key, struct PP_Var value) { char *value_str = trace_var_as_string(value); trace_info("[PPB] {full} %s instance=%d, key=%d, value=%s\n", __func__+6, instance, key, value_str); g_free(value_str); return ppb_flash_set_crash_data(instance, key, value); } TRACE_WRAPPER int32_t trace_ppb_flash_enumerate_video_capture_devices(PP_Instance instance, PP_Resource video_capture, struct PP_ArrayOutput devices) { trace_info("[PPB] {full} %s instance=%d, video_capture=%d, " "devices={.GetDataBuffer=%p, .user_data=%p}\n", __func__+6, instance, video_capture, devices.GetDataBuffer, devices.user_data); return ppb_flash_enumerate_video_capture_devices(instance, video_capture, devices); } TRACE_WRAPPER void trace_ppb_flash_run_message_loop(PP_Instance instance) { trace_info("[PPB] {zilch} %s instance=%d\n", __func__+6, instance); ppb_flash_run_message_loop(instance); } TRACE_WRAPPER void trace_ppb_flash_quit_message_loop(PP_Instance instance) { trace_info("[PPB] {zilch} %s instance=%d\n", __func__+6, instance); ppb_flash_quit_message_loop(instance); } TRACE_WRAPPER int32_t trace_ppb_flash_invoke_printing(PP_Instance instance) { trace_info("[PPB] {zilch} %s instance=%d\n", __func__+6, instance); return ppb_flash_invoke_printing(instance); } TRACE_WRAPPER struct PP_Var trace_ppb_flash_get_device_id(PP_Instance instance) { trace_info("[PPB] {zilch} %s instance=%d\n", __func__+6, instance); return ppb_flash_get_device_id(instance); } TRACE_WRAPPER int32_t trace_ppb_flash_get_setting_int(PP_Instance instance, PP_FlashSetting setting) { trace_info("[PPB] {zilch} %s instance=%d, setting=%s\n", __func__+6, instance, reverse_pp_flash_setting(setting)); return ppb_flash_get_setting_int(instance, setting); } const struct PPB_Flash_13_0 ppb_flash_interface_13_0 = { .SetInstanceAlwaysOnTop = TWRAPZ(ppb_flash_set_instance_always_on_top), .DrawGlyphs = TWRAPF(ppb_flash_draw_glyphs), .GetProxyForURL = TWRAPF(ppb_flash_get_proxy_for_url), .Navigate = TWRAPF(ppb_flash_navigate), .GetLocalTimeZoneOffset = TWRAPF(ppb_flash_get_local_time_zone_offset), .GetCommandLineArgs = TWRAPF(ppb_flash_get_command_line_args), .PreloadFontWin = TWRAPZ(ppb_flash_preload_font_win), .IsRectTopmost = TWRAPF(ppb_flash_is_rect_topmost), .UpdateActivity = TWRAPF(ppb_flash_update_activity), .GetSetting = TWRAPF(ppb_flash_get_setting), .SetCrashData = TWRAPF(ppb_flash_set_crash_data), .EnumerateVideoCaptureDevices = TWRAPF(ppb_flash_enumerate_video_capture_devices), }; const struct PPB_Flash_12_6 ppb_flash_interface_12_6 = { .SetInstanceAlwaysOnTop = TWRAPZ(ppb_flash_set_instance_always_on_top), .DrawGlyphs = TWRAPF(ppb_flash_draw_glyphs), .GetProxyForURL = TWRAPF(ppb_flash_get_proxy_for_url), .Navigate = TWRAPF(ppb_flash_navigate), .RunMessageLoop = TWRAPZ(ppb_flash_run_message_loop), .QuitMessageLoop = TWRAPZ(ppb_flash_quit_message_loop), .GetLocalTimeZoneOffset = TWRAPF(ppb_flash_get_local_time_zone_offset), .GetCommandLineArgs = TWRAPF(ppb_flash_get_command_line_args), .PreloadFontWin = TWRAPZ(ppb_flash_preload_font_win), .IsRectTopmost = TWRAPF(ppb_flash_is_rect_topmost), .InvokePrinting = TWRAPZ(ppb_flash_invoke_printing), .UpdateActivity = TWRAPF(ppb_flash_update_activity), .GetDeviceID = TWRAPZ(ppb_flash_get_device_id), .GetSettingInt = TWRAPZ(ppb_flash_get_setting_int), .GetSetting = TWRAPF(ppb_flash_get_setting), .SetCrashData = TWRAPF(ppb_flash_set_crash_data), .EnumerateVideoCaptureDevices = TWRAPF(ppb_flash_enumerate_video_capture_devices), }; static void __attribute__((constructor)) constructor_ppb_flash(void) { register_interface(PPB_FLASH_INTERFACE_12_6, &ppb_flash_interface_12_6); register_interface(PPB_FLASH_INTERFACE_13_0, &ppb_flash_interface_13_0); } freshplayerplugin-0.3.9/src/ppb_flash.h000066400000000000000000000056571321746453100202070ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include void ppb_flash_set_instance_always_on_top(PP_Instance instance, PP_Bool on_top); PP_Bool ppb_flash_draw_glyphs(PP_Instance instance, PP_Resource pp_image_data, const struct PP_BrowserFont_Trusted_Description *font_desc, uint32_t color, const struct PP_Point *position, const struct PP_Rect *clip, const float transformation[3][3], PP_Bool allow_subpixel_aa, uint32_t glyph_count, const uint16_t glyph_indices[], const struct PP_Point glyph_advances[]); struct PP_Var ppb_flash_get_proxy_for_url(PP_Instance instance, const char *url); int32_t ppb_flash_navigate(PP_Resource request_info, const char *target, PP_Bool from_user_action); double ppb_flash_get_local_time_zone_offset(PP_Instance instance, PP_Time t); struct PP_Var ppb_flash_get_command_line_args(PP_Module module); void ppb_flash_preload_font_win(const void *logfontw); PP_Bool ppb_flash_is_rect_topmost(PP_Instance instance, const struct PP_Rect *rect); void ppb_flash_update_activity(PP_Instance instance); struct PP_Var ppb_flash_get_setting(PP_Instance instance, PP_FlashSetting setting); PP_Bool ppb_flash_set_crash_data(PP_Instance instance, PP_FlashCrashKey key, struct PP_Var value); int32_t ppb_flash_enumerate_video_capture_devices(PP_Instance instance, PP_Resource video_capture, struct PP_ArrayOutput devices); void ppb_flash_run_message_loop(PP_Instance instance); void ppb_flash_quit_message_loop(PP_Instance instance); int32_t ppb_flash_invoke_printing(PP_Instance instance); struct PP_Var ppb_flash_get_device_id(PP_Instance instance); int32_t ppb_flash_get_setting_int(PP_Instance instance, PP_FlashSetting setting); freshplayerplugin-0.3.9/src/ppb_flash_clipboard.c000066400000000000000000000511011321746453100222020ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "gtk_wrapper.h" #include "pp_interface.h" #include "ppb_core.h" #include "ppb_flash_clipboard.h" #include "ppb_message_loop.h" #include "ppb_var.h" #include "reverse_constant.h" #include "trace_core.h" #include "utils.h" #include #include #include #include #include #include static GHashTable *format_id_ht; ///< maps name to id static GHashTable *format_name_ht; ///< maps id to name static uint32_t next_format_id = 1000; static pthread_mutex_t lock; static void free_data_block(gpointer data) { g_free(data); } static void __attribute__((destructor)) destructor__ppb_flash_clipboard(void) { pthread_mutex_lock(&lock); g_hash_table_unref(format_id_ht); g_hash_table_unref(format_name_ht); pthread_mutex_unlock(&lock); pthread_mutex_destroy(&lock); } uint32_t ppb_flash_clipboard_register_custom_format(PP_Instance instance_id, const char *format_name) { // check if this format was registered already pthread_mutex_lock(&lock); uint32_t format_id = GPOINTER_TO_INT(g_hash_table_lookup(format_id_ht, format_name)); pthread_mutex_unlock(&lock); if (format_id > 0) return format_id; // create new one pthread_mutex_lock(&lock); format_id = next_format_id ++; g_hash_table_insert(format_id_ht, g_strdup(format_name), GINT_TO_POINTER(format_id)); g_hash_table_insert(format_name_ht, GINT_TO_POINTER(format_id), g_strdup(format_name)); pthread_mutex_unlock(&lock); return format_id; } static int clipboard_type_and_format_are_supported(PP_Flash_Clipboard_Type clipboard_type, uint32_t format, const char *func_name) { if (clipboard_type != PP_FLASH_CLIPBOARD_TYPE_STANDARD && clipboard_type != PP_FLASH_CLIPBOARD_TYPE_SELECTION) { trace_error("%s, bad clipboard_type (= %d)\n", func_name, clipboard_type); return 0; } pthread_mutex_lock(&lock); gchar *custom_format_name = g_hash_table_lookup(format_name_ht, GINT_TO_POINTER(format)); pthread_mutex_unlock(&lock); if (format != PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT && format != PP_FLASH_CLIPBOARD_FORMAT_HTML && format != PP_FLASH_CLIPBOARD_FORMAT_RTF && custom_format_name == NULL) { trace_error("%s, unknown format (= %d)\n", func_name, format); return 0; } return 1; } static GtkClipboard * get_clipboard_of_type(PP_Flash_Clipboard_Type clipboard_type) { switch (clipboard_type) { case PP_FLASH_CLIPBOARD_TYPE_STANDARD: return gw_gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); case PP_FLASH_CLIPBOARD_TYPE_SELECTION: return gw_gtk_clipboard_get(GDK_SELECTION_PRIMARY); default: return NULL; } } static GdkAtom get_clipboard_target_atom(uint32_t format) { switch (format) { case PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT: return gw_gdk_atom_intern_static_string("UTF8_STRING"); case PP_FLASH_CLIPBOARD_FORMAT_HTML: return gw_gdk_atom_intern("text/html", FALSE); case PP_FLASH_CLIPBOARD_FORMAT_RTF: return gw_gdk_atom_intern("text/rtf", FALSE); default: break; } pthread_mutex_lock(&lock); gchar *custom_format_name = g_hash_table_lookup(format_name_ht, GINT_TO_POINTER(format)); pthread_mutex_unlock(&lock); if (custom_format_name) return gw_gdk_atom_intern(custom_format_name, FALSE); return GDK_NONE; } struct clipboard_is_format_available_param_s { PP_Flash_Clipboard_Type clipboard_type; uint32_t format; PP_Bool result; PP_Resource m_loop; int depth; }; static void clipboard_is_format_available_ptac(void *user_data) { struct clipboard_is_format_available_param_s *p = user_data; p->result = PP_FALSE; GtkClipboard *clipboard = get_clipboard_of_type(p->clipboard_type); if (!clipboard) goto quit; GdkAtom target = get_clipboard_target_atom(p->format); if (target == GDK_NONE) goto quit; p->result = gw_gtk_clipboard_wait_is_target_available(clipboard, target); quit: ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void clipboard_is_format_available_comt(void *user_data, int32_t result) { ppb_core_call_on_browser_thread(0, clipboard_is_format_available_ptac, user_data); } PP_Bool ppb_flash_clipboard_is_format_available(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t format) { if (!clipboard_type_and_format_are_supported(clipboard_type, format, __func__)) return PP_FALSE; struct clipboard_is_format_available_param_s *p = g_slice_alloc(sizeof(*p)); p->clipboard_type = clipboard_type; p->format = format; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(clipboard_is_format_available_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); PP_Bool result = p->result; g_slice_free1(sizeof(*p), p); return result; } struct clipboard_read_data_param_s { PP_Flash_Clipboard_Type clipboard_type; uint32_t format; struct PP_Var result; PP_Resource m_loop; int depth; }; static void clipboard_read_data_ptac(void *user_data) { struct clipboard_read_data_param_s *p = user_data; p->result = PP_MakeUndefined(); GtkClipboard *clipboard = get_clipboard_of_type(p->clipboard_type); if (!clipboard) goto quit; GdkAtom target = get_clipboard_target_atom(p->format); if (target == GDK_NONE) goto quit; GtkSelectionData *sd = gw_gtk_clipboard_wait_for_contents(clipboard, target); if (sd) { const guchar *sd_data = gw_gtk_selection_data_get_data(sd); const gint sd_length = gw_gtk_selection_data_get_length(sd); switch (p->format) { case PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT: case PP_FLASH_CLIPBOARD_FORMAT_HTML: p->result = ppb_var_var_from_utf8((char *)sd_data, sd_length); break; default: p->result = ppb_var_array_buffer_create(sd_length); memcpy(ppb_var_array_buffer_map(p->result), sd_data, sd_length); ppb_var_array_buffer_unmap(p->result); break; } gw_gtk_selection_data_free(sd); } quit: ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void clipboard_read_data_comt(void *user_data, int32_t result) { ppb_core_call_on_browser_thread(0, clipboard_read_data_ptac, user_data); } struct PP_Var ppb_flash_clipboard_read_data(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t format) { if (!clipboard_type_and_format_are_supported(clipboard_type, format, __func__)) return PP_MakeUndefined(); struct clipboard_read_data_param_s *p = g_slice_alloc(sizeof(*p)); p->clipboard_type = clipboard_type; p->format = format; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(clipboard_read_data_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); struct PP_Var result = p->result; g_slice_free1(sizeof(*p), p); return result; } struct clipboard_write_data_param_s { PP_Flash_Clipboard_Type clipboard_type; uint32_t data_item_count; const uint32_t *formats; const struct PP_Var *data_items; int32_t result; PP_Resource m_loop; int depth; }; struct selection_entry_s { GdkAtom type; struct PP_Var var; }; static void clipboard_get_func(GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, gpointer user_data) { GArray *items = user_data; struct selection_entry_s *item = &g_array_index(items, struct selection_entry_s, info); uint32_t len = 0; const char *data; if (item->var.type == PP_VARTYPE_STRING) { data = ppb_var_var_to_utf8(item->var, &len); } else if (item->var.type == PP_VARTYPE_ARRAY_BUFFER) { data = ppb_var_array_buffer_map(item->var); ppb_var_array_buffer_byte_length(item->var, &len); } else { trace_error("%s, unexpected var type %d\n", __func__, item->var.type); data = NULL; len = 0; } gw_gtk_selection_data_set(selection_data, item->type, 8, (const guchar *)data, len); if (item->var.type == PP_VARTYPE_ARRAY_BUFFER) ppb_var_array_buffer_unmap(item->var); } static void clipboard_clear_func(GtkClipboard *clipboard, gpointer user_data) { GArray *items = user_data; for (uint32_t k = 0; k < items->len; k ++) { struct selection_entry_s *item = &g_array_index(items, struct selection_entry_s, k); ppb_var_release(item->var); } g_array_unref(items); } static void clipboard_write_data_ptac(void *user_data) { struct clipboard_write_data_param_s *p = user_data; struct selection_entry_s item; p->result = PP_OK; GtkClipboard *clipboard = get_clipboard_of_type(p->clipboard_type); if (!clipboard) goto quit; if (p->data_item_count == 0) { // one can pass zero items to clear clipboard gw_gtk_clipboard_clear(clipboard); goto quit; } GArray *items = g_array_new(FALSE /* no zero teminator */, TRUE /* zero items */, sizeof(item)); for (uint32_t k = 0; k < p->data_item_count; k ++) { item.var = p->data_items[k]; switch (p->formats[k]) { case PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT: if (item.var.type != PP_VARTYPE_STRING) { trace_error("%s, plaintext format, var is not a string\n", __func__); break; } item.type = gw_gdk_atom_intern("text/html", FALSE); ppb_var_add_ref(item.var); g_array_append_val(items, item); item.type = gw_gdk_atom_intern("TEXT", FALSE); ppb_var_add_ref(item.var); g_array_append_val(items, item); item.type = gw_gdk_atom_intern("STRING", FALSE); ppb_var_add_ref(item.var); g_array_append_val(items, item); item.type = gw_gdk_atom_intern("UTF8_STRING", FALSE); ppb_var_add_ref(item.var); g_array_append_val(items, item); item.type = gw_gdk_atom_intern("COMPOUND_TEXT", FALSE); ppb_var_add_ref(item.var); g_array_append_val(items, item); break; case PP_FLASH_CLIPBOARD_FORMAT_HTML: if (item.var.type != PP_VARTYPE_STRING) { trace_error("%s, html format, var is not a string\n", __func__); break; } item.type = gw_gdk_atom_intern("text/html", FALSE); ppb_var_add_ref(item.var); g_array_append_val(items, item); break; case PP_FLASH_CLIPBOARD_FORMAT_RTF: if (item.var.type != PP_VARTYPE_ARRAY_BUFFER) { trace_error("%s, rtf, var is not an array buffer\n", __func__); break; } item.type = gw_gdk_atom_intern("text/rtf", FALSE); ppb_var_add_ref(item.var); g_array_append_val(items, item); break; default: if (item.var.type != PP_VARTYPE_ARRAY_BUFFER) { trace_error("%s, custom format, var is not an array buffer\n", __func__); break; } item.type = get_clipboard_target_atom(p->formats[k]); if (item.type != GDK_NONE) { ppb_var_add_ref(item.var); g_array_append_val(items, item); } break; } } GtkTargetEntry *targets = g_new0(GtkTargetEntry, items->len); for (uint32_t k = 0; k < items->len; k ++) { targets[k].target = gw_gdk_atom_name(g_array_index(items, struct selection_entry_s, k).type); targets[k].info = k; } if (gw_gtk_clipboard_set_with_data(clipboard, targets, items->len, clipboard_get_func, clipboard_clear_func, items)) { gw_gtk_clipboard_set_can_store(clipboard, targets, items->len); } else { p->result = PP_ERROR_FAILED; } for (uint32_t k = 0; k < items->len; k ++) g_free(targets[k].target); g_free(targets); quit: ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void clipboard_write_data_comt(void *user_data, int32_t result) { ppb_core_call_on_browser_thread(0, clipboard_write_data_ptac, user_data); } int32_t ppb_flash_clipboard_write_data(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t data_item_count, const uint32_t formats[], const struct PP_Var data_items[]) { for (uint32_t k = 0; k < data_item_count; k ++) { if (!clipboard_type_and_format_are_supported(clipboard_type, formats[k], __func__)) return PP_ERROR_FAILED; } struct clipboard_write_data_param_s *p = g_slice_alloc(sizeof(*p)); p->clipboard_type = clipboard_type; p->data_item_count = data_item_count; p->formats = formats; p->data_items = data_items; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(clipboard_write_data_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); int32_t result = p->result; g_slice_free1(sizeof(*p), p); return result; } PP_Bool ppb_flash_clipboard_get_sequence_number(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint64_t *sequence_number) { return PP_FALSE; } // trace wrappers TRACE_WRAPPER uint32_t trace_ppb_flash_clipboard_register_custom_format(PP_Instance instance_id, const char *format_name) { trace_info("[PPB] {full} %s instance_id=%d, format_name=%s\n", __func__+6, instance_id, format_name); return ppb_flash_clipboard_register_custom_format(instance_id, format_name); } TRACE_WRAPPER PP_Bool trace_ppb_flash_clipboard_is_format_available(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t format) { trace_info("[PPB] {full} %s instance_id=%d, clipboard_type=%s, format=%s(%u)\n", __func__+6, instance_id, reverse_clipboard_type(clipboard_type), reverse_clipboard_format(format), format); return ppb_flash_clipboard_is_format_available(instance_id, clipboard_type, format); } TRACE_WRAPPER struct PP_Var trace_ppb_flash_clipboard_read_data(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t format) { trace_info("[PPB] {full} %s instance_id=%d, clipboard_type=%s, format=%s(%u)\n", __func__+6, instance_id, reverse_clipboard_type(clipboard_type), reverse_clipboard_format(format), format); return ppb_flash_clipboard_read_data(instance_id, clipboard_type, format); } TRACE_WRAPPER int32_t trace_ppb_flash_clipboard_write_data(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t data_item_count, const uint32_t formats[], const struct PP_Var data_items[]) { trace_info("[PPB] {full} %s instance_id=%d, clipboard_type=%s, data_item_count=%u, " "formats[]=%p, data_items[]=%p\n", __func__+6, instance_id, reverse_clipboard_type(clipboard_type), data_item_count, formats, data_items); return ppb_flash_clipboard_write_data(instance_id, clipboard_type, data_item_count, formats, data_items); } TRACE_WRAPPER PP_Bool trace_ppb_flash_clipboard_get_sequence_number(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint64_t *sequence_number) { trace_info("[PPB] {zilch} %s instance_id=%d, clipboard_type=%s\n", __func__, instance_id, reverse_clipboard_type(clipboard_type)); return ppb_flash_clipboard_get_sequence_number(instance_id, clipboard_type, sequence_number); } const struct PPB_Flash_Clipboard_5_1 ppb_flash_clipboard_interface_5_1 = { .RegisterCustomFormat = TWRAPF(ppb_flash_clipboard_register_custom_format), .IsFormatAvailable = TWRAPF(ppb_flash_clipboard_is_format_available), .ReadData = TWRAPF(ppb_flash_clipboard_read_data), .WriteData = TWRAPF(ppb_flash_clipboard_write_data), .GetSequenceNumber = TWRAPZ(ppb_flash_clipboard_get_sequence_number), }; const struct PPB_Flash_Clipboard_5_0 ppb_flash_clipboard_interface_5_0 = { .RegisterCustomFormat = TWRAPF(ppb_flash_clipboard_register_custom_format), .IsFormatAvailable = TWRAPF(ppb_flash_clipboard_is_format_available), .ReadData = TWRAPF(ppb_flash_clipboard_read_data), .WriteData = TWRAPF(ppb_flash_clipboard_write_data), }; static void __attribute__((constructor)) constructor_ppb_flash_clipboard(void) { pthread_mutex_init(&lock, NULL); pthread_mutex_lock(&lock); format_id_ht = g_hash_table_new_full(g_str_hash, g_str_equal, free_data_block, NULL); format_name_ht = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_data_block); g_hash_table_insert(format_id_ht, g_strdup("TEXT"), GINT_TO_POINTER(PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT)); g_hash_table_insert(format_id_ht, g_strdup("STRING"), GINT_TO_POINTER(PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT)); g_hash_table_insert(format_id_ht, g_strdup("UTF8_STRING"), GINT_TO_POINTER(PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT)); g_hash_table_insert(format_id_ht, g_strdup("COMPOUND_TEXT"), GINT_TO_POINTER(PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT)); g_hash_table_insert(format_id_ht, g_strdup("text/html"), GINT_TO_POINTER(PP_FLASH_CLIPBOARD_FORMAT_HTML)); g_hash_table_insert(format_id_ht, g_strdup("text/rtf"), GINT_TO_POINTER(PP_FLASH_CLIPBOARD_FORMAT_RTF)); g_hash_table_insert(format_name_ht, GINT_TO_POINTER(PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT), g_strdup("STRING")); g_hash_table_insert(format_name_ht, GINT_TO_POINTER(PP_FLASH_CLIPBOARD_FORMAT_HTML), g_strdup("text/html")); g_hash_table_insert(format_name_ht, GINT_TO_POINTER(PP_FLASH_CLIPBOARD_FORMAT_RTF), g_strdup("text/rtf")); pthread_mutex_unlock(&lock); register_interface(PPB_FLASH_CLIPBOARD_INTERFACE_5_0, &ppb_flash_clipboard_interface_5_0); register_interface(PPB_FLASH_CLIPBOARD_INTERFACE_5_1, &ppb_flash_clipboard_interface_5_1); } freshplayerplugin-0.3.9/src/ppb_flash_clipboard.h000066400000000000000000000041411321746453100222110ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include uint32_t ppb_flash_clipboard_register_custom_format(PP_Instance instance_id, const char *format_name); PP_Bool ppb_flash_clipboard_is_format_available(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t format); struct PP_Var ppb_flash_clipboard_read_data(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t format); int32_t ppb_flash_clipboard_write_data(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint32_t data_item_count, const uint32_t formats[], const struct PP_Var data_items[]); PP_Bool ppb_flash_clipboard_get_sequence_number(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, uint64_t *sequence_number); freshplayerplugin-0.3.9/src/ppb_flash_drm.c000066400000000000000000000173161321746453100210370ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "config.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_crypto.h" #include "ppb_flash_drm.h" #include "ppb_message_loop.h" #include "ppb_var.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include #include #include #define salt_length 32 STATIC_ASSERT_LESS_OR_EQ(salt_length, 32); struct pp_flash_drm_s { COMMON_STRUCTURE_FIELDS }; STATIC_ASSERT(sizeof(struct pp_flash_drm_s) <= LARGEST_RESOURCE_SIZE); PP_Resource ppb_flash_drm_create(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource flash_drm = pp_resource_allocate(PP_RESOURCE_FLASH_DRM, pp_i); struct pp_flash_drm_s *fd = pp_resource_acquire(flash_drm, PP_RESOURCE_FLASH_DRM); if (!fd) { trace_error("%s, failed to create flash drm resource\n", __func__); return 0; } pp_resource_release(flash_drm); return flash_drm; } static void ppb_flash_drm_destroy(void *p) { } static void get_system_salt(char *salt) { do { FILE *fp = fopen("/etc/machine-id", "rb"); if (!fp) break; if (fread(salt, 1, 32, fp) != 32) { fclose(fp); break; } fclose(fp); return; } while (0); do { FILE *fp = fopen("/var/lib/dbus/machine-id", "rb"); if (!fp) break; if (fread(salt, 1, 32, fp) != 32) { fclose(fp); break; } fclose(fp); return; } while (0); // fall back to random number generator unsigned char salt_raw[salt_length / 2]; ppb_crypto_get_random_bytes((char *)salt_raw, salt_length / 2); // make hexadecimal string for (unsigned int k = 0; k < salt_length / 2; k ++) { const char tbl[] = "0123456789abcdef"; salt[2 * k] = tbl[(salt_raw[k] >> 4) & 0xf]; salt[2 * k + 1] = tbl[salt_raw[k] & 0xf]; } } int32_t ppb_flash_drm_get_device_id(PP_Resource drm, struct PP_Var *id, struct PP_CompletionCallback callback) { const char *salt_fname = fpp_config_get_pepper_salt_file_name(); FILE *fp; char salt[salt_length]; (void)drm; fp = fopen(salt_fname, "rb"); if (!fp) { // create salt trace_info("%s, creating salt file\n", __func__); fp = fopen(salt_fname, "wb"); if (!fp) { trace_error("%s, can't create salt file\n", __func__); return PP_ERROR_FAILED; } get_system_salt(salt); size_t written = fwrite(salt, 1, salt_length, fp); fclose(fp); if (written != salt_length) { trace_error("%s, can't write to salt file\n", __func__); return PP_ERROR_FAILED; } fp = fopen(salt_fname, "rb"); if (!fp) { trace_error("%s, can't open salt file\n", __func__); return PP_ERROR_FAILED; } } size_t read_bytes = fread(salt, 1, salt_length, fp); fclose(fp); if (read_bytes != salt_length) { trace_error("%s, truncated salt file. Remove it and try again\n", __func__); return PP_ERROR_FAILED; } *id = ppb_var_var_from_utf8(salt, salt_length); ppb_message_loop_post_work_with_result(ppb_message_loop_get_current(), callback, 0, PP_OK, 0, __func__); return PP_OK_COMPLETIONPENDING; } PP_Bool ppb_flash_drm_get_hmonitor(PP_Resource drm, int64_t *hmonitor) { return PP_FALSE; } int32_t ppb_flash_drm_get_voucher_file(PP_Resource drm, PP_Resource *file_ref, struct PP_CompletionCallback callback) { return -1; } int32_t ppb_flash_drm_monitor_is_external(PP_Resource drm, PP_Bool *is_external, struct PP_CompletionCallback callback) { return -1; } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_flash_drm_create(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_flash_drm_create(instance); } TRACE_WRAPPER int32_t trace_ppb_flash_drm_get_device_id(PP_Resource drm, struct PP_Var *id, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s drm=%d, callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, drm, callback.func, callback.user_data, callback.flags); return ppb_flash_drm_get_device_id(drm, id, callback); } TRACE_WRAPPER PP_Bool trace_ppb_flash_drm_get_hmonitor(PP_Resource drm, int64_t *hmonitor) { trace_info("[PPB] {zilch} %s drm=%d\n", __func__+6, drm); return ppb_flash_drm_get_hmonitor(drm, hmonitor); } TRACE_WRAPPER int32_t trace_ppb_flash_drm_get_voucher_file(PP_Resource drm, PP_Resource *file_ref, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s drm=%d, callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, drm, callback.func, callback.user_data, callback.flags); return ppb_flash_drm_get_voucher_file(drm, file_ref, callback); } TRACE_WRAPPER int32_t trace_ppb_flash_drm_monitor_is_external(PP_Resource drm, PP_Bool *is_external, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s drm=%d, callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, drm, callback.func, callback.user_data, callback.flags); return ppb_flash_drm_monitor_is_external(drm, is_external, callback); } const struct PPB_Flash_DRM_1_1 ppb_flash_drm_interface_1_1 = { .Create = TWRAPF(ppb_flash_drm_create), .GetDeviceID = TWRAPF(ppb_flash_drm_get_device_id), .GetHmonitor = TWRAPZ(ppb_flash_drm_get_hmonitor), .GetVoucherFile = TWRAPZ(ppb_flash_drm_get_voucher_file), .MonitorIsExternal = TWRAPZ(ppb_flash_drm_monitor_is_external), }; const struct PPB_Flash_DRM_1_0 ppb_flash_drm_interface_1_0 = { .Create = TWRAPF(ppb_flash_drm_create), .GetDeviceID = TWRAPF(ppb_flash_drm_get_device_id), .GetHmonitor = TWRAPZ(ppb_flash_drm_get_hmonitor), .GetVoucherFile = TWRAPZ(ppb_flash_drm_get_voucher_file), }; static void __attribute__((constructor)) constructor_ppb_flash_drm(void) { register_interface(PPB_FLASH_DRM_INTERFACE_1_0, &ppb_flash_drm_interface_1_0); register_interface(PPB_FLASH_DRM_INTERFACE_1_1, &ppb_flash_drm_interface_1_1); register_resource(PP_RESOURCE_FLASH_DRM, ppb_flash_drm_destroy); } freshplayerplugin-0.3.9/src/ppb_flash_drm.h000066400000000000000000000034171321746453100210410ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include PP_Resource ppb_flash_drm_create(PP_Instance instance); int32_t ppb_flash_drm_get_device_id(PP_Resource drm, struct PP_Var *id, struct PP_CompletionCallback callback); PP_Bool ppb_flash_drm_get_hmonitor(PP_Resource drm, int64_t *hmonitor); int32_t ppb_flash_drm_get_voucher_file(PP_Resource drm, PP_Resource *file_ref, struct PP_CompletionCallback callback); int32_t ppb_flash_drm_monitor_is_external(PP_Resource drm, PP_Bool *is_external, struct PP_CompletionCallback callback); freshplayerplugin-0.3.9/src/ppb_flash_file.c000066400000000000000000000421701321746453100211700ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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. */ #define _FILE_OFFSET_BITS 64 #include "config.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_file_ref.h" #include "ppb_flash_file.h" #include "trace_core.h" #include #include #include #include #include #include #include #include #include #include #include #include /// resolve pp module local path to absolute one static char * to_abs_path(const char *root, const char *s) { char *rel_path = NULL; char *abs_path = NULL; char *src, *dst; int dot_cnt = 0; int after_slash = 1; rel_path = g_strdup_printf("/%s", s); src = dst = rel_path; while (*src) { switch (*src) { case '\\': case '/': if (dot_cnt == 1 || dot_cnt == 2) { for (int k = 0; k < dot_cnt; k ++) { while (dst > rel_path && *(dst - 1) != '/') dst --; if (dst > rel_path) dst --; } } *dst++ = '/'; dot_cnt = 0; after_slash = 1; break; case '.': *dst++ = '.'; if (after_slash) dot_cnt ++; break; default: dot_cnt = 0; after_slash = 0; *dst++ = *src; break; } src++; } // treat trailing "/." and "/.." if (after_slash && (dot_cnt == 1 || dot_cnt == 2)) { for (int k = 0; k < dot_cnt; k ++) { while (dst > rel_path && *(dst - 1) != '/') dst --; if (dst > rel_path) dst --; } *dst++ = '/'; } int len = dst - rel_path; abs_path = g_strdup_printf("%s%.*s", root, len, rel_path); g_free(rel_path); return abs_path; } static int pp_mode_to_open_mode(int32_t mode) { int ret = 0; if ((mode & PP_FILEOPENFLAG_READ) && !(mode & PP_FILEOPENFLAG_WRITE)) ret = O_RDONLY; if (!(mode & PP_FILEOPENFLAG_READ) && (mode & PP_FILEOPENFLAG_WRITE)) ret = O_WRONLY; if ((mode & PP_FILEOPENFLAG_READ) && (mode & PP_FILEOPENFLAG_WRITE)) ret = O_RDWR; if (mode & PP_FILEOPENFLAG_CREATE) ret |= O_CREAT; if (mode & PP_FILEOPENFLAG_TRUNCATE) ret |= O_TRUNC; if (mode & PP_FILEOPENFLAG_EXCLUSIVE) ret |= O_EXCL; if (mode & PP_FILEOPENFLAG_APPEND) ret |= O_APPEND; return ret; } int32_t ppb_flash_file_file_ref_open_file(PP_Resource file_ref_id, int32_t mode, PP_FileHandle *file) { struct pp_file_ref_s *fr = pp_resource_acquire(file_ref_id, PP_RESOURCE_FILE_REF); if (!fr) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } if (!fr->path) { trace_error("%s, resource have no path\n", __func__); pp_resource_release(file_ref_id); return PP_ERROR_FAILED; } int xmode = pp_mode_to_open_mode(mode); *file = open(fr->path, xmode, 0666); pp_resource_release(file_ref_id); if (*file > 0) { return PP_OK; } else { switch (errno) { case ENOENT: return PP_ERROR_FILENOTFOUND; case EACCES: return PP_ERROR_NOACCESS; default: return PP_ERROR_FAILED; } } } int32_t ppb_flash_file_file_ref_query_file(PP_Resource file_ref_id, struct PP_FileInfo *info) { if (!info) return PP_ERROR_BADARGUMENT; struct pp_file_ref_s *fr = pp_resource_acquire(file_ref_id, PP_RESOURCE_FILE_REF); if (!fr) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } struct stat sb; int ret; if (fr->type == PP_FILE_REF_TYPE_NAME) { ret = stat(fr->path, &sb); } else { ret = fstat(fr->fd, &sb); } if (ret == -1) { pp_resource_release(file_ref_id); // TODO: create and use common errno converter switch (errno) { case ENOENT: return PP_ERROR_FILENOTFOUND; case EACCES: return PP_ERROR_NOACCESS; default: return PP_ERROR_FAILED; } } info->size = sb.st_size; if (S_ISREG(sb.st_mode)) { info->type = PP_FILETYPE_REGULAR; } else if (S_ISDIR(sb.st_mode)) { info->type = PP_FILETYPE_DIRECTORY; } else { info->type = PP_FILETYPE_OTHER; } info->system_type = PP_FILESYSTEMTYPE_EXTERNAL; // TODO: which fs type should be used? info->creation_time = sb.st_ctim.tv_sec + sb.st_ctim.tv_nsec / 1e9; info->last_access_time = sb.st_atim.tv_sec + sb.st_atim.tv_nsec / 1e9; info->last_modified_time = sb.st_mtim.tv_sec + sb.st_mtim.tv_nsec / 1e9; pp_resource_release(file_ref_id); return PP_OK; } bool ppb_flash_file_modulelocal_create_thread_adapter_for_instance(PP_Instance instance) { // Deprecated. Returns true. return PP_TRUE; } void ppb_flash_file_modulelocal_clear_thread_adapter_for_instance(PP_Instance instance) { // Deprecated. Does nothing. return; } static void create_subdirectories_recursively(const char *p) { if (!p) return; struct stat sb; char *path = strdup(p); char *last_slash = strrchr(path, '/'); if (!last_slash) goto quit; *last_slash = '\0'; // check if directory already exists if (lstat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) goto quit; char *ptr = strchr(path, '/'); while (ptr) { *ptr = '\0'; (void)mkdir(path, 0777); *ptr = '/'; ptr = strchr(ptr + 1, '/'); } (void)mkdir(path, 0777); quit: free(path); } int32_t ppb_flash_file_modulelocal_open_file(PP_Instance instance, const char *path, int32_t mode, PP_FileHandle *file) { char *abs_path = to_abs_path(fpp_config_get_pepper_data_dir(), path); int xmode = pp_mode_to_open_mode(mode); if (xmode & O_CREAT) create_subdirectories_recursively(abs_path); int fd = open(abs_path, xmode, 0666); g_free(abs_path); *file = fd; if (fd > 0) return PP_OK; else switch (errno) { case ENOENT: return PP_ERROR_FILENOTFOUND; case EACCES: return PP_ERROR_NOACCESS; default: return PP_ERROR_FAILED; } } int32_t ppb_flash_file_modulelocal_rename_file(PP_Instance instance, const char *path_from, const char *path_to) { (void)instance; char *abs_path_from = to_abs_path(fpp_config_get_pepper_data_dir(), path_from); char *abs_path_to = to_abs_path(fpp_config_get_pepper_data_dir(), path_to); int ret = rename(abs_path_from, abs_path_to); g_free(abs_path_from); g_free(abs_path_to); if (ret < 0) { // TODO: implement error mapping return PP_ERROR_FAILED; } return PP_OK; } int32_t ppb_flash_file_modulelocal_delete_file_or_dir(PP_Instance instance, const char *path, PP_Bool recursive) { (void)instance; if (recursive) { trace_warning("%s, recursive not implemented\n", __func__); } char *abs_path = to_abs_path(fpp_config_get_pepper_data_dir(), path); int ret = unlink(abs_path); g_free(abs_path); if (ret < 0) { // TODO: implement error mapping return PP_ERROR_FAILED; } return PP_OK; } int32_t ppb_flash_file_modulelocal_create_dir(PP_Instance instance, const char *path) { char *abs_path = to_abs_path(fpp_config_get_pepper_data_dir(), path); create_subdirectories_recursively(abs_path); int ret = mkdir(abs_path, 0777); g_free(abs_path); if (ret < 0) { switch (errno) { case EACCES: return PP_ERROR_NOACCESS; case EEXIST: return PP_OK; default: return PP_ERROR_FAILED; } } return PP_OK; } int32_t ppb_flash_file_modulelocal_query_file(PP_Instance instance, const char *path, struct PP_FileInfo *info) { if (!info) { trace_error("%s, 'info' is NULL\n", __func__); return PP_ERROR_FAILED; } char *abs_path = to_abs_path(fpp_config_get_pepper_data_dir(), path); struct stat sb; int ret = lstat(abs_path, &sb); g_free(abs_path); if (ret < 0) { switch (errno) { case ENOENT: return PP_ERROR_FILENOTFOUND; case EACCES: return PP_ERROR_NOACCESS; default: return PP_ERROR_FAILED; } } info->size = sb.st_size; if (S_ISREG(sb.st_mode)) info->type = PP_FILETYPE_REGULAR; else if (S_ISDIR(sb.st_mode)) info->type = PP_FILETYPE_DIRECTORY; else info->type = PP_FILETYPE_OTHER; info->system_type = PP_FILESYSTEMTYPE_ISOLATED; info->creation_time = sb.st_ctime; info->last_access_time = sb.st_atime; info->last_modified_time = sb.st_mtime; return PP_OK; } int32_t ppb_flash_file_modulelocal_get_dir_contents(PP_Instance instance, const char *path, struct PP_DirContents_Dev **contents) { struct dirent **namelist; char *abs_path = to_abs_path(fpp_config_get_pepper_data_dir(), path); int n = scandir(abs_path, &namelist, NULL, alphasort); *contents = NULL; if (n < 0) goto err; *contents = malloc(sizeof(struct PP_DirContents_Dev)); if (!*contents) goto err; (*contents)->entries = malloc(n * sizeof(struct PP_DirEntry_Dev)); if (!(*contents)->entries) goto err2; int cnt = 0; for (int k = 0; k < n; k ++) { char *fname = g_strdup_printf("%s/%s", abs_path, namelist[k]->d_name); struct stat sb; int ret = lstat(fname, &sb); g_free(fname); if (ret == 0) { (*contents)->entries[cnt].is_dir = S_ISDIR(sb.st_mode); (*contents)->entries[cnt].name = strdup(namelist[k]->d_name); cnt++; } free(namelist[k]); } (*contents)->count = cnt; free(namelist); g_free(abs_path); return PP_OK; err2: free(*contents); err: g_free(abs_path); return PP_ERROR_FAILED; } void ppb_flash_file_modulelocal_free_dir_contents(PP_Instance instance, struct PP_DirContents_Dev *contents) { for (int k = 0; k < contents->count; k ++) free((char*)contents->entries[k].name); free(contents->entries); free(contents); } int32_t ppb_flash_file_modulelocal_create_temporary_file(PP_Instance instance, PP_FileHandle *file) { (void)instance; char *tmpfname; // TODO: find a good directory for temporary files tmpfname = g_strdup_printf("/tmp/FreshTempXXXXXX"); *file = mkstemp(tmpfname); unlink(tmpfname); g_free(tmpfname); if (*file < 0) return PP_ERROR_FAILED; return PP_OK; } // trace wrappers TRACE_WRAPPER int32_t trace_ppb_flash_file_file_ref_open_file(PP_Resource file_ref_id, int32_t mode, PP_FileHandle *file) { trace_info("[PPB] {full} %s file_ref_id=%d, mode=%d\n", __func__+6, file_ref_id, mode); return ppb_flash_file_file_ref_open_file(file_ref_id, mode, file); } TRACE_WRAPPER int32_t trace_ppb_flash_file_file_ref_query_file(PP_Resource file_ref_id, struct PP_FileInfo *info) { trace_info("[PPB] {full} %s file_ref_id=%d\n", __func__+6, file_ref_id); return ppb_flash_file_file_ref_query_file(file_ref_id, info); } TRACE_WRAPPER bool trace_ppb_flash_file_modulelocal_create_thread_adapter_for_instance(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_flash_file_modulelocal_create_thread_adapter_for_instance(instance); } TRACE_WRAPPER void trace_ppb_flash_file_modulelocal_clear_thread_adapter_for_instance(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); ppb_flash_file_modulelocal_clear_thread_adapter_for_instance(instance); } TRACE_WRAPPER int32_t trace_ppb_flash_file_modulelocal_open_file(PP_Instance instance, const char *path, int32_t mode, PP_FileHandle *file) { trace_info("[PPB] {full} %s instance=%d, path=%s, mode=%d\n", __func__+6, instance, path, mode); return ppb_flash_file_modulelocal_open_file(instance, path, mode, file); } TRACE_WRAPPER int32_t trace_ppb_flash_file_modulelocal_rename_file(PP_Instance instance, const char *path_from, const char *path_to) { trace_info("[PPB] {full} %s instance=%d, path_from=%s, path_to=%s\n", __func__+6, instance, path_from, path_to); return ppb_flash_file_modulelocal_rename_file(instance, path_from, path_to); } TRACE_WRAPPER int32_t trace_ppb_flash_file_modulelocal_delete_file_or_dir(PP_Instance instance, const char *path, PP_Bool recursive) { trace_info("[PPB] {full} %s instance=%d, path=%s, recursive=%d\n", __func__+6, instance, path, recursive); return ppb_flash_file_modulelocal_delete_file_or_dir(instance, path, recursive); } TRACE_WRAPPER int32_t trace_ppb_flash_file_modulelocal_create_dir(PP_Instance instance, const char *path) { trace_info("[PPB] {full} %s instance=%d, path=%s\n", __func__+6, instance, path); return ppb_flash_file_modulelocal_create_dir(instance, path); } TRACE_WRAPPER int32_t trace_ppb_flash_file_modulelocal_query_file(PP_Instance instance, const char *path, struct PP_FileInfo *info) { trace_info("[PPB] {full} %s instance=%d, path=%s\n", __func__+6, instance, path); return ppb_flash_file_modulelocal_query_file(instance, path, info); } TRACE_WRAPPER int32_t trace_ppb_flash_file_modulelocal_get_dir_contents(PP_Instance instance, const char *path, struct PP_DirContents_Dev **contents) { trace_info("[PPB] {full} %s instance=%d, path=%s\n", __func__+6, instance, path); return ppb_flash_file_modulelocal_get_dir_contents(instance, path, contents); } TRACE_WRAPPER void trace_ppb_flash_file_modulelocal_free_dir_contents(PP_Instance instance, struct PP_DirContents_Dev *contents) { trace_info("[PPB] {full} %s instance=%d, contents=%p\n", __func__+6, instance, contents); ppb_flash_file_modulelocal_free_dir_contents(instance, contents); } TRACE_WRAPPER int32_t trace_ppb_flash_file_modulelocal_create_temporary_file(PP_Instance instance, PP_FileHandle *file) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_flash_file_modulelocal_create_temporary_file(instance, file); } const struct PPB_Flash_File_FileRef ppb_flash_file_file_ref_interface_2_0 = { .OpenFile = TWRAPF(ppb_flash_file_file_ref_open_file), .QueryFile = TWRAPF(ppb_flash_file_file_ref_query_file), }; const struct PPB_Flash_File_ModuleLocal_3_0 ppb_flash_file_modulelocal_interface_3_0 = { .CreateThreadAdapterForInstance = TWRAPF(ppb_flash_file_modulelocal_create_thread_adapter_for_instance), .ClearThreadAdapterForInstance = TWRAPF(ppb_flash_file_modulelocal_clear_thread_adapter_for_instance), .OpenFile = TWRAPF(ppb_flash_file_modulelocal_open_file), .RenameFile = TWRAPF(ppb_flash_file_modulelocal_rename_file), .DeleteFileOrDir = TWRAPF(ppb_flash_file_modulelocal_delete_file_or_dir), .CreateDir = TWRAPF(ppb_flash_file_modulelocal_create_dir), .QueryFile = TWRAPF(ppb_flash_file_modulelocal_query_file), .GetDirContents = TWRAPF(ppb_flash_file_modulelocal_get_dir_contents), .FreeDirContents = TWRAPF(ppb_flash_file_modulelocal_free_dir_contents), .CreateTemporaryFile = TWRAPF(ppb_flash_file_modulelocal_create_temporary_file), }; static void __attribute__((constructor)) constructor_ppb_flash_file(void) { register_interface(PPB_FLASH_FILE_FILEREF_INTERFACE, &ppb_flash_file_file_ref_interface_2_0); register_interface(PPB_FLASH_FILE_MODULELOCAL_INTERFACE_3_0, &ppb_flash_file_modulelocal_interface_3_0); } freshplayerplugin-0.3.9/src/ppb_flash_file.h000066400000000000000000000053601321746453100211750ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include int32_t ppb_flash_file_file_ref_open_file(PP_Resource file_ref_id, int32_t mode, PP_FileHandle *file); int32_t ppb_flash_file_file_ref_query_file(PP_Resource file_ref_id, struct PP_FileInfo *info); bool ppb_flash_file_modulelocal_create_thread_adapter_for_instance(PP_Instance instance); void ppb_flash_file_modulelocal_clear_thread_adapter_for_instance(PP_Instance instance); int32_t ppb_flash_file_modulelocal_open_file(PP_Instance instance, const char *path, int32_t mode, PP_FileHandle *file); int32_t ppb_flash_file_modulelocal_rename_file(PP_Instance instance, const char *path_from, const char *path_to); int32_t ppb_flash_file_modulelocal_delete_file_or_dir(PP_Instance instance, const char *path, PP_Bool recursive); int32_t ppb_flash_file_modulelocal_create_dir(PP_Instance instance, const char *path); int32_t ppb_flash_file_modulelocal_query_file(PP_Instance instance, const char *path, struct PP_FileInfo *info); int32_t ppb_flash_file_modulelocal_get_dir_contents(PP_Instance instance, const char *path, struct PP_DirContents_Dev **contents); void ppb_flash_file_modulelocal_free_dir_contents(PP_Instance instance, struct PP_DirContents_Dev *contents); int32_t ppb_flash_file_modulelocal_create_temporary_file(PP_Instance instance, PP_FileHandle *file); freshplayerplugin-0.3.9/src/ppb_flash_font_file.c000066400000000000000000000157151321746453100222230ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "font.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_flash_font_file.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include // for htonl() #include #include #include #include #include FT_TRUETYPE_TABLES_H struct pp_flash_font_file_s { COMMON_STRUCTURE_FIELDS PangoFont *font; FT_Face ft_face; PP_PrivateFontCharset charset; }; STATIC_ASSERT(sizeof(struct pp_flash_font_file_s) <= LARGEST_RESOURCE_SIZE); PP_Resource ppb_flash_font_file_create(PP_Instance instance, const struct PP_BrowserFont_Trusted_Description *description, PP_PrivateFontCharset charset) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource font_file = pp_resource_allocate(PP_RESOURCE_FLASH_FONT_FILE, pp_i); struct pp_flash_font_file_s *fff = pp_resource_acquire(font_file, PP_RESOURCE_FLASH_FONT_FILE); if (!fff) { trace_error("%s, resource allocation error\n", __func__); return 0; } PangoFontDescription *font_desc = pp_browser_font_desc_to_pango_font_desc(description); fff->font = pango_context_load_font(tables_get_pango_ctx(), font_desc); pango_font_description_free(font_desc); fff->ft_face = pango_fc_font_lock_face(PANGO_FC_FONT(fff->font)); pp_resource_release(font_file); return font_file; } static void ppb_flash_font_file_destroy(void *ptr) { struct pp_flash_font_file_s *fff = ptr; pango_fc_font_unlock_face(PANGO_FC_FONT(fff->font)); if (fff->font) { g_object_unref(fff->font); fff->font = NULL; } } PP_Bool ppb_flash_font_file_is_flash_font_file(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_FLASH_FONT_FILE; } PP_Bool ppb_flash_font_file_get_font_table(PP_Resource font_file, uint32_t table, void *output, uint32_t *output_length) { table = htonl(table); PP_Bool retval = PP_FALSE; if (!output_length) return PP_FALSE; struct pp_flash_font_file_s *fff = pp_resource_acquire(font_file, PP_RESOURCE_FLASH_FONT_FILE); if (!fff) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } FT_ULong len = 0; FT_Error ft_error = FT_Load_Sfnt_Table(fff->ft_face, table, 0, NULL, &len); if (output == NULL) { *output_length = len; retval = ft_error == 0 ? PP_TRUE : PP_FALSE; } else if (*output_length < len) { // not enough space retval = PP_FALSE; } else { ft_error = FT_Load_Sfnt_Table(fff->ft_face, table, 0, output, &len); retval = ft_error == 0 ? PP_TRUE : PP_FALSE; } if (ft_error != 0) { trace_info_f(" ft_error=0x%02x\n", ft_error); } pp_resource_release(font_file); return retval; } PP_Bool ppb_flash_font_file_is_supported_for_windows(void) { return PP_TRUE; } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_flash_font_file_create(PP_Instance instance, const struct PP_BrowserFont_Trusted_Description *description, PP_PrivateFontCharset charset) { char *s_face = trace_var_as_string(description->face); trace_info("[PPB] {full} %s instance=%d, description={.face=%s, .family=%d, .size=%u, " ".weight=%d, .italic=%u, .small_caps=%u, .letter_spacing=%d, .word_spacing=%d}, " ".charset=%d\n", __func__+6, instance, s_face, description->family, description->size, description->weight, description->italic, description->small_caps, description->letter_spacing, description->word_spacing, charset); g_free(s_face); return ppb_flash_font_file_create(instance, description, charset); } TRACE_WRAPPER PP_Bool trace_ppb_flash_font_file_is_flash_font_file(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_flash_font_file_is_flash_font_file(resource); } TRACE_WRAPPER PP_Bool trace_ppb_flash_font_file_get_font_table(PP_Resource font_file, uint32_t table, void *output, uint32_t *output_length) { trace_info("[PPB] {full} %s font_file=%d, table=%c%c%c%c, output=%p\n", __func__+6, font_file, table & 0xffu, (table >> 8) & 0xffu, (table >> 16) & 0xffu, (table >> 24) & 0xffu, output); return ppb_flash_font_file_get_font_table(font_file, table, output, output_length); } TRACE_WRAPPER PP_Bool trace_ppb_flash_font_file_is_supported_for_windows(void) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_flash_font_file_is_supported_for_windows(); } const struct PPB_Flash_FontFile_0_1 ppb_flash_font_file_interface_0_1 = { .Create = TWRAPF(ppb_flash_font_file_create), .IsFlashFontFile = TWRAPF(ppb_flash_font_file_is_flash_font_file), .GetFontTable = TWRAPF(ppb_flash_font_file_get_font_table), }; const struct PPB_Flash_FontFile_0_2 ppb_flash_font_file_interface_0_2 = { .Create = TWRAPF(ppb_flash_font_file_create), .IsFlashFontFile = TWRAPF(ppb_flash_font_file_is_flash_font_file), .GetFontTable = TWRAPF(ppb_flash_font_file_get_font_table), .IsSupportedForWindows = TWRAPF(ppb_flash_font_file_is_supported_for_windows), }; static void __attribute__((constructor)) constructor_ppb_flash_font_file(void) { register_interface(PPB_FLASH_FONTFILE_INTERFACE_0_1, &ppb_flash_font_file_interface_0_1); register_interface(PPB_FLASH_FONTFILE_INTERFACE_0_2, &ppb_flash_font_file_interface_0_2); register_resource(PP_RESOURCE_FLASH_FONT_FILE, ppb_flash_font_file_destroy); } freshplayerplugin-0.3.9/src/ppb_flash_font_file.h000066400000000000000000000033071321746453100222220ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include PP_Resource ppb_flash_font_file_create(PP_Instance instance, const struct PP_BrowserFont_Trusted_Description *description, PP_PrivateFontCharset charset); PP_Bool ppb_flash_font_file_is_flash_font_file(PP_Resource resource); PP_Bool ppb_flash_font_file_get_font_table(PP_Resource font_file, uint32_t table, void *output, uint32_t *output_length); PP_Bool ppb_flash_font_file_is_supported_for_windows(void); freshplayerplugin-0.3.9/src/ppb_flash_fullscreen.c000066400000000000000000000542611321746453100224170ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "config.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_core.h" #include "ppb_flash_fullscreen.h" #include "ppb_instance.h" #include "ppb_view.h" #include "tables.h" #include "trace_core.h" #include "utils.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include static volatile gint currently_fullscreen = 0; static GAsyncQueue *fullscreen_transition_queue = NULL; static volatile gint run_fullscreen_thread = 1; static volatile gint run_delay_thread = 1; static pthread_barrier_t cross_thread_call_barrier; static Atom freshwrappercommand_atom; struct handle_event_comt_param_s { PP_Instance instance_id; XEvent ev; }; struct thread_param_s { struct pp_instance_s *pp_i; Window browser_window; }; enum { FSCMD_UNDEFINED = 0, FSCMD_FULLSCREEN_WAIT_IS_OVER, FSCMD_VSYNC, }; static void __attribute__((destructor)) destructor_ppb_flash_fullscreen(void) { if (fullscreen_transition_queue) g_async_queue_unref(fullscreen_transition_queue); g_atomic_int_set(&run_fullscreen_thread, 0); } PP_Bool ppb_flash_fullscreen_is_fullscreen(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_FALSE; } pthread_mutex_lock(&display.lock); uint32_t is_fullscreen = pp_i->is_fullscreen_apparent; pthread_mutex_unlock(&display.lock); return is_fullscreen; } static void call_did_change_view_comt(void *user_data, int32_t result) { PP_Instance instance = GPOINTER_TO_INT(user_data); struct pp_instance_s *pp_i = tables_get_pp_instance(instance); const int is_fullscreen = result; // check if instance is still alive if (!pp_i) goto done; if (!g_atomic_int_get(&pp_i->instance_loaded)) { goto done; } PP_Resource view = pp_resource_allocate(PP_RESOURCE_VIEW, pp_i); struct pp_view_s *v = pp_resource_acquire(view, PP_RESOURCE_VIEW); if (!v) { trace_error("%s, resource allocation failure\n", __func__); goto done; } // looks like transition is over, so current window geometry can be safely used as // full screen size pp_i->fs_width = pp_i->fs_width_current; pp_i->fs_height = pp_i->fs_height_current; v->rect.point.x = 0; v->rect.point.y = 0; if (is_fullscreen) { v->rect.size.width = pp_i->fs_width / config.device_scale + 0.5; v->rect.size.height = pp_i->fs_height / config.device_scale + 0.5; } else { v->rect.size.width = pp_i->width / config.device_scale + 0.5; v->rect.size.height = pp_i->height / config.device_scale + 0.5; } pp_resource_release(view); pthread_mutex_lock(&display.lock); pp_i->is_fullscreen_apparent = is_fullscreen; pthread_mutex_unlock(&display.lock); pp_i->ppp_instance_1_1->DidChangeView(pp_i->id, view); ppb_core_release_resource(view); done: pthread_barrier_wait(&cross_thread_call_barrier); } static void handle_event_ptac(void *p) { struct handle_event_comt_param_s *params = p; struct pp_instance_s *pp_i = tables_get_pp_instance(params->instance_id); if (pp_i) { NPP_HandleEvent(pp_i->npp, ¶ms->ev); } g_slice_free(struct handle_event_comt_param_s, params); pthread_barrier_wait(&cross_thread_call_barrier); } static void get_browser_window(void *p) { struct thread_param_s *tp = p; if (npn.getvalue(tp->pp_i->npp, NPNVnetscapeWindow, &tp->browser_window) != NPERR_NO_ERROR) { tp->browser_window = None; trace_error("%s, failed to get NPNVnetscapeWindow\n", __func__); } pthread_barrier_wait(&cross_thread_call_barrier); } static void append_wm_protocol(Display *dpy, Window wnd, Atom a) { Atom *protocols = NULL; int n = 0; XGetWMProtocols(dpy, wnd, &protocols, &n); // check if the atom was already set for (int k = 0; k < n; k ++) if (protocols[k] == a) goto done; // append to the end Atom *p2 = malloc(sizeof(Atom) * (n + 1)); if (!p2) goto done; memcpy(p2, protocols, sizeof(Atom) * n); p2[n] = a; XSetWMProtocols(dpy, wnd, p2, n + 1); free(p2); done: XFree(protocols); } static void call_did_change_view(PP_Instance instance_id, int is_fullscreen) { ppb_core_call_on_main_thread2(0, PP_MakeCCB(call_did_change_view_comt, GINT_TO_POINTER(instance_id)), is_fullscreen, __func__); pthread_barrier_wait(&cross_thread_call_barrier); } static void craft_graphicsexpose_event(XEvent *ev, Display *dpy, struct pp_instance_s *pp_i) { memset(ev, 0, sizeof(*ev)); ev->xgraphicsexpose.type = GraphicsExpose; ev->xgraphicsexpose.display = dpy; ev->xgraphicsexpose.drawable = pp_i->fs_wnd; ev->xgraphicsexpose.width = pp_i->fs_width; ev->xgraphicsexpose.height = pp_i->fs_height; } static void fullscreen_window_thread_int(Display *dpy, struct thread_param_s *tp) { struct pp_instance_s *pp_i = tp->pp_i; int px, py; Window root, child; int rel_x, rel_y; unsigned int mask; const int wnd_size = 10; const int screen = DefaultScreen(dpy); trace_info_f("%s started\n", __func__); // get current mouse pointer position XQueryPointer(dpy, DefaultRootWindow(dpy), &root, &child, &px, &py, &rel_x, &rel_y, &mask); // create tiny window where mouse pointer is XSetWindowAttributes attrs = { .background_pixel = 0x000000, .backing_store = Always, }; pp_i->fs_wnd = XCreateWindow(dpy, DefaultRootWindow(dpy), px - wnd_size / 2, py - wnd_size / 2, wnd_size, wnd_size, 0, DefaultDepth(dpy, screen), InputOutput, DefaultVisual(dpy, screen), CWBackPixel | CWBackingStore, &attrs); XSelectInput(dpy, pp_i->fs_wnd, KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask | StructureNotifyMask); // tell window manager we want exact position XSizeHints size_hints = { .flags = USPosition, .x = px - wnd_size / 2, .y = py - wnd_size / 2, }; XSetWMNormalHints(dpy, pp_i->fs_wnd, &size_hints); // update windows state properties Atom netwm_state_atom = XInternAtom(dpy, "_NET_WM_STATE", False); // build state atom list Atom atom; GArray *state_atoms = g_array_sized_new(FALSE, TRUE, sizeof(Atom), 10); if (config.fullscreen_horz_maximize_atom) { atom = XInternAtom(dpy, "_NET_WM_STATE_MAXIMIZED_HORZ", False); // fill horizontal space g_array_append_val(state_atoms, atom); } if (config.fullscreen_vert_maximize_atom) { atom = XInternAtom(dpy, "_NET_WM_STATE_MAXIMIZED_VERT", False); // fill vertical space g_array_append_val(state_atoms, atom); } atom = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); // go fullscreen g_array_append_val(state_atoms, atom); if (config.tie_fullscreen_window_to_browser) { atom = XInternAtom(dpy, "_NET_WM_STATE_SKIP_PAGER", False); // do not appear in pager g_array_append_val(state_atoms, atom); atom = XInternAtom(dpy, "_NET_WM_STATE_SKIP_TASKBAR", False); // do not appear in taskbar g_array_append_val(state_atoms, atom); } XChangeProperty(dpy, pp_i->fs_wnd, netwm_state_atom, XA_ATOM, 32, PropModeReplace, (unsigned char *)state_atoms->data, state_atoms->len); g_array_free(state_atoms, TRUE); // give window a name const char *fs_window_name = "freshwrapper fullscreen window"; XChangeProperty(dpy, pp_i->fs_wnd, XInternAtom(dpy, "WM_NAME", False), XInternAtom(dpy, "STRING", False), 8, PropModeReplace, (unsigned char *)fs_window_name, strlen(fs_window_name)); XChangeProperty(dpy, pp_i->fs_wnd, XInternAtom(dpy, "_NET_WM_NAME", False), XInternAtom(dpy, "UTF8_STRING", False), 8, PropModeReplace, (unsigned char *)fs_window_name, strlen(fs_window_name)); // set hint for a compositor long int net_wm_bypass_compositor_hint_on = 1; XChangeProperty(dpy, pp_i->fs_wnd, XInternAtom(dpy, "_NET_WM_BYPASS_COMPOSITOR", False), XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&net_wm_bypass_compositor_hint_on, 1); // tell window manager we want to handle WM_DELETE_WINDOW Atom wm_delete_window_atom = XInternAtom(dpy, "WM_DELETE_WINDOW", False); append_wm_protocol(dpy, pp_i->fs_wnd, wm_delete_window_atom); // show window XMapRaised(dpy, pp_i->fs_wnd); XSync(dpy, False); // round trip to browser thread to get browser window tp->browser_window = None; ppb_core_call_on_browser_thread(pp_i->id, get_browser_window, tp); pthread_barrier_wait(&cross_thread_call_barrier); // set window transient for browser window if (config.tie_fullscreen_window_to_browser) { if (tp->browser_window != None) XSetTransientForHint(dpy, pp_i->fs_wnd, tp->browser_window); else trace_error("%s, can't get tp->browser_window\n", __func__); } pthread_mutex_lock(&display.lock); pp_i->is_fullscreen = 1; pp_i->fs_width_current = wnd_size; pp_i->fs_height_current = wnd_size; pthread_mutex_unlock(&display.lock); int called_did_change_view = 0; int graphics_expose_events_in_queue = 0; int quit_message_received = 0; int graphics_expose_was_at_least_once = 0; while (1) { XEvent ev; int handled = 0; KeySym keysym; if (quit_message_received && graphics_expose_was_at_least_once) goto quit_and_destroy_fs_wnd; XNextEvent(dpy, &ev); switch (ev.type) { case KeyPress: keysym = XLookupKeysym(&ev.xkey, 0); if (XK_Escape == keysym) quit_message_received = 1; break; case ClientMessage: handled = 1; if (ev.xclient.data.l[0] == (long)wm_delete_window_atom) quit_message_received = 1; if (ev.xclient.message_type == freshwrappercommand_atom) { switch (ev.xclient.data.l[0]) { case FSCMD_FULLSCREEN_WAIT_IS_OVER: if (!called_did_change_view) { call_did_change_view(pp_i->id, 1); called_did_change_view = 1; // add unrequested GraphicsExpose in case some was lost during // fullscreen transition craft_graphicsexpose_event(&ev, dpy, pp_i); handled = 0; // feed HandleEvent with crafted event } break; case FSCMD_VSYNC: if (graphics_expose_events_in_queue > 0) { craft_graphicsexpose_event(&ev, dpy, pp_i); graphics_expose_events_in_queue -= 1; graphics_expose_was_at_least_once = 1; handled = 0; // feed HandleEvent with crafted event } break; case FSCMD_UNDEFINED: default: // do nothing break; } } break; case ConfigureNotify: pthread_mutex_lock(&display.lock); pp_i->fs_width_current = ev.xconfigure.width; pp_i->fs_height_current = ev.xconfigure.height; pthread_mutex_unlock(&display.lock); handled = 1; break; case ReparentNotify: case MapNotify: case UnmapNotify: case DestroyNotify: case Expose: handled = 1; break; case GraphicsExpose: if (config.enable_vsync) { graphics_expose_events_in_queue += 1; handled = 1; } else { graphics_expose_was_at_least_once = 1; handled = 0; } break; } ev.xany.display = display.x; if (!handled) { struct handle_event_comt_param_s *params = g_slice_alloc(sizeof(*params)); params->instance_id = pp_i->id; params->ev = ev; ppb_core_call_on_browser_thread(pp_i->id, handle_event_ptac, params); pthread_barrier_wait(&cross_thread_call_barrier); } } quit_and_destroy_fs_wnd: pthread_mutex_lock(&display.lock); pp_i->is_fullscreen = 0; pp_i->is_fullscreen_apparent = 0; pthread_mutex_unlock(&display.lock); XDestroyWindow(dpy, pp_i->fs_wnd); XFlush(dpy); call_did_change_view(pp_i->id, 0); // GraphicsExpose could be jammed in delay loop. We need to call it here explicitly, // to prevent callback chain breakage. while (graphics_expose_events_in_queue > 0) { XEvent ev = { .xgraphicsexpose = { .type = GraphicsExpose, .display = dpy, .drawable = pp_i->wnd, .width = pp_i->width, .height = pp_i->height, } }; struct handle_event_comt_param_s *params = g_slice_alloc(sizeof(*params)); params->instance_id = pp_i->id; params->ev = ev; ppb_core_call_on_browser_thread(pp_i->id, handle_event_ptac, params); pthread_barrier_wait(&cross_thread_call_barrier); graphics_expose_events_in_queue -= 1; } g_slice_free(struct thread_param_s, tp); trace_info_f("%s terminated\n", __func__); } static int enable_drm_vsync = 1; static void wait_vsync_drm(void) { if (display.dri_fd < 0) return; int ret; do { drm_wait_vblank_t dwv = { .request.type = _DRM_VBLANK_RELATIVE, .request.sequence = 1, }; ret = ioctl(display.dri_fd, DRM_IOCTL_WAIT_VBLANK, &dwv); } while (ret != 0 && errno == EINTR); if (ret != 0) { trace_warning("Got an error (errno=%d) while waiting for VSYNC event. Disabling VSYNC.\n", errno); enable_drm_vsync = 0; } if (config.vsync_afterwait_us > 0) usleep(config.vsync_afterwait_us); } /// thread used for active waiting static void * delay_thread(void *param) { struct thread_param_s *tp = param; struct pp_instance_s *pp_i = tp->pp_i; // first, wait some time before window manager performs fullscreen transition usleep(config.fs_delay_ms * 1000); pthread_mutex_lock(&display.lock); if (pp_i->is_fullscreen) { XEvent ev = { .xclient = { .type = ClientMessage, .window = pp_i->fs_wnd, .message_type = freshwrappercommand_atom, .format = 32, .data.l[0] = FSCMD_FULLSCREEN_WAIT_IS_OVER, } }; XSendEvent(display.x, ev.xclient.window, False, NoEventMask, &ev); XFlush(display.x); } pthread_mutex_unlock(&display.lock); if (!config.enable_vsync) { // if no vsync required, just wait until thread could be terminated while (g_atomic_int_get(&run_delay_thread)) { usleep(300 * 1000); } return NULL; } // wait for vsync events, pass them back to fullscreen thread while (g_atomic_int_get(&run_delay_thread)) { pthread_mutex_lock(&display.lock); if (pp_i->is_fullscreen) { XEvent ev = { .xclient = { .type = ClientMessage, .window = pp_i->fs_wnd, .message_type = freshwrappercommand_atom, .format = 32, .data.l[0] = FSCMD_VSYNC, } }; XSendEvent(display.x, ev.xclient.window, False, NoEventMask, &ev); XFlush(display.x); } pthread_mutex_unlock(&display.lock); if (display.dri_fd >= 0) { if (enable_drm_vsync) wait_vsync_drm(); else usleep(16 * 1000); } else { usleep(16 * 1000); } } return NULL; } static void * fullscreen_window_thread(void *p) { GAsyncQueue *async_q = fullscreen_transition_queue; Display *dpy = XOpenDisplay(NULL); freshwrappercommand_atom = XInternAtom(display.x, "FRESHWRAPPER_COMMAND", False); g_async_queue_ref(async_q); while (g_atomic_int_get(&run_fullscreen_thread)) { struct thread_param_s *tp = g_async_queue_pop(async_q); pthread_t t; g_atomic_int_set(¤tly_fullscreen, 1); g_atomic_int_set(&run_delay_thread, 1); pthread_create(&t, NULL, delay_thread, tp); fullscreen_window_thread_int(dpy, tp); g_atomic_int_set(&run_delay_thread, 0); pthread_join(t, NULL); g_atomic_int_set(¤tly_fullscreen, 0); } pthread_barrier_destroy(&cross_thread_call_barrier); g_async_queue_unref(async_q); XCloseDisplay(dpy); return NULL; } PP_Bool ppb_flash_fullscreen_set_fullscreen(PP_Instance instance, PP_Bool fullscreen) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_FALSE; } pthread_mutex_lock(&display.lock); int in_same_state = (!!fullscreen == !!pp_i->is_fullscreen); pthread_mutex_unlock(&display.lock); if (in_same_state) return PP_FALSE; if (!fullscreen_transition_queue) { pthread_t t; fullscreen_transition_queue = g_async_queue_new(); pthread_create(&t, NULL, fullscreen_window_thread, NULL); pthread_detach(t); } if (fullscreen) { if (g_atomic_int_get(¤tly_fullscreen)) { // can't go fullscreen -- other instance is still fullscreen return PP_FALSE; } struct thread_param_s *tparams = g_slice_alloc(sizeof(*tparams)); tparams->pp_i = pp_i; g_async_queue_push(fullscreen_transition_queue, tparams); } else if (g_atomic_int_get(¤tly_fullscreen)) { pthread_mutex_lock(&display.lock); pp_i->is_fullscreen = 0; XKeyEvent ev = { .type = KeyPress, .display = display.x, .window = pp_i->fs_wnd, .keycode = XKeysymToKeycode(display.x, XK_Escape) }; XSendEvent(display.x, pp_i->fs_wnd, False, 0, (void *)&ev); XFlush(display.x); pthread_mutex_unlock(&display.lock); } return PP_TRUE; } PP_Bool ppb_flash_fullscreen_get_screen_size(PP_Instance instance, struct PP_Size *size) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_FALSE; } size->width = pp_i->fs_width > 0 ? pp_i->fs_width : display.min_width; size->height = pp_i->fs_height > 0 ? pp_i->fs_height : display.min_height; size->width /= config.device_scale; size->height /= config.device_scale; return PP_TRUE; } // trace wrappers TRACE_WRAPPER PP_Bool trace_ppb_flash_fullscreen_is_fullscreen(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_flash_fullscreen_is_fullscreen(instance); } TRACE_WRAPPER PP_Bool trace_ppb_flash_fullscreen_set_fullscreen(PP_Instance instance, PP_Bool fullscreen) { trace_info("[PPB] {full} %s instance=%d fullscreen=%d\n", __func__+6, instance, fullscreen); return ppb_flash_fullscreen_set_fullscreen(instance, fullscreen); } TRACE_WRAPPER PP_Bool trace_ppb_flash_fullscreen_get_screen_size(PP_Instance instance, struct PP_Size *size) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_flash_fullscreen_get_screen_size(instance, size); } const struct PPB_FlashFullscreen_1_0 ppb_flash_fullscreen_interface_1_0 = { .IsFullscreen = TWRAPF(ppb_flash_fullscreen_is_fullscreen), .SetFullscreen = TWRAPF(ppb_flash_fullscreen_set_fullscreen), .GetScreenSize = TWRAPF(ppb_flash_fullscreen_get_screen_size), }; static void __attribute__((constructor)) constructor_ppb_flash_fullscreen(void) { pthread_barrier_init(&cross_thread_call_barrier, NULL, 2); register_interface(PPB_FLASHFULLSCREEN_INTERFACE_1_0, &ppb_flash_fullscreen_interface_1_0); } freshplayerplugin-0.3.9/src/ppb_flash_fullscreen.h000066400000000000000000000027121321746453100224160ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include PP_Bool ppb_flash_fullscreen_is_fullscreen(PP_Instance instance); PP_Bool ppb_flash_fullscreen_set_fullscreen(PP_Instance instance, PP_Bool fullscreen); PP_Bool ppb_flash_fullscreen_get_screen_size(PP_Instance instance, struct PP_Size *size); freshplayerplugin-0.3.9/src/ppb_flash_menu.c000066400000000000000000000252031321746453100212130ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "autogenerated_version_info.h" #include "config.h" #include "gtk_wrapper.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_core.h" #include "ppb_flash_menu.h" #include "ppb_instance.h" #include "ppb_message_loop.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include "utils.h" #include #include #include #include struct pp_flash_menu_s { COMMON_STRUCTURE_FIELDS GtkWidget *menu; }; STATIC_ASSERT(sizeof(struct pp_flash_menu_s) <= LARGEST_RESOURCE_SIZE); static int32_t *popup_menu_result = NULL; static struct PP_CompletionCallback popup_menu_ccb = { }; static PP_Resource popup_menu_ccb_ml = 0; static int popup_menu_sentinel = 0; static int popup_menu_canceled = 0; // called when used selects menu item static void menu_item_activated(GtkMenuItem *mi, gpointer user_data) { if (popup_menu_result) *popup_menu_result = (size_t)user_data; // set the flag indicating user selected something, not just aborted popup_menu_canceled = 0; } // called when used selects menu item (workaround for submenus) static void menu_item_button_press(GtkWidget *widget, GdkEvent *event, gpointer user_data) { if (popup_menu_result) *popup_menu_result = (size_t)user_data; // set the flag indicating user selected something, not just aborted popup_menu_canceled = 0; } // called when menu is closed static void menu_selection_done(GtkMenuShell *object, gboolean user_data) { int32_t code = popup_menu_canceled ? PP_ERROR_USERCANCEL : PP_OK; ppb_message_loop_post_work_with_result(popup_menu_ccb_ml, popup_menu_ccb, 0, code, 0, __func__); popup_menu_sentinel = 0; popup_menu_result = NULL; } static GtkWidget * convert_menu(const struct PP_Flash_Menu *pp_menu) { GtkWidget *menu = gw_gtk_menu_new(); for (uintptr_t k = 0; k < pp_menu->count; k ++) { const struct PP_Flash_MenuItem pp_mi = pp_menu->items[k]; GtkWidget *mi = NULL; switch (pp_mi.type) { case PP_FLASH_MENUITEM_TYPE_NORMAL: mi = gw_gtk_menu_item_new_with_label(pp_mi.name); break; case PP_FLASH_MENUITEM_TYPE_CHECKBOX: mi = gw_gtk_check_menu_item_new_with_label(pp_mi.name); gw_gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi), pp_mi.checked != PP_FALSE); break; case PP_FLASH_MENUITEM_TYPE_SEPARATOR: mi = gw_gtk_separator_menu_item_new(); break; case PP_FLASH_MENUITEM_TYPE_SUBMENU: mi = gw_gtk_menu_item_new_with_label(pp_mi.name); break; } if (!mi) continue; gw_gtk_widget_set_sensitive(mi, pp_mi.enabled != PP_FALSE); gw_gtk_widget_show(mi); gw_gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); if (pp_mi.type == PP_FLASH_MENUITEM_TYPE_SUBMENU) { gw_gtk_menu_item_set_submenu(GTK_MENU_ITEM(mi), convert_menu(pp_mi.submenu)); } else { // each menu item have specific id associated g_signal_connect(G_OBJECT(mi), "activate", G_CALLBACK(menu_item_activated), (void*)(size_t)pp_mi.id); // connect "button-press-event" to workaround submenu "activate" signal missing issue g_signal_connect(G_OBJECT(mi), "button-press-event", G_CALLBACK(menu_item_button_press), (void*)(size_t)pp_mi.id); } } return menu; } static void append_version_information(GtkWidget *menu) { GtkWidget *mi; mi = gw_gtk_separator_menu_item_new(); gw_gtk_widget_show(mi); gw_gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); gchar *s = g_strdup_printf("freshwrapper, %s", g_version_info); mi = gw_gtk_menu_item_new_with_label(s); g_free(s); gw_gtk_widget_set_sensitive(mi, FALSE); gw_gtk_widget_show(mi); gw_gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); } struct flash_menu_create_param_s { PP_Resource flash_menu; const struct PP_Flash_Menu *menu_data; PP_Resource m_loop; int depth; }; static void flash_menu_create_ptac(void *param) { struct flash_menu_create_param_s *p = param; struct pp_flash_menu_s *fm = pp_resource_acquire(p->flash_menu, PP_RESOURCE_FLASH_MENU); if (!fm) { trace_error("%s, bad resource\n", __func__); goto quit; } // recursively construct menu fm->menu = convert_menu(p->menu_data); if (config.show_version_info) append_version_information(fm->menu); // we need notification on menu close g_signal_connect(fm->menu, "selection-done", G_CALLBACK(menu_selection_done), NULL); pp_resource_release(p->flash_menu); quit: ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void flash_menu_create_comt(void *user_data, int32_t result) { ppb_core_call_on_browser_thread(0, flash_menu_create_ptac, user_data); } PP_Resource ppb_flash_menu_create(PP_Instance instance_id, const struct PP_Flash_Menu *menu_data) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance_id); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource flash_menu = pp_resource_allocate(PP_RESOURCE_FLASH_MENU, pp_i); if (pp_resource_get_type(flash_menu) != PP_RESOURCE_FLASH_MENU) { trace_error("%s, resource allocation failure\n", __func__); return 0; } struct flash_menu_create_param_s *p = g_slice_alloc0(sizeof(*p)); p->flash_menu = flash_menu; p->menu_data = menu_data; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(flash_menu_create_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); g_slice_free1(sizeof(*p), p); return flash_menu; } static void destroy_flash_menu_ptac(void *param) { GtkWidget *menu = param; g_object_unref(menu); } static void ppb_flash_menu_destroy(void *p) { struct pp_flash_menu_s *fm = p; g_object_ref_sink(fm->menu); // actual menu destroy can make something X-related, call in on browser thread ppb_core_call_on_browser_thread(fm->instance->id, destroy_flash_menu_ptac, fm->menu); } PP_Bool ppb_flash_menu_is_flash_menu(PP_Resource resource_id) { return pp_resource_get_type(resource_id) == PP_RESOURCE_FLASH_MENU; } static void menu_popup_ptac(void *p) { GtkWidget *menu = p; gw_gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, gw_gtk_get_current_event_time()); } int32_t ppb_flash_menu_show(PP_Resource menu_id, const struct PP_Point *location, int32_t *selected_id, struct PP_CompletionCallback callback) { struct pp_flash_menu_s *fm = pp_resource_acquire(menu_id, PP_RESOURCE_FLASH_MENU); if (!fm) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } struct pp_instance_s *pp_i = fm->instance; if (popup_menu_sentinel) trace_error("%s, two context menus at the same time\n", __func__); (void)location; // TODO: handle location popup_menu_sentinel = 1; popup_menu_canceled = 1; popup_menu_ccb = callback; popup_menu_ccb_ml = ppb_message_loop_get_current(); popup_menu_result = selected_id; pthread_mutex_lock(&display.lock); // creating and showing menu together with its closing generates pair of focus events, // FocusOut and FocusIn, which should not be passed to the plugin instance. Otherwise they // will tamper with text selection. pp_i->ignore_focus_events_cnt = 2; pthread_mutex_unlock(&display.lock); ppb_core_call_on_browser_thread(pp_i->id, menu_popup_ptac, fm->menu); pp_resource_release(menu_id); return PP_OK_COMPLETIONPENDING; } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_flash_menu_create(PP_Instance instance_id, const struct PP_Flash_Menu *menu_data) { trace_info("[PPB] {full} %s instance_id=%d, menu_data=%p\n", __func__+6, instance_id, menu_data); return ppb_flash_menu_create(instance_id, menu_data); } TRACE_WRAPPER PP_Bool trace_ppb_flash_menu_is_flash_menu(PP_Resource resource_id) { trace_info("[PPB] {full} %s resource_id=%d\n", __func__+6, resource_id); return ppb_flash_menu_is_flash_menu(resource_id); } TRACE_WRAPPER int32_t trace_ppb_flash_menu_show(PP_Resource menu_id, const struct PP_Point *location, int32_t *selected_id, struct PP_CompletionCallback callback) { gchar *s_location = trace_point_as_string(location); trace_info("[PPB] {full} %s menu_id=%d, location=%s, callback={.func=%p, .user_data=%p, " ".flags=%d}\n", __func__+6, menu_id, s_location, callback.func, callback.user_data, callback.flags); g_free(s_location); return ppb_flash_menu_show(menu_id, location, selected_id, callback); } const struct PPB_Flash_Menu_0_2 ppb_flash_menu_interface_0_2 = { .Create = TWRAPF(ppb_flash_menu_create), .IsFlashMenu = TWRAPF(ppb_flash_menu_is_flash_menu), .Show = TWRAPF(ppb_flash_menu_show), }; static void __attribute__((constructor)) constructor_ppb_flash_menu(void) { register_interface(PPB_FLASH_MENU_INTERFACE_0_2, &ppb_flash_menu_interface_0_2); register_resource(PP_RESOURCE_FLASH_MENU, ppb_flash_menu_destroy); } freshplayerplugin-0.3.9/src/ppb_flash_menu.h000066400000000000000000000030271321746453100212200ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include PP_Resource ppb_flash_menu_create(PP_Instance instance_id, const struct PP_Flash_Menu *menu_data); PP_Bool ppb_flash_menu_is_flash_menu(PP_Resource resource_id); int32_t ppb_flash_menu_show(PP_Resource menu_id, const struct PP_Point *location, int32_t *selected_id, struct PP_CompletionCallback callback); freshplayerplugin-0.3.9/src/ppb_flash_message_loop.c000066400000000000000000000124031321746453100227220ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "pp_resource.h" #include "ppb_flash_message_loop.h" #include "ppb_message_loop.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include struct pp_flash_message_loop_s { COMMON_STRUCTURE_FIELDS int running; PP_Resource message_loop; int depth; }; STATIC_ASSERT(sizeof(struct pp_flash_message_loop_s) <= LARGEST_RESOURCE_SIZE); PP_Resource ppb_flash_message_loop_create(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource message_loop = pp_resource_allocate(PP_RESOURCE_FLASH_MESSAGE_LOOP, pp_i); return message_loop; } static void ppb_flash_message_loop_destroy(void *p) { struct pp_flash_message_loop_s *fml = p; if (fml->running) ppb_flash_message_loop_quit(fml->self_id); } PP_Bool ppb_flash_message_loop_is_flash_message_loop(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_FLASH_MESSAGE_LOOP; } int32_t ppb_flash_message_loop_run(PP_Resource flash_message_loop) { struct pp_flash_message_loop_s *fml = pp_resource_acquire(flash_message_loop, PP_RESOURCE_FLASH_MESSAGE_LOOP); if (!fml) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } PP_Resource message_loop = ppb_message_loop_get_current(); fml->running = 1; fml->message_loop = message_loop; fml->depth = ppb_message_loop_get_depth(message_loop) + 1; pp_resource_ref(flash_message_loop); // prevent destroy of running loop pp_resource_release(flash_message_loop); // launching nested loop without depth increase to prevent hang up of previously pushed tasks ppb_message_loop_run_int(message_loop, ML_NESTED); fml = pp_resource_acquire(flash_message_loop, PP_RESOURCE_FLASH_MESSAGE_LOOP); if (fml) { fml->running = 0; pp_resource_release(flash_message_loop); } pp_resource_unref(flash_message_loop); return PP_OK; } void ppb_flash_message_loop_quit(PP_Resource flash_message_loop) { struct pp_flash_message_loop_s *fml = pp_resource_acquire(flash_message_loop, PP_RESOURCE_FLASH_MESSAGE_LOOP); if (!fml) { trace_error("%s, bad resource\n", __func__); return; } if (fml->running) ppb_message_loop_post_quit_depth(fml->message_loop, PP_FALSE, fml->depth); pp_resource_release(flash_message_loop); } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_flash_message_loop_create(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_flash_message_loop_create(instance); } TRACE_WRAPPER PP_Bool trace_ppb_flash_message_loop_is_flash_message_loop(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_flash_message_loop_is_flash_message_loop(resource); } TRACE_WRAPPER int32_t trace_ppb_flash_message_loop_run(PP_Resource flash_message_loop) { trace_info("[PPB] {full} %s flash_message_loop=%d\n", __func__+6, flash_message_loop); return ppb_flash_message_loop_run(flash_message_loop); } TRACE_WRAPPER void trace_ppb_flash_message_loop_quit(PP_Resource flash_message_loop) { trace_info("[PPB] {full} %s flash_message_loop=%d\n", __func__+6, flash_message_loop); return ppb_flash_message_loop_quit(flash_message_loop); } const struct PPB_Flash_MessageLoop_0_1 ppb_flash_message_loop_interface_0_1 = { .Create = TWRAPF(ppb_flash_message_loop_create), .IsFlashMessageLoop = TWRAPF(ppb_flash_message_loop_is_flash_message_loop), .Run = TWRAPF(ppb_flash_message_loop_run), .Quit = TWRAPF(ppb_flash_message_loop_quit), }; static void __attribute__((constructor)) constructor_ppb_flash_message_loop(void) { register_interface(PPB_FLASH_MESSAGELOOP_INTERFACE_0_1, &ppb_flash_message_loop_interface_0_1); register_resource(PP_RESOURCE_FLASH_MESSAGE_LOOP, ppb_flash_message_loop_destroy); } freshplayerplugin-0.3.9/src/ppb_flash_message_loop.h000066400000000000000000000027551321746453100227400ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include PP_Resource ppb_flash_message_loop_create(PP_Instance instance); PP_Bool ppb_flash_message_loop_is_flash_message_loop(PP_Resource resource); int32_t ppb_flash_message_loop_run(PP_Resource flash_message_loop); void ppb_flash_message_loop_quit(PP_Resource flash_message_loop); freshplayerplugin-0.3.9/src/ppb_font.c000066400000000000000000000215121321746453100200370ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "font.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_font.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include #include struct pp_font_s { COMMON_STRUCTURE_FIELDS struct fpp_font ff; }; STATIC_ASSERT(sizeof(struct pp_font_s) <= LARGEST_RESOURCE_SIZE); struct PP_Var ppb_font_get_font_families(PP_Instance instance) { return fpp_font_get_font_families(); } PP_Resource ppb_font_create(PP_Instance instance, const struct PP_FontDescription_Dev *description) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource font = pp_resource_allocate(PP_RESOURCE_FONT, pp_i); struct pp_font_s *f = pp_resource_acquire(font, PP_RESOURCE_FONT); if (!f) { trace_error("%s, resource allocation failure\n", __func__); return 0; } fpp_font_init(&f->ff, description); pp_resource_release(font); return font; } static void ppb_font_destroy(void *p) { struct pp_font_s *f = p; if (!f) return; fpp_font_destroy(&f->ff); } PP_Bool ppb_font_is_font(PP_Resource resource) { return PP_RESOURCE_FONT == pp_resource_get_type(resource); } PP_Bool ppb_font_describe(PP_Resource font, struct PP_FontDescription_Dev *description, struct PP_FontMetrics_Dev *metrics) { struct pp_font_s *f = pp_resource_acquire(font, PP_RESOURCE_FONT); if (!f) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } PP_Bool ret = fpp_font_describe(&f->ff, description, metrics); pp_resource_release(font); return ret; } PP_Bool ppb_font_draw_text_at(PP_Resource font, PP_Resource image_data, const struct PP_TextRun_Dev *text, const struct PP_Point *position, uint32_t color, const struct PP_Rect *clip, PP_Bool image_data_is_opaque) { struct pp_font_s *f = pp_resource_acquire(font, PP_RESOURCE_FONT); if (!f) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } PP_Bool ret = fpp_font_draw_text_at(&f->ff, image_data, text, position, color, clip, image_data_is_opaque); pp_resource_release(font); return ret; } int32_t ppb_font_measure_text(PP_Resource font, const struct PP_TextRun_Dev *text) { struct pp_font_s *f = pp_resource_acquire(font, PP_RESOURCE_FONT); if (!f) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_FAILED; } int32_t ret = fpp_font_measure_text(&f->ff, text); pp_resource_release(font); return ret; } uint32_t ppb_font_character_offset_for_pixel(PP_Resource font, const struct PP_TextRun_Dev *text, int32_t pixel_position) { return 0; } int32_t ppb_font_pixel_offset_for_character(PP_Resource font, const struct PP_TextRun_Dev *text, uint32_t char_offset) { return -1; } // trace wrappers TRACE_WRAPPER struct PP_Var trace_ppb_font_get_font_families(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_font_get_font_families(instance); } TRACE_WRAPPER PP_Resource trace_ppb_font_create(PP_Instance instance, const struct PP_FontDescription_Dev *description) { gchar *s_face = trace_var_as_string(description->face); trace_info("[PPB] {full} %s instance=%d, description={.face=%s, .family=%u, .size=%u, " ".weight=%u, .italic=%u, .small_caps=%u, .letter_spacing=%d, .word_spacing=%d}\n", __func__+6, instance, s_face, description->family, description->size, description->weight, description->italic, description->small_caps, description->letter_spacing, description->word_spacing); g_free(s_face); return ppb_font_create(instance, description); } TRACE_WRAPPER PP_Bool trace_ppb_font_is_font(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_font_is_font(resource); } TRACE_WRAPPER PP_Bool trace_ppb_font_describe(PP_Resource font, struct PP_FontDescription_Dev *description, struct PP_FontMetrics_Dev *metrics) { trace_info("[PPB] {full} %s font=%d\n", __func__+6, font); return ppb_font_describe(font, description, metrics); } TRACE_WRAPPER PP_Bool trace_ppb_font_draw_text_at(PP_Resource font, PP_Resource image_data, const struct PP_TextRun_Dev *text, const struct PP_Point *position, uint32_t color, const struct PP_Rect *clip, PP_Bool image_data_is_opaque) { gchar *s_text = trace_var_as_string(text->text); gchar *s_position = trace_point_as_string(position); gchar *s_clip = trace_rect_as_string(clip); trace_info("[PPB] {full} %s font=%d, image_data=%d, text={.text=%s, .rtl=%u, " ".override_direction=%u}, position=%s, color=0x%08x, clip=%s, " "image_data_is_opaque=%u\n", __func__+6, font, image_data, s_text, text->rtl, text->override_direction, s_position, color, s_clip, image_data_is_opaque); g_free(s_text); g_free(s_position); g_free(s_clip); return ppb_font_draw_text_at(font, image_data, text, position, color, clip, image_data_is_opaque); } TRACE_WRAPPER int32_t trace_ppb_font_measure_text(PP_Resource font, const struct PP_TextRun_Dev *text) { gchar *s_text = trace_var_as_string(text->text); trace_info("[PPB] {full} %s font=%d, text={.text=%s, .rtl=%u, .override_direction=%u}\n", __func__+6, font, s_text, text->rtl, text->override_direction); g_free(s_text); return ppb_font_measure_text(font, text); } TRACE_WRAPPER uint32_t trace_ppb_font_character_offset_for_pixel(PP_Resource font, const struct PP_TextRun_Dev *text, int32_t pixel_position) { gchar *s_text = trace_var_as_string(text->text); trace_info("[PPB] {zilch} %s font=%d, text={.text=%s, .rtl=%u, .override_direction=%u}, " "pixel_position=%d\n", __func__+6, font, s_text, text->rtl, text->override_direction, pixel_position); g_free(s_text); return ppb_font_character_offset_for_pixel(font, text, pixel_position); } TRACE_WRAPPER int32_t trace_ppb_font_pixel_offset_for_character(PP_Resource font, const struct PP_TextRun_Dev *text, uint32_t char_offset) { gchar *s_text = trace_var_as_string(text->text); trace_info("[PPB] {zilch} %s font=%d, text={.text=%s, .rtl=%u, .override_direction=%u}, " "char_offset=%u\n", __func__+6, font, s_text, text->rtl, text->override_direction, char_offset); g_free(s_text); return ppb_font_pixel_offset_for_character(font, text, char_offset); } const struct PPB_Font_Dev_0_6 ppb_font_dev_interface_0_6 = { .GetFontFamilies = TWRAPF(ppb_font_get_font_families), .Create = TWRAPF(ppb_font_create), .IsFont = TWRAPF(ppb_font_is_font), .Describe = TWRAPF(ppb_font_describe), .DrawTextAt = TWRAPF(ppb_font_draw_text_at), .MeasureText = TWRAPF(ppb_font_measure_text), .CharacterOffsetForPixel = TWRAPZ(ppb_font_character_offset_for_pixel), .PixelOffsetForCharacter = TWRAPZ(ppb_font_pixel_offset_for_character), }; static void __attribute__((constructor)) constructor_ppb_font(void) { register_interface(PPB_FONT_DEV_INTERFACE_0_6, &ppb_font_dev_interface_0_6); register_resource(PP_RESOURCE_FONT, ppb_font_destroy); } freshplayerplugin-0.3.9/src/ppb_font.h000066400000000000000000000043061321746453100200460ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include struct PP_Var ppb_font_get_font_families(PP_Instance instance); PP_Resource ppb_font_create(PP_Instance instance, const struct PP_FontDescription_Dev *description); PP_Bool ppb_font_is_font(PP_Resource resource); PP_Bool ppb_font_describe(PP_Resource font, struct PP_FontDescription_Dev *description, struct PP_FontMetrics_Dev *metrics); PP_Bool ppb_font_draw_text_at(PP_Resource font, PP_Resource image_data, const struct PP_TextRun_Dev *text, const struct PP_Point *position, uint32_t color, const struct PP_Rect *clip, PP_Bool image_data_is_opaque); int32_t ppb_font_measure_text(PP_Resource font, const struct PP_TextRun_Dev *text); uint32_t ppb_font_character_offset_for_pixel(PP_Resource font, const struct PP_TextRun_Dev *text, int32_t pixel_position); int32_t ppb_font_pixel_offset_for_character(PP_Resource font, const struct PP_TextRun_Dev *text, uint32_t char_offset); freshplayerplugin-0.3.9/src/ppb_graphics2d.c000066400000000000000000000426301321746453100211230ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "config.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_core.h" #include "ppb_graphics2d.h" #include "ppb_image_data.h" #include "ppb_instance.h" #include "ppb_message_loop.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include "utils.h" #include #include #include #include #include #include STATIC_ASSERT(sizeof(struct pp_graphics2d_s) <= LARGEST_RESOURCE_SIZE); struct g2d_paint_task_s { enum g2d_paint_task_type_e { gpt_paint_id, gpt_replace_contents, } type; PP_Resource image_data; struct PP_Point ofs; struct PP_Rect src; int src_is_set; }; PP_Resource ppb_graphics2d_create(PP_Instance instance, const struct PP_Size *size, PP_Bool is_always_opaque) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource graphics_2d = pp_resource_allocate(PP_RESOURCE_GRAPHICS2D, pp_i); struct pp_graphics2d_s *g2d = pp_resource_acquire(graphics_2d, PP_RESOURCE_GRAPHICS2D); if (!g2d) { trace_error("%s, can't create graphics2d resource\n", __func__); return 0; } g2d->is_always_opaque = is_always_opaque; g2d->scale = config.device_scale; g2d->external_scale = 1.0; g2d->width = size->width; g2d->height = size->height; g2d->stride = 4 * size->width; g2d->scaled_width = g2d->width * g2d->scale + 0.5; g2d->scaled_height = g2d->height * g2d->scale + 0.5; g2d->scaled_stride = 4 * g2d->scaled_width; g2d->data = calloc(g2d->stride * g2d->height, 1); g2d->second_buffer = calloc(g2d->scaled_stride * g2d->scaled_height, 1); if (!g2d->data || !g2d->second_buffer) { trace_warning("%s, can't allocate memory\n", __func__); free_and_nullify(g2d->data); free_and_nullify(g2d->second_buffer); pp_resource_release(graphics_2d); ppb_core_release_resource(graphics_2d); return 0; } g2d->cairo_surf = cairo_image_surface_create_for_data((unsigned char *)g2d->data, CAIRO_FORMAT_ARGB32, g2d->width, g2d->height, g2d->stride); g2d->task_list = NULL; if (pp_i->is_transparent && display.have_xrender) { // we need XRender picture (which in turn requires X Pixmap) to alpha blend // our images with existing pixmap provided by the browser. This is only needed // is instance is transparent, therefore depth is always 32-bit. pthread_mutex_lock(&display.lock); g2d->pixmap = XCreatePixmap(display.x, DefaultRootWindow(display.x), g2d->scaled_width, g2d->scaled_height, 32); XFlush(display.x); g2d->xr_pict = XRenderCreatePicture(display.x, g2d->pixmap, display.pictfmt_argb32, 0, 0); g2d->gc = XCreateGC(display.x, g2d->pixmap, 0, 0); XFlush(display.x); pthread_mutex_unlock(&display.lock); } // without XRender, fall back to software compositing pp_resource_release(graphics_2d); return graphics_2d; } static void ppb_graphics2d_destroy(void *p) { if (!p) return; struct pp_graphics2d_s *g2d = p; free_and_nullify(g2d->data); free_and_nullify(g2d->second_buffer); if (g2d->cairo_surf) { cairo_surface_destroy(g2d->cairo_surf); g2d->cairo_surf = NULL; } if (g2d->instance->is_transparent && display.have_xrender) { pthread_mutex_lock(&display.lock); XRenderFreePicture(display.x, g2d->xr_pict); XFreePixmap(display.x, g2d->pixmap); XFreeGC(display.x, g2d->gc); pthread_mutex_unlock(&display.lock); } } PP_Bool ppb_graphics2d_is_graphics2d(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_GRAPHICS2D; } PP_Bool ppb_graphics2d_describe(PP_Resource graphics_2d, struct PP_Size *size, PP_Bool *is_always_opaque) { return PP_TRUE; } void ppb_graphics2d_paint_image_data(PP_Resource graphics_2d, PP_Resource image_data, const struct PP_Point *top_left, const struct PP_Rect *src_rect) { struct pp_graphics2d_s *g2d = pp_resource_acquire(graphics_2d, PP_RESOURCE_GRAPHICS2D); if (!g2d) { trace_error("%s, bad resource\n", __func__); return; } struct g2d_paint_task_s *pt = g_slice_alloc(sizeof(*pt)); pt->type = gpt_paint_id; pp_resource_ref(image_data); pt->image_data = image_data; pt->src_is_set = !!src_rect; if (top_left) { memcpy(&pt->ofs, top_left, sizeof(*top_left)); } else { pt->ofs.x = pt->ofs.y = 0; } if (src_rect) memcpy(&pt->src, src_rect, sizeof(*src_rect)); g2d->task_list = g_list_append(g2d->task_list, pt); pp_resource_release(graphics_2d); } void ppb_graphics2d_scroll(PP_Resource graphics_2d, const struct PP_Rect *clip_rect, const struct PP_Point *amount) { } void ppb_graphics2d_replace_contents(PP_Resource graphics_2d, PP_Resource image_data) { struct pp_graphics2d_s *g2d = pp_resource_acquire(graphics_2d, PP_RESOURCE_GRAPHICS2D); if (!g2d) { trace_error("%s, bad resource\n", __func__); return; } struct g2d_paint_task_s *pt = g_slice_alloc(sizeof(*pt)); pt->type = gpt_replace_contents; pp_resource_ref(image_data); pt->image_data = image_data; g2d->task_list = g_list_append(g2d->task_list, pt); pp_resource_release(graphics_2d); } static void call_forceredraw_ptac(void *param) { struct pp_instance_s *pp_i = tables_get_pp_instance(GPOINTER_TO_SIZE(param)); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return; } if (pp_i->is_fullscreen || pp_i->windowed_mode) { XEvent ev = { .xgraphicsexpose = { .type = GraphicsExpose, .drawable = pp_i->is_fullscreen ? pp_i->fs_wnd : pp_i->wnd, .width = pp_i->is_fullscreen ? pp_i->fs_width : pp_i->width, .height = pp_i->is_fullscreen ? pp_i->fs_height : pp_i->height, } }; pthread_mutex_lock(&display.lock); XSendEvent(display.x, ev.xgraphicsexpose.drawable, True, ExposureMask, &ev); XFlush(display.x); pthread_mutex_unlock(&display.lock); } else { NPRect npr = {.top = 0, .left = 0, .bottom = pp_i->height, .right = pp_i->width}; npn.invalidaterect(pp_i->npp, &npr); npn.forceredraw(pp_i->npp); } } int32_t ppb_graphics2d_flush(PP_Resource graphics_2d, struct PP_CompletionCallback callback) { struct pp_graphics2d_s *g2d = pp_resource_acquire(graphics_2d, PP_RESOURCE_GRAPHICS2D); if (!g2d) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } struct pp_instance_s *pp_i = g2d->instance; pthread_mutex_lock(&display.lock); if (pp_i->graphics_in_progress) { pp_resource_release(graphics_2d); pthread_mutex_unlock(&display.lock); return PP_ERROR_INPROGRESS; } if (pp_i->graphics == graphics_2d) { pp_i->graphics_ccb = callback; pp_i->graphics_ccb_ml = ppb_message_loop_get_current(); pp_i->graphics_in_progress = 1; } pthread_mutex_unlock(&display.lock); while (g2d->task_list) { GList *link = g_list_first(g2d->task_list); struct g2d_paint_task_s *pt = link->data; struct pp_image_data_s *id; cairo_t *cr; g2d->task_list = g_list_delete_link(g2d->task_list, link); switch (pt->type) { case gpt_paint_id: id = pp_resource_acquire(pt->image_data, PP_RESOURCE_IMAGE_DATA); if (!id) break; cairo_surface_mark_dirty(g2d->cairo_surf); cr = cairo_create(g2d->cairo_surf); cairo_set_source_surface(cr, id->cairo_surf, pt->ofs.x, pt->ofs.y); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); if (pt->src_is_set) { cairo_rectangle(cr, pt->src.point.x + pt->ofs.x, pt->src.point.y + pt->ofs.y, pt->src.size.width, pt->src.size.height); cairo_fill(cr); } else { cairo_paint(cr); } cairo_surface_flush(g2d->cairo_surf); cairo_destroy(cr); pp_resource_release(pt->image_data); pp_resource_unref(pt->image_data); break; case gpt_replace_contents: id = pp_resource_acquire(pt->image_data, PP_RESOURCE_IMAGE_DATA); if (!id) break; if (id->width == g2d->width || id->height == g2d->height) { void *tmp; cairo_surface_t *tmp_surf; cairo_surface_flush(id->cairo_surf); cairo_surface_flush(g2d->cairo_surf); tmp = g2d->data; g2d->data = id->data; id->data = tmp; tmp_surf = g2d->cairo_surf; g2d->cairo_surf = id->cairo_surf; id->cairo_surf = tmp_surf; } pp_resource_release(pt->image_data); pp_resource_unref(pt->image_data); break; } g_slice_free(struct g2d_paint_task_s, pt); } // scale image if (g2d->scaled_width == g2d->width && g2d->scaled_height == g2d->height) { // fast path: exact copy memcpy(g2d->second_buffer, g2d->data, g2d->stride * g2d->height); } else { // slow path: scaling required cairo_surface_t *surf; surf = cairo_image_surface_create_for_data((unsigned char *)g2d->second_buffer, CAIRO_FORMAT_ARGB32, g2d->scaled_width, g2d->scaled_height, g2d->scaled_stride); cairo_t *cr = cairo_create(surf); cairo_scale(cr, g2d->scale, g2d->scale); cairo_set_source_surface(cr, g2d->cairo_surf, 0, 0); cairo_paint(cr); cairo_destroy(cr); cairo_surface_destroy(surf); } pp_resource_release(graphics_2d); ppb_core_call_on_browser_thread(pp_i->id, call_forceredraw_ptac, GSIZE_TO_POINTER(pp_i->id)); if (callback.func) { // invoke callback as soon as possible if graphics device is not bound to an instance if (pp_i->graphics != graphics_2d) ppb_message_loop_post_work_with_result(ppb_message_loop_get_current(), callback, 0, PP_OK, 0, __func__); return PP_OK_COMPLETIONPENDING; } trace_error("%s, callback.func==NULL branch not implemented\n", __func__); return PP_OK; } PP_Bool ppb_graphics2d_set_scale(PP_Resource resource, float scale) { struct pp_graphics2d_s *g2d = pp_resource_acquire(resource, PP_RESOURCE_GRAPHICS2D); if (!g2d) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } g2d->external_scale = scale; g2d->scale = scale * config.device_scale; g2d->scaled_width = g2d->width * g2d->scale + 0.5; g2d->scaled_height = g2d->height * g2d->scale + 0.5; g2d->scaled_stride = 4 * g2d->scaled_width; free(g2d->second_buffer); g2d->second_buffer = calloc(g2d->scaled_stride * g2d->scaled_height, 1); PP_Bool ret = !!g2d->second_buffer; pp_resource_release(resource); return ret; } float ppb_graphics2d_get_scale(PP_Resource resource) { struct pp_graphics2d_s *g2d = pp_resource_acquire(resource, PP_RESOURCE_GRAPHICS2D); if (!g2d) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } float scale = g2d->external_scale; pp_resource_release(resource); return scale; } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_graphics2d_create(PP_Instance instance, const struct PP_Size *size, PP_Bool is_always_opaque) { char *s_size = trace_size_as_string(size); trace_info("[PPB] {full} %s instance=%d, size=%s, is_always_opaque=%d\n", __func__+6, instance, s_size, is_always_opaque); g_free(s_size); return ppb_graphics2d_create(instance, size, is_always_opaque); } TRACE_WRAPPER PP_Bool trace_ppb_graphics2d_is_graphics2d(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_graphics2d_is_graphics2d(resource); } TRACE_WRAPPER PP_Bool trace_ppb_graphics2d_describe(PP_Resource graphics_2d, struct PP_Size *size, PP_Bool *is_always_opaque) { char *s_size = trace_size_as_string(size); trace_info("[PPB] {zilch} %s graphics_2d=%d, size=%s\n", __func__+6, graphics_2d, s_size); g_free(s_size); return ppb_graphics2d_describe(graphics_2d, size, is_always_opaque); } TRACE_WRAPPER void trace_ppb_graphics2d_paint_image_data(PP_Resource graphics_2d, PP_Resource image_data, const struct PP_Point *top_left, const struct PP_Rect *src_rect) { char *s_top_left = trace_point_as_string(top_left); char *s_src_rect = trace_rect_as_string(src_rect); trace_info("[PPB] {full} %s graphics_2d=%d, image_data=%d, top_left=%s, src_rect=%s\n", __func__+6, graphics_2d, image_data, s_top_left, s_src_rect); g_free(s_top_left); g_free(s_src_rect); ppb_graphics2d_paint_image_data(graphics_2d, image_data, top_left, src_rect); } TRACE_WRAPPER void trace_ppb_graphics2d_scroll(PP_Resource graphics_2d, const struct PP_Rect *clip_rect, const struct PP_Point *amount) { char *s_clip_rect = trace_rect_as_string(clip_rect); char *s_amount = trace_point_as_string(amount); trace_info("[PPB] {zilch} %s graphics_2d=%d, clip_rect=%s, amount=%s\n", __func__+6, graphics_2d, s_clip_rect, s_amount); g_free(s_clip_rect); g_free(s_amount); ppb_graphics2d_scroll(graphics_2d, clip_rect, amount); } TRACE_WRAPPER void trace_ppb_graphics2d_replace_contents(PP_Resource graphics_2d, PP_Resource image_data) { trace_info("[PPB] {full} %s graphics_2d=%d, image_data=%d\n", __func__+6, graphics_2d, image_data); ppb_graphics2d_replace_contents(graphics_2d, image_data); } TRACE_WRAPPER int32_t trace_ppb_graphics2d_flush(PP_Resource graphics_2d, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s graphics_2d=%d, callback={.func=%p, .user_data=%p, .flags=%d}\n", __func__+6, graphics_2d, callback.func, callback.user_data, callback.flags); return ppb_graphics2d_flush(graphics_2d, callback); } TRACE_WRAPPER PP_Bool trace_ppb_graphics2d_set_scale(PP_Resource resource, float scale) { trace_info("[PPB] {full} %s resource=%d, scale=%f\n", __func__+6, resource, scale); return ppb_graphics2d_set_scale(resource, scale); } TRACE_WRAPPER float trace_ppb_graphics2d_get_scale(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_graphics2d_get_scale(resource); } const struct PPB_Graphics2D_1_0 ppb_graphics2d_interface_1_0 = { .Create = TWRAPF(ppb_graphics2d_create), .IsGraphics2D = TWRAPF(ppb_graphics2d_is_graphics2d), .Describe = TWRAPZ(ppb_graphics2d_describe), .PaintImageData = TWRAPF(ppb_graphics2d_paint_image_data), .Scroll = TWRAPZ(ppb_graphics2d_scroll), .ReplaceContents = TWRAPF(ppb_graphics2d_replace_contents), .Flush = TWRAPF(ppb_graphics2d_flush), }; const struct PPB_Graphics2D_1_1 ppb_graphics2d_interface_1_1 = { .Create = TWRAPF(ppb_graphics2d_create), .IsGraphics2D = TWRAPF(ppb_graphics2d_is_graphics2d), .Describe = TWRAPZ(ppb_graphics2d_describe), .PaintImageData = TWRAPF(ppb_graphics2d_paint_image_data), .Scroll = TWRAPZ(ppb_graphics2d_scroll), .ReplaceContents = TWRAPF(ppb_graphics2d_replace_contents), .Flush = TWRAPF(ppb_graphics2d_flush), .SetScale = TWRAPF(ppb_graphics2d_set_scale), .GetScale = TWRAPF(ppb_graphics2d_get_scale), }; static void __attribute__((constructor)) constructor_ppb_graphics2d(void) { register_interface(PPB_GRAPHICS_2D_INTERFACE_1_0, &ppb_graphics2d_interface_1_0); register_interface(PPB_GRAPHICS_2D_INTERFACE_1_1, &ppb_graphics2d_interface_1_1); register_resource(PP_RESOURCE_GRAPHICS2D, ppb_graphics2d_destroy); } freshplayerplugin-0.3.9/src/ppb_graphics2d.h000066400000000000000000000054671321746453100211370ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include "pp_resource.h" #include #include #include #include #include struct pp_graphics2d_s { COMMON_STRUCTURE_FIELDS int is_always_opaque; int32_t width; int32_t height; int32_t stride; double scale; double external_scale; int32_t scaled_width; int32_t scaled_height; int32_t scaled_stride; char *data; char *second_buffer; cairo_surface_t *cairo_surf; GList *task_list; Pixmap pixmap; Picture xr_pict; GC gc; }; PP_Resource ppb_graphics2d_create(PP_Instance instance, const struct PP_Size *size, PP_Bool is_always_opaque); PP_Bool ppb_graphics2d_is_graphics2d(PP_Resource resource); PP_Bool ppb_graphics2d_describe(PP_Resource graphics_2d, struct PP_Size *size, PP_Bool *is_always_opaque); void ppb_graphics2d_paint_image_data(PP_Resource graphics_2d, PP_Resource image_data, const struct PP_Point *top_left, const struct PP_Rect *src_rect); void ppb_graphics2d_scroll(PP_Resource graphics_2d, const struct PP_Rect *clip_rect, const struct PP_Point *amount); void ppb_graphics2d_replace_contents(PP_Resource graphics_2d, PP_Resource image_data); int32_t ppb_graphics2d_flush(PP_Resource graphics_2d, struct PP_CompletionCallback callback); PP_Bool ppb_graphics2d_set_scale(PP_Resource resource, float scale); float ppb_graphics2d_get_scale(PP_Resource resource); freshplayerplugin-0.3.9/src/ppb_graphics3d.c000066400000000000000000000475621321746453100211350ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "compat_glx_defines.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_core.h" #include "ppb_graphics3d.h" #include "ppb_instance.h" #include "ppb_message_loop.h" #include "reverse_constant.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include #include #include #include #include #include #include STATIC_ASSERT(sizeof(struct pp_graphics3d_s) <= LARGEST_RESOURCE_SIZE); int32_t ppb_graphics3d_get_attrib_max_value(PP_Resource instance, int32_t attribute, int32_t *value) { return 0; } GLXContext peek_gl_context(PP_Resource graphics3d) { struct pp_graphics3d_s *g3d = pp_resource_acquire(graphics3d, PP_RESOURCE_GRAPHICS3D); if (!g3d) { trace_error("%s, bad resource\n", __func__); return NULL; } GLXContext glc = g3d->glc; pp_resource_release(graphics3d); return glc; } PP_Resource ppb_graphics3d_create(PP_Instance instance, PP_Resource share_context, const int32_t attrib_list[]) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } GLXContext share_glc = (share_context == 0) ? NULL : peek_gl_context(share_context); // check for required GLX extensions #if HAVE_GLES2 if (!display.glx_arb_create_context || !display.glx_arb_create_context_profile || !display.glx_ext_create_context_es2_profile) { trace_warning("%s, some of GLX_ARB_create_context, GLX_ARB_create_context_profile, " "GLX_EXT_create_context_es2_profile missing\n", __func__); return 0; } if (!display.glXCreateContextAttribsARB) { trace_warning("%s, no glXCreateContextAttribsARB found\n", __func__); return 0; } #endif PP_Resource context = pp_resource_allocate(PP_RESOURCE_GRAPHICS3D, pp_i); struct pp_graphics3d_s *g3d = pp_resource_acquire(context, PP_RESOURCE_GRAPHICS3D); if (!g3d) { trace_error("%s, can't create context\n", __func__); return 0; } int attrib_len = 0; while (attrib_list[attrib_len] != PP_GRAPHICS3DATTRIB_NONE) { attrib_len += 2; } attrib_len ++; const int max_attrib_count = attrib_len + 3 * 2; int *cfg_attrs = calloc(max_attrib_count, sizeof(int)); int k2 = 0; cfg_attrs[k2++] = GLX_X_RENDERABLE; cfg_attrs[k2++] = True; cfg_attrs[k2++] = GLX_DRAWABLE_TYPE; cfg_attrs[k2++] = GLX_WINDOW_BIT | GLX_PIXMAP_BIT; int done = 0; int k1 = 0; while (!done) { switch (attrib_list[k1]) { case PP_GRAPHICS3DATTRIB_HEIGHT: g3d->height = attrib_list[k1 + 1]; k1 += 2; break; case PP_GRAPHICS3DATTRIB_WIDTH: g3d->width = attrib_list[k1 + 1]; k1 += 2; break; case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE: case PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR: // TODO: save these values k1 += 2; break; case PP_GRAPHICS3DATTRIB_NONE: cfg_attrs[k2++] = None; done = 1; break; case PP_GRAPHICS3DATTRIB_ALPHA_SIZE: cfg_attrs[k2++] = GLX_ALPHA_SIZE; cfg_attrs[k2++] = attrib_list[k1 + 1]; k1 += 2; break; case PP_GRAPHICS3DATTRIB_BLUE_SIZE: cfg_attrs[k2++] = GLX_BLUE_SIZE; cfg_attrs[k2++] = attrib_list[k1 + 1]; k1 += 2; break; case PP_GRAPHICS3DATTRIB_GREEN_SIZE: cfg_attrs[k2++] = GLX_GREEN_SIZE; cfg_attrs[k2++] = attrib_list[k1 + 1]; k1 += 2; break; case PP_GRAPHICS3DATTRIB_RED_SIZE: cfg_attrs[k2++] = GLX_RED_SIZE; cfg_attrs[k2++] = attrib_list[k1 + 1]; k1 += 2; break; case PP_GRAPHICS3DATTRIB_DEPTH_SIZE: cfg_attrs[k2++] = GLX_DEPTH_SIZE; cfg_attrs[k2++] = attrib_list[k1 + 1]; k1 += 2; break; case PP_GRAPHICS3DATTRIB_STENCIL_SIZE: cfg_attrs[k2++] = GLX_STENCIL_SIZE; cfg_attrs[k2++] = attrib_list[k1 + 1]; k1 += 2; break; case PP_GRAPHICS3DATTRIB_SAMPLES: cfg_attrs[k2++] = GLX_SAMPLES; cfg_attrs[k2++] = attrib_list[k1 + 1]; k1 += 2; break; case PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS: cfg_attrs[k2++] = GLX_SAMPLE_BUFFERS; cfg_attrs[k2++] = attrib_list[k1 + 1]; k1 += 2; break; case GLX_Y_INVERTED_EXT: cfg_attrs[k2++] = GLX_Y_INVERTED_EXT; cfg_attrs[k2++] = attrib_list[k1 + 1]; k1 += 2; break; case GLX_BIND_TO_TEXTURE_RGBA_EXT: cfg_attrs[k2++] = GLX_BIND_TO_TEXTURE_RGBA_EXT; cfg_attrs[k2++] = attrib_list[k1 + 1]; k1 += 2; break; default: // skip unknown attribute trace_error("%s, unknown attribute 0x%x\n", __func__, attrib_list[k1]); k1 += 1; break; } } assert(k2 <= max_attrib_count); pthread_mutex_lock(&display.lock); int screen = DefaultScreen(display.x); int nconfigs = 0; GLXFBConfig *fb_cfgs = glXChooseFBConfig(display.x, screen, cfg_attrs, &nconfigs); free(cfg_attrs); if (!fb_cfgs) { trace_error("%s, glXChooseFBConfig returned NULL\n", __func__); goto err; } trace_info_f("%s, glXChooseFBConfig returned %d configs, choosing first one\n", __func__, nconfigs); g3d->fb_config = fb_cfgs[0]; XFree(fb_cfgs); #if HAVE_GLES2 // create context implementing OpenGL ES 2.0 const int ctx_attrs[] = { GLX_RENDER_TYPE, GLX_RGBA_TYPE, GLX_CONTEXT_MAJOR_VERSION_ARB, 2, GLX_CONTEXT_MINOR_VERSION_ARB, 0, GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_ES2_PROFILE_BIT_EXT, None, }; #else // create context implementing OpenGL 2.0 // OpenGL ES 2.0 will be emulated with help of shader translator const int ctx_attrs[] = { GLX_RENDER_TYPE, GLX_RGBA_TYPE, GLX_CONTEXT_MAJOR_VERSION_ARB, 2, GLX_CONTEXT_MINOR_VERSION_ARB, 0, None, }; #endif if (display.glXCreateContextAttribsARB) { g3d->glc = display.glXCreateContextAttribsARB(display.x, g3d->fb_config, share_glc, True, ctx_attrs); if (!g3d->glc) trace_warning("%s, glXCreateContextAttribsARB returned NULL\n", __func__); } else { g3d->glc = NULL; } if (!g3d->glc) { // if glXCreateContextAttribsARB is not present or returned NULL, // request any GL context g3d->glc = glXCreateNewContext(display.x, g3d->fb_config, GLX_RGBA_TYPE, share_glc, True); if (!g3d->glc) { trace_error("%s, glXCreateNewContext returned NULL\n", __func__); goto err; } } g3d->depth = pp_i->is_transparent ? 32 : DefaultDepth(display.x, screen); switch (g3d->depth) { case 24: g3d->xr_pictfmt = display.pictfmt_rgb24; break; case 32: g3d->xr_pictfmt = display.pictfmt_argb32; break; default: trace_error("%s, unsupported g3d->depth (%d)\n", __func__, g3d->depth); goto err; } // Creating two X pixmaps. First one is for drawing into, with a GLX Pixmap associated. // Second one is for double buffering. g3d->pixmap[0] = XCreatePixmap(display.x, DefaultRootWindow(display.x), g3d->width, g3d->height, g3d->depth); g3d->pixmap[1] = XCreatePixmap(display.x, DefaultRootWindow(display.x), g3d->width, g3d->height, g3d->depth); g3d->glx_pixmap = glXCreatePixmap(display.x, g3d->fb_config, g3d->pixmap[0], NULL); if (g3d->glx_pixmap == None) { trace_error("%s, failed to create GLX pixmap\n", __func__); goto err; } XFlush(display.x); if (display.have_xrender) { g3d->xr_pict[0] = XRenderCreatePicture(display.x, g3d->pixmap[0], g3d->xr_pictfmt, 0, 0); g3d->xr_pict[1] = XRenderCreatePicture(display.x, g3d->pixmap[1], g3d->xr_pictfmt, 0, 0); } int ret = glXMakeCurrent(display.x, g3d->glx_pixmap, g3d->glc); if (!ret) { trace_error("%s, glXMakeCurrent failed\n", __func__); goto err; } // clear surface glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); glXMakeCurrent(display.x, None, NULL); g3d->sub_maps = g_hash_table_new(g_direct_hash, g_direct_equal); pthread_mutex_unlock(&display.lock); pp_resource_release(context); return context; err: pthread_mutex_unlock(&display.lock); pp_resource_release(context); pp_resource_expunge(context); return 0; } static void ppb_graphics3d_destroy(void *p) { struct pp_graphics3d_s *g3d = p; g_hash_table_destroy(g3d->sub_maps); pthread_mutex_lock(&display.lock); // bringing context to current thread releases it from any others glXMakeCurrent(display.x, g3d->glx_pixmap, g3d->glc); // free it here, to be able to destroy X Pixmap glXMakeCurrent(display.x, None, NULL); glXDestroyPixmap(display.x, g3d->glx_pixmap); if (display.have_xrender) { XRenderFreePicture(display.x, g3d->xr_pict[0]); XRenderFreePicture(display.x, g3d->xr_pict[1]); } XFreePixmap(display.x, g3d->pixmap[0]); XFreePixmap(display.x, g3d->pixmap[1]); glXDestroyContext(display.x, g3d->glc); pthread_mutex_unlock(&display.lock); } PP_Bool ppb_graphics3d_is_graphics3d(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_GRAPHICS3D; } int32_t ppb_graphics3d_get_attribs(PP_Resource context, int32_t attrib_list[]) { return 0; } int32_t ppb_graphics3d_set_attribs(PP_Resource context, const int32_t attrib_list[]) { return 0; } int32_t ppb_graphics3d_get_error(PP_Resource context) { return 0; } int32_t ppb_graphics3d_resize_buffers(PP_Resource context, int32_t width, int32_t height) { if (width < 0 || height < 0) { trace_error("%s, width or height are negative\n", __func__); return PP_ERROR_BADARGUMENT; } struct pp_graphics3d_s *g3d = pp_resource_acquire(context, PP_RESOURCE_GRAPHICS3D); if (!g3d) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } g3d->width = width; g3d->height = height; GLXPixmap old_glx_pixmap = g3d->glx_pixmap; Pixmap old_pixmap[2] = { g3d->pixmap[0], g3d->pixmap[1] }; Picture old_pict[2] = { g3d->xr_pict[0], g3d->xr_pict[1] }; // release possibly bound to other thread g3d->glx_pixmap and bind it to the current one pthread_mutex_lock(&display.lock); glXMakeCurrent(display.x, g3d->glx_pixmap, g3d->glc); g3d->pixmap[0] = XCreatePixmap(display.x, DefaultRootWindow(display.x), g3d->width, g3d->height, g3d->depth); g3d->pixmap[1] = XCreatePixmap(display.x, DefaultRootWindow(display.x), g3d->width, g3d->height, g3d->depth); g3d->glx_pixmap = glXCreatePixmap(display.x, g3d->fb_config, g3d->pixmap[0], NULL); XFlush(display.x); if (display.have_xrender) { g3d->xr_pict[0] = XRenderCreatePicture(display.x, g3d->pixmap[0], g3d->xr_pictfmt, 0, 0); g3d->xr_pict[1] = XRenderCreatePicture(display.x, g3d->pixmap[1], g3d->xr_pictfmt, 0, 0); } // make new g3d->glx_pixmap current to the current thread to allow releasing old_glx_pixmap glXMakeCurrent(display.x, g3d->glx_pixmap, g3d->glc); // clear surface glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); // destroy previous glx and x pixmaps glXDestroyPixmap(display.x, old_glx_pixmap); if (display.have_xrender) { XRenderFreePicture(display.x, old_pict[0]); XRenderFreePicture(display.x, old_pict[1]); } XFreePixmap(display.x, old_pixmap[0]); XFreePixmap(display.x, old_pixmap[1]); pthread_mutex_unlock(&display.lock); pp_resource_release(context); return PP_OK; } static void call_forceredraw_ptac(void *param) { struct pp_instance_s *pp_i = tables_get_pp_instance(GPOINTER_TO_SIZE(param)); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return; } pthread_mutex_lock(&display.lock); if (pp_i->is_fullscreen || pp_i->windowed_mode) { XEvent ev = { .xgraphicsexpose = { .type = GraphicsExpose, .drawable = pp_i->is_fullscreen ? pp_i->fs_wnd : pp_i->wnd, .width = pp_i->is_fullscreen ? pp_i->fs_width : pp_i->width, .height = pp_i->is_fullscreen ? pp_i->fs_height : pp_i->height, } }; XSendEvent(display.x, ev.xgraphicsexpose.drawable, True, ExposureMask, &ev); XFlush(display.x); pthread_mutex_unlock(&display.lock); } else { pthread_mutex_unlock(&display.lock); NPRect npr = {.top = 0, .left = 0, .bottom = pp_i->height, .right = pp_i->width}; npn.invalidaterect(pp_i->npp, &npr); npn.forceredraw(pp_i->npp); } } int32_t ppb_graphics3d_swap_buffers(PP_Resource context, struct PP_CompletionCallback callback) { struct pp_graphics3d_s *g3d = pp_resource_acquire(context, PP_RESOURCE_GRAPHICS3D); if (!g3d) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } struct pp_instance_s *pp_i = g3d->instance; pthread_mutex_lock(&display.lock); if (pp_i->graphics != context) { // Other context bound, do nothing. pp_resource_release(context); pthread_mutex_unlock(&display.lock); return PP_ERROR_FAILED; } if (pp_i->graphics_in_progress) { pp_resource_release(context); pthread_mutex_unlock(&display.lock); return PP_ERROR_INPROGRESS; } glXMakeCurrent(display.x, g3d->glx_pixmap, g3d->glc); glFinish(); // ensure painting is done glXMakeCurrent(display.x, None, NULL); // a round-trip to an X server is required here to be sure that drawing is completed XSync(display.x, False); // copy from pixmap[0] to pixmap[1] if (display.have_xrender) { XRenderComposite(display.x, PictOpSrc, g3d->xr_pict[0], None, g3d->xr_pict[1], 0, 0, 0, 0, 0, 0, g3d->width, g3d->height); } else { const int screen = DefaultScreen(display.x); const GC gc = DefaultGC(display.x, screen); XCopyArea(display.x, g3d->pixmap[0], g3d->pixmap[1], gc, 0, 0, g3d->width, g3d->height, 0, 0); } // a round-trip to an X server is required here to ensure that copying is completed, and further // GL drawing in this thread into pixmap[0] will not affect pixmap[1] which will be used in // another, browser thread XSync(display.x, False); pp_resource_release(context); pp_i->graphics_ccb = callback; pp_i->graphics_ccb_ml = ppb_message_loop_get_current(); pp_i->graphics_in_progress = 1; pthread_mutex_unlock(&display.lock); ppb_core_call_on_browser_thread(pp_i->id, call_forceredraw_ptac, GSIZE_TO_POINTER(pp_i->id)); if (callback.func) return PP_OK_COMPLETIONPENDING; trace_error("%s, callback.func==NULL branch not implemented\n", __func__); return PP_OK; } // trace wrappers TRACE_WRAPPER int32_t trace_ppb_graphics3d_get_attrib_max_value(PP_Resource instance, int32_t attribute, int32_t *value) { trace_info("[PPB] {zilch} %s instance=%d, attribute=%s(0x%04x)\n", __func__+6, instance, reverse_graphics3d_attribute(attribute), attribute); return ppb_graphics3d_get_attrib_max_value(instance, attribute, value); } TRACE_WRAPPER PP_Resource trace_ppb_graphics3d_create(PP_Instance instance, PP_Resource share_context, const int32_t attrib_list[]) { gchar *s_attrib_list = trace_graphics3d_attributes_as_string(attrib_list); trace_info("[PPB] {full} %s intance=%d, share_context=%d, attrib_list=%s\n", __func__+6, instance, share_context, s_attrib_list); g_free(s_attrib_list); return ppb_graphics3d_create(instance, share_context, attrib_list); } TRACE_WRAPPER PP_Bool trace_ppb_graphics3d_is_graphics3d(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_graphics3d_is_graphics3d(resource); } TRACE_WRAPPER int32_t trace_ppb_graphics3d_get_attribs(PP_Resource context, int32_t attrib_list[]) { trace_info("[PPB] {zilch} %s context=%d\n", __func__+6, context); return ppb_graphics3d_get_attribs(context, attrib_list); } TRACE_WRAPPER int32_t trace_ppb_graphics3d_set_attribs(PP_Resource context, const int32_t attrib_list[]) { gchar *s_attrib_list = trace_graphics3d_attributes_as_string(attrib_list); trace_info("[PPB] {zilch} %s context=%d, attrib_list=%s\n", __func__+6, context, s_attrib_list); g_free(s_attrib_list); return ppb_graphics3d_set_attribs(context, attrib_list); } TRACE_WRAPPER int32_t trace_ppb_graphics3d_get_error(PP_Resource context) { trace_info("[PPB] {zilch} %s context=%d\n", __func__+6, context); return ppb_graphics3d_get_error(context); } TRACE_WRAPPER int32_t trace_ppb_graphics3d_resize_buffers(PP_Resource context, int32_t width, int32_t height) { trace_info("[PPB] {full} %s context=%d, width=%d, height=%d\n", __func__+6, context, width, height); return ppb_graphics3d_resize_buffers(context, width, height); } TRACE_WRAPPER int32_t trace_ppb_graphics3d_swap_buffers(PP_Resource context, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s context=%d, callback={.func=%p, .user_data=%p, .flags=%d}\n", __func__+6, context, callback.func, callback.user_data, callback.flags); return ppb_graphics3d_swap_buffers(context, callback); } const struct PPB_Graphics3D_1_0 ppb_graphics3d_interface_1_0 = { .GetAttribMaxValue = TWRAPZ(ppb_graphics3d_get_attrib_max_value), .Create = TWRAPF(ppb_graphics3d_create), .IsGraphics3D = TWRAPF(ppb_graphics3d_is_graphics3d), .GetAttribs = TWRAPZ(ppb_graphics3d_get_attribs), .SetAttribs = TWRAPZ(ppb_graphics3d_set_attribs), .GetError = TWRAPZ(ppb_graphics3d_get_error), .ResizeBuffers = TWRAPF(ppb_graphics3d_resize_buffers), .SwapBuffers = TWRAPF(ppb_graphics3d_swap_buffers), }; static void __attribute__((constructor)) constructor_ppb_graphics3d(void) { register_interface(PPB_GRAPHICS_3D_INTERFACE_1_0, &ppb_graphics3d_interface_1_0); register_resource(PP_RESOURCE_GRAPHICS3D, ppb_graphics3d_destroy); } freshplayerplugin-0.3.9/src/ppb_graphics3d.h000066400000000000000000000050431321746453100211260ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include "glx.h" #include "pp_resource.h" #include #include #include #include struct pp_graphics3d_s { COMMON_STRUCTURE_FIELDS GLXContext glc; GLXFBConfig fb_config; int32_t depth; ///< depth of the pixmap, 32 for transparent, 24 otherwise GLXPixmap glx_pixmap; Pixmap pixmap[2]; ///< first for immediate drawing, second - to store copy Picture xr_pict[2]; ///< XRender pictures for X pixmaps XRenderPictFormat *xr_pictfmt; int32_t width; int32_t height; GHashTable *sub_maps; }; int32_t ppb_graphics3d_get_attrib_max_value(PP_Resource instance, int32_t attribute, int32_t *value); PP_Resource ppb_graphics3d_create(PP_Instance instance, PP_Resource share_context, const int32_t attrib_list[]); PP_Bool ppb_graphics3d_is_graphics3d(PP_Resource resource); int32_t ppb_graphics3d_get_attribs(PP_Resource context, int32_t attrib_list[]); int32_t ppb_graphics3d_set_attribs(PP_Resource context, const int32_t attrib_list[]); int32_t ppb_graphics3d_get_error(PP_Resource context); int32_t ppb_graphics3d_resize_buffers(PP_Resource context, int32_t width, int32_t height); int32_t ppb_graphics3d_swap_buffers(PP_Resource context, struct PP_CompletionCallback callback); freshplayerplugin-0.3.9/src/ppb_host_resolver.c000066400000000000000000000240331321746453100217700ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "async_network.h" #include "pp_interface.h" #include "ppb_host_resolver.h" #include "ppb_message_loop.h" #include "ppb_net_address.h" #include "ppb_var.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "utils.h" #include #include #include STATIC_ASSERT(sizeof(struct pp_host_resolver_s) <= LARGEST_RESOURCE_SIZE); PP_Resource ppb_host_resolver_create(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource host_resolver = pp_resource_allocate(PP_RESOURCE_HOST_RESOLVER, pp_i); return host_resolver; } static void ppb_host_resolver_destroy(void *ptr) { struct pp_host_resolver_s *hr = ptr; free_and_nullify(hr->addrs); } PP_Bool ppb_host_resolver_is_host_resolver(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_HOST_RESOLVER; } int32_t ppb_host_resolver_resolve(PP_Resource host_resolver, const char *host, uint16_t port, const struct PP_HostResolver_Private_Hint *hint, struct PP_CompletionCallback callback) { struct pp_host_resolver_s *hr = pp_resource_acquire(host_resolver, PP_RESOURCE_HOST_RESOLVER); if (!hr) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } hr->host = nullsafe_strdup(host); struct async_network_task_s *task = async_network_task_create(); task->type = ASYNC_NETWORK_HOST_RESOLVE; task->resource = host_resolver; task->host = nullsafe_strdup(host); task->port = port; task->callback = callback; task->callback_ml = ppb_message_loop_get_current(); pp_resource_release(host_resolver); async_network_task_push(task); return PP_OK_COMPLETIONPENDING; } int32_t ppb_host_resolver_resolve_1_0(PP_Resource host_resolver, const char *host, uint16_t port, const struct PP_HostResolver_Hint *hint, struct PP_CompletionCallback callback) { // TODO: use 'hint' somehow? return ppb_host_resolver_resolve(host_resolver, host, port, NULL, callback); } struct PP_Var ppb_host_resolver_get_canonical_name(PP_Resource host_resolver) { // TODO: implement struct pp_host_resolver_s *hr = pp_resource_acquire(host_resolver, PP_RESOURCE_HOST_RESOLVER); if (!hr) { trace_error("%s, bad resource\n", __func__); return PP_MakeUndefined(); } struct PP_Var var = ppb_var_var_from_utf8_z(hr->host); pp_resource_release(host_resolver); return var; } uint32_t ppb_host_resolver_get_size(PP_Resource host_resolver) { struct pp_host_resolver_s *hr = pp_resource_acquire(host_resolver, PP_RESOURCE_HOST_RESOLVER); if (!hr) { trace_error("%s, bad resource\n", __func__); return 0; } uint32_t count = hr->addr_count; pp_resource_release(host_resolver); return count; } uint32_t ppb_host_resolver_get_net_address_count(PP_Resource host_resolver) { return ppb_host_resolver_get_size(host_resolver); } PP_Bool ppb_host_resolver_get_net_address(PP_Resource host_resolver, uint32_t index, struct PP_NetAddress_Private *addr) { struct pp_host_resolver_s *hr = pp_resource_acquire(host_resolver, PP_RESOURCE_HOST_RESOLVER); if (!hr) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } if (index >= hr->addr_count) { pp_resource_release(host_resolver); return PP_FALSE; } memcpy(addr, &hr->addrs[index], sizeof(struct PP_NetAddress_Private)); pp_resource_release(host_resolver); return PP_TRUE; } PP_Resource ppb_host_resolver_get_net_address_1_0(PP_Resource host_resolver, uint32_t index) { PP_Resource net_address = 0; struct pp_host_resolver_s *hr = pp_resource_acquire(host_resolver, PP_RESOURCE_HOST_RESOLVER); if (!hr) { trace_error("%s, bad resource\n", __func__); goto err_1; } if (index >= hr->addr_count) goto err_2; net_address = pp_resource_allocate(PP_RESOURCE_NET_ADDRESS, hr->instance); struct pp_net_address_s *na = pp_resource_acquire(net_address, PP_RESOURCE_NET_ADDRESS); if (!na) { trace_error("%s, resource allocation failed\n", __func__); goto err_2; } memcpy(&na->addr, &hr->addrs[index], sizeof(struct PP_NetAddress_Private)); pp_resource_release(net_address); err_2: pp_resource_release(host_resolver); err_1: return net_address; } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_host_resolver_create(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_host_resolver_create(instance); } TRACE_WRAPPER PP_Bool trace_ppb_host_resolver_is_host_resolver(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_host_resolver_is_host_resolver(resource); } TRACE_WRAPPER int32_t trace_ppb_host_resolver_resolve(PP_Resource host_resolver, const char *host, uint16_t port, const struct PP_HostResolver_Private_Hint *hint, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s host_resolver=%d, host=%s, port=%u, hint=%p, callback={.func=%p, " ".user_data=%p, .flags=%u}\n", __func__+6, host_resolver, host, (unsigned int)port, hint, callback.func, callback.user_data, callback.flags); return ppb_host_resolver_resolve(host_resolver, host, port, hint, callback); } TRACE_WRAPPER int32_t trace_ppb_host_resolver_resolve_1_0(PP_Resource host_resolver, const char *host, uint16_t port, const struct PP_HostResolver_Hint *hint, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s host_resolver=%d, host=%s, port=%u, hint=%p, callback={.func=%p, " ".user_data=%p, .flags=%u}\n", __func__+6, host_resolver, host, (unsigned int)port, hint, callback.func, callback.user_data, callback.flags); return ppb_host_resolver_resolve_1_0(host_resolver, host, port, hint, callback); } TRACE_WRAPPER struct PP_Var trace_ppb_host_resolver_get_canonical_name(PP_Resource host_resolver) { trace_info("[PPB] {zilch} %s host_resolver=%d\n", __func__+6, host_resolver); return ppb_host_resolver_get_canonical_name(host_resolver); } TRACE_WRAPPER uint32_t trace_ppb_host_resolver_get_size(PP_Resource host_resolver) { trace_info("[PPB] {full} %s host_resolver=%d\n", __func__+6, host_resolver); return ppb_host_resolver_get_size(host_resolver); } TRACE_WRAPPER uint32_t trace_ppb_host_resolver_get_net_address_count(PP_Resource host_resolver) { trace_info("[PPB] {full} %s host_resolver=%d\n", __func__+6, host_resolver); return ppb_host_resolver_get_net_address_count(host_resolver); } TRACE_WRAPPER PP_Bool trace_ppb_host_resolver_get_net_address(PP_Resource host_resolver, uint32_t index, struct PP_NetAddress_Private *addr) { trace_info("[PPB] {full} %s host_resolver=%d, index=%u\n", __func__+6, host_resolver, index); return ppb_host_resolver_get_net_address(host_resolver, index, addr); } TRACE_WRAPPER PP_Resource trace_ppb_host_resolver_get_net_address_1_0(PP_Resource host_resolver, uint32_t index) { trace_info("[PPB] {full} %s host_resolver=%d, index=%u\n", __func__+6, host_resolver, index); return ppb_host_resolver_get_net_address_1_0(host_resolver, index); } const struct PPB_HostResolver_Private_0_1 ppb_host_resolver_private_interface_0_1 = { .Create = TWRAPF(ppb_host_resolver_create), .IsHostResolver = TWRAPF(ppb_host_resolver_is_host_resolver), .Resolve = TWRAPF(ppb_host_resolver_resolve), .GetCanonicalName = TWRAPZ(ppb_host_resolver_get_canonical_name), .GetSize = TWRAPF(ppb_host_resolver_get_size), .GetNetAddress = TWRAPF(ppb_host_resolver_get_net_address), }; const struct PPB_HostResolver_1_0 ppb_host_resolver_interface_1_0 = { .Create = TWRAPF(ppb_host_resolver_create), .IsHostResolver = TWRAPF(ppb_host_resolver_is_host_resolver), .Resolve = TWRAPF(ppb_host_resolver_resolve_1_0), .GetCanonicalName = TWRAPZ(ppb_host_resolver_get_canonical_name), .GetNetAddressCount = TWRAPF(ppb_host_resolver_get_net_address_count), .GetNetAddress = TWRAPF(ppb_host_resolver_get_net_address_1_0), }; static void __attribute__((constructor)) constructor_ppb_host_resolver(void) { register_interface(PPB_HOSTRESOLVER_PRIVATE_INTERFACE_0_1, &ppb_host_resolver_private_interface_0_1); register_interface(PPB_HOSTRESOLVER_INTERFACE_1_0, &ppb_host_resolver_interface_1_0); register_resource(PP_RESOURCE_HOST_RESOLVER, ppb_host_resolver_destroy); } freshplayerplugin-0.3.9/src/ppb_host_resolver.h000066400000000000000000000050211321746453100217710ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include "pp_resource.h" #include #include struct pp_host_resolver_s { COMMON_STRUCTURE_FIELDS char *host; struct PP_NetAddress_Private *addrs; uint32_t addr_count; }; PP_Resource ppb_host_resolver_create(PP_Instance instance); PP_Bool ppb_host_resolver_is_host_resolver(PP_Resource resource); int32_t ppb_host_resolver_resolve(PP_Resource host_resolver, const char *host, uint16_t port, const struct PP_HostResolver_Private_Hint *hint, struct PP_CompletionCallback callback); int32_t ppb_host_resolver_resolve_1_0(PP_Resource host_resolver, const char *host, uint16_t port, const struct PP_HostResolver_Hint *hint, struct PP_CompletionCallback callback); struct PP_Var ppb_host_resolver_get_canonical_name(PP_Resource host_resolver); uint32_t ppb_host_resolver_get_size(PP_Resource host_resolver); uint32_t ppb_host_resolver_get_net_address_count(PP_Resource host_resolver); PP_Bool ppb_host_resolver_get_net_address(PP_Resource host_resolver, uint32_t index, struct PP_NetAddress_Private *addr); PP_Resource ppb_host_resolver_get_net_address_1_0(PP_Resource host_resolver, uint32_t index); freshplayerplugin-0.3.9/src/ppb_image_data.c000066400000000000000000000163421321746453100211510ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "pp_resource.h" #include "ppb_core.h" #include "ppb_image_data.h" #include "reverse_constant.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include "utils.h" #include #include #include STATIC_ASSERT(sizeof(struct pp_image_data_s) <= LARGEST_RESOURCE_SIZE); PP_ImageDataFormat ppb_image_data_get_native_image_data_format(void) { return PP_IMAGEDATAFORMAT_BGRA_PREMUL; } PP_Bool ppb_image_data_is_image_data_format_supported(PP_ImageDataFormat format) { switch (format) { case PP_IMAGEDATAFORMAT_BGRA_PREMUL: return PP_TRUE; case PP_IMAGEDATAFORMAT_RGBA_PREMUL: return PP_TRUE; default: return PP_FALSE; } } PP_Resource ppb_image_data_create(PP_Instance instance, PP_ImageDataFormat format, const struct PP_Size *size, PP_Bool init_to_zero) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource image_data = pp_resource_allocate(PP_RESOURCE_IMAGE_DATA, pp_i); struct pp_image_data_s *id = pp_resource_acquire(image_data, PP_RESOURCE_IMAGE_DATA); if (!id) { trace_error("%s, failed to create image data resource\n", __func__); return 0; } id->format = format; id->width = size->width; id->height = size->height; id->stride = id->width * 4; (void)init_to_zero; // ignore flag, always clear memory id->data = calloc(id->stride * id->height, 1); if (!id->data) { pp_resource_release(image_data); ppb_core_release_resource(image_data); trace_error("%s, can't allocate memory for image\n", __func__); return 0; } id->cairo_surf = cairo_image_surface_create_for_data((void *)id->data, CAIRO_FORMAT_ARGB32, id->width, id->height, id->stride); pp_resource_release(image_data); return image_data; } static void ppb_image_data_destroy(void *p) { if (!p) return; struct pp_image_data_s *id = p; if (id->cairo_surf) { cairo_surface_destroy(id->cairo_surf); id->cairo_surf = NULL; } free_and_nullify(id->data); } PP_Bool ppb_image_data_is_image_data(PP_Resource image_data) { return pp_resource_get_type(image_data) == PP_RESOURCE_IMAGE_DATA; } PP_Bool ppb_image_data_describe(PP_Resource image_data, struct PP_ImageDataDesc *desc) { struct pp_image_data_s *id = pp_resource_acquire(image_data, PP_RESOURCE_IMAGE_DATA); if (!id) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } desc->format = id->format; desc->size.width = id->width; desc->size.height = id->height; desc->stride = id->stride; pp_resource_release(image_data); return PP_TRUE; } void * ppb_image_data_map(PP_Resource image_data) { void *data_ptr; struct pp_image_data_s *id = pp_resource_acquire(image_data, PP_RESOURCE_IMAGE_DATA); if (!id) { trace_error("%s, bad resource\n", __func__); return NULL; } data_ptr = id->data; pp_resource_release(image_data); return data_ptr; } void ppb_image_data_unmap(PP_Resource image_data) { struct pp_image_data_s *id = pp_resource_acquire(image_data, PP_RESOURCE_IMAGE_DATA); if (!id) { trace_error("%s, bad resource\n", __func__); return; } pp_resource_release(image_data); } // trace wrappers TRACE_WRAPPER PP_ImageDataFormat trace_ppb_image_data_get_native_image_data_format(void) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_image_data_get_native_image_data_format(); } TRACE_WRAPPER PP_Bool trace_ppb_image_data_is_image_data_format_supported(PP_ImageDataFormat format) { trace_info("[PPB] {full} %s format=%s\n", __func__+6, reverse_pp_image_data_format(format)); return ppb_image_data_is_image_data_format_supported(format); } TRACE_WRAPPER PP_Resource trace_ppb_image_data_create(PP_Instance instance, PP_ImageDataFormat format, const struct PP_Size *size, PP_Bool init_to_zero) { char *s_size = trace_size_as_string(size); trace_info("[PPB] {full} %s instance=%d, format=%s, size=%s, init_to_zero=%d\n", __func__+6, instance, reverse_pp_image_data_format(format), s_size, init_to_zero); g_free(s_size); return ppb_image_data_create(instance, format, size, init_to_zero); } TRACE_WRAPPER PP_Bool trace_ppb_image_data_is_image_data(PP_Resource image_data) { trace_info("[PPB] {full} %s image_data=%d\n", __func__+6, image_data); return ppb_image_data_is_image_data(image_data); } TRACE_WRAPPER PP_Bool trace_ppb_image_data_describe(PP_Resource image_data, struct PP_ImageDataDesc *desc) { trace_info("[PPB] {full} %s image_data=%d, desc=%p\n", __func__+6, image_data, desc); return ppb_image_data_describe(image_data, desc); } TRACE_WRAPPER void * trace_ppb_image_data_map(PP_Resource image_data) { trace_info("[PPB] {full} %s image_data=%d\n", __func__+6, image_data); return ppb_image_data_map(image_data); } TRACE_WRAPPER void trace_ppb_image_data_unmap(PP_Resource image_data) { trace_info("[PPB] {full} %s image_data=%d\n", __func__+6, image_data); ppb_image_data_unmap(image_data); } const struct PPB_ImageData_1_0 ppb_image_data_interface_1_0 = { .GetNativeImageDataFormat = TWRAPF(ppb_image_data_get_native_image_data_format), .IsImageDataFormatSupported = TWRAPF(ppb_image_data_is_image_data_format_supported), .Create = TWRAPF(ppb_image_data_create), .IsImageData = TWRAPF(ppb_image_data_is_image_data), .Describe = TWRAPF(ppb_image_data_describe), .Map = TWRAPF(ppb_image_data_map), .Unmap = TWRAPF(ppb_image_data_unmap), }; static void __attribute__((constructor)) constructor_ppb_image_data(void) { register_interface(PPB_IMAGEDATA_INTERFACE_1_0, &ppb_image_data_interface_1_0); register_resource(PP_RESOURCE_IMAGE_DATA, ppb_image_data_destroy); } freshplayerplugin-0.3.9/src/ppb_image_data.h000066400000000000000000000040431321746453100211510ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include "pp_resource.h" #include #include struct pp_image_data_s { COMMON_STRUCTURE_FIELDS int32_t width; int32_t height; int32_t stride; char *data; PP_ImageDataFormat format; cairo_surface_t *cairo_surf; }; PP_ImageDataFormat ppb_image_data_get_native_image_data_format(void); PP_Bool ppb_image_data_is_image_data_format_supported(PP_ImageDataFormat format); PP_Resource ppb_image_data_create(PP_Instance instance, PP_ImageDataFormat format, const struct PP_Size *size, PP_Bool init_to_zero); PP_Bool ppb_image_data_is_image_data(PP_Resource image_data); PP_Bool ppb_image_data_describe(PP_Resource image_data, struct PP_ImageDataDesc *desc); void * ppb_image_data_map(PP_Resource image_data); void ppb_image_data_unmap(PP_Resource image_data); freshplayerplugin-0.3.9/src/ppb_input_event.c000066400000000000000000001171161321746453100214370ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "pp_resource.h" #include "ppb_input_event.h" #include "ppb_instance.h" #include "ppb_var.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include "utils.h" #include #include #include #include #include struct pp_input_event_s { COMMON_STRUCTURE_FIELDS uint32_t event_class; PP_InputEvent_Type type; PP_TimeTicks time_stamp; uint32_t modifiers; PP_InputEvent_MouseButton mouse_button; struct PP_Point mouse_position; int32_t click_count; struct PP_Point mouse_movement; struct PP_FloatPoint wheel_delta; struct PP_FloatPoint wheel_ticks; PP_Bool scroll_by_page; uint32_t key_code; struct PP_Var code; struct PP_Var text; uint32_t segment_number; uint32_t *segment_offsets; int32_t target_segment; uint32_t selection_start; uint32_t selection_end; }; STATIC_ASSERT(sizeof(struct pp_input_event_s) <= LARGEST_RESOURCE_SIZE); static void ppb_input_event_destroy(void *p) { struct pp_input_event_s *ie = p; ppb_var_release(ie->code); ppb_var_release(ie->text); free_and_nullify(ie->segment_offsets); } int32_t ppb_input_event_request_input_events(PP_Instance instance, uint32_t event_classes) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_ERROR_BADARGUMENT; } pthread_mutex_lock(&display.lock); pp_i->event_mask |= event_classes; pthread_mutex_unlock(&display.lock); return PP_OK; } int32_t ppb_input_event_request_filtering_input_events(PP_Instance instance, uint32_t event_classes) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_ERROR_BADARGUMENT; } pthread_mutex_lock(&display.lock); pp_i->filtered_event_mask |= event_classes; pthread_mutex_unlock(&display.lock); return PP_OK; } void ppb_input_event_clear_input_event_request(PP_Instance instance, uint32_t event_classes) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return; } pthread_mutex_lock(&display.lock); pp_i->event_mask &= ~event_classes; pp_i->filtered_event_mask &= ~event_classes; pthread_mutex_unlock(&display.lock); return; } PP_Bool ppb_input_event_is_input_event(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_INPUT_EVENT; } PP_InputEvent_Type ppb_input_event_get_type(PP_Resource event) { struct pp_input_event_s *ie = pp_resource_acquire(event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return PP_INPUTEVENT_TYPE_UNDEFINED; } PP_InputEvent_Type t = ie->type; pp_resource_release(event); return t; } PP_TimeTicks ppb_input_event_get_time_stamp(PP_Resource event) { struct pp_input_event_s *ie = pp_resource_acquire(event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return PP_INPUTEVENT_TYPE_UNDEFINED; } PP_TimeTicks time_stamp = ie->time_stamp; pp_resource_release(event); return time_stamp; } uint32_t ppb_input_event_get_modifiers(PP_Resource event) { struct pp_input_event_s *ie = pp_resource_acquire(event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return 0; } uint32_t modifiers = ie->modifiers; pp_resource_release(event); return modifiers; } PP_Resource ppb_mouse_input_event_create(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, PP_InputEvent_MouseButton mouse_button, const struct PP_Point *mouse_position, int32_t click_count, const struct PP_Point *mouse_movement) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource input_event = pp_resource_allocate(PP_RESOURCE_INPUT_EVENT, pp_i); struct pp_input_event_s *ie = pp_resource_acquire(input_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, can't allocate memory\n", __func__); return 0; } ie->event_class = PP_INPUTEVENT_CLASS_MOUSE; ie->type = type; ie->time_stamp = time_stamp; ie->modifiers = modifiers; ie->mouse_button = mouse_button; ie->mouse_position.x = mouse_position ? mouse_position->x : 0; ie->mouse_position.y = mouse_position ? mouse_position->y : 0; ie->click_count = click_count; ie->mouse_movement.x = mouse_movement ? mouse_movement->x : 0; ie->mouse_movement.y = mouse_movement ? mouse_movement->y : 0; pp_resource_release(input_event); return input_event; } PP_Bool ppb_mouse_input_event_is_mouse_input_event(PP_Resource resource) { struct pp_input_event_s *ie = pp_resource_acquire(resource, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } PP_Bool res = ie->event_class == PP_INPUTEVENT_CLASS_MOUSE; pp_resource_release(resource); return res; } PP_InputEvent_MouseButton ppb_mouse_input_event_get_button(PP_Resource mouse_event) { struct pp_input_event_s *ie = pp_resource_acquire(mouse_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return PP_INPUTEVENT_MOUSEBUTTON_NONE; } if (ie->event_class != PP_INPUTEVENT_CLASS_MOUSE) { trace_error("%s, not a mouse event\n", __func__); pp_resource_release(mouse_event); return PP_INPUTEVENT_MOUSEBUTTON_NONE; } PP_InputEvent_MouseButton mb = ie->mouse_button; pp_resource_release(mouse_event); return mb; } struct PP_Point ppb_mouse_input_event_get_position(PP_Resource mouse_event) { struct pp_input_event_s *ie = pp_resource_acquire(mouse_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return PP_MakePoint(0, 0); } if (ie->event_class != PP_INPUTEVENT_CLASS_MOUSE) { trace_error("%s, not a mouse event\n", __func__); pp_resource_release(mouse_event); return PP_MakePoint(0, 0); } struct PP_Point res = PP_MakePoint(ie->mouse_position.x, ie->mouse_position.y); pp_resource_release(mouse_event); return res; } int32_t ppb_mouse_input_event_get_click_count(PP_Resource mouse_event) { struct pp_input_event_s *ie = pp_resource_acquire(mouse_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return 0; } if (ie->event_class != PP_INPUTEVENT_CLASS_MOUSE) { trace_error("%s, not a mouse event\n", __func__); pp_resource_release(mouse_event); return 0; } uint32_t click_count = ie->click_count; pp_resource_release(mouse_event); return click_count; } struct PP_Point ppb_mouse_input_event_get_movement(PP_Resource mouse_event) { struct pp_input_event_s *ie = pp_resource_acquire(mouse_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return PP_MakePoint(0, 0); } if (ie->event_class != PP_INPUTEVENT_CLASS_MOUSE) { trace_error("%s, not a mouse event\n", __func__); pp_resource_release(mouse_event); return PP_MakePoint(0, 0); } struct PP_Point mouse_movement = ie->mouse_movement; pp_resource_release(mouse_event); return mouse_movement; } PP_Resource ppb_wheel_input_event_create(PP_Instance instance, PP_TimeTicks time_stamp, uint32_t modifiers, const struct PP_FloatPoint *wheel_delta, const struct PP_FloatPoint *wheel_ticks, PP_Bool scroll_by_page) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource input_event = pp_resource_allocate(PP_RESOURCE_INPUT_EVENT, pp_i); struct pp_input_event_s *ie = pp_resource_acquire(input_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, can't allocate memory\n", __func__); return 0; } ie->event_class = PP_INPUTEVENT_CLASS_WHEEL; ie->type = PP_INPUTEVENT_TYPE_WHEEL; ie->time_stamp = time_stamp; ie->modifiers = modifiers; ie->wheel_delta.x = wheel_delta ? wheel_delta->x : 0; ie->wheel_delta.y = wheel_delta ? wheel_delta->y : 0; ie->wheel_ticks.x = wheel_ticks ? wheel_ticks->x : 0; ie->wheel_ticks.y = wheel_ticks ? wheel_ticks->y : 0; ie->scroll_by_page = scroll_by_page; pp_resource_release(input_event); return input_event; } PP_Bool ppb_wheel_input_event_is_wheel_input_event(PP_Resource resource) { struct pp_input_event_s *ie = pp_resource_acquire(resource, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } PP_Bool res = ie->event_class == PP_INPUTEVENT_CLASS_WHEEL; pp_resource_release(resource); return res; } struct PP_FloatPoint ppb_wheel_input_event_get_delta(PP_Resource wheel_event) { struct pp_input_event_s *ie = pp_resource_acquire(wheel_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return PP_MakeFloatPoint(0, 0); } if (ie->event_class != PP_INPUTEVENT_CLASS_WHEEL) { trace_error("%s, not a wheel event\n", __func__); pp_resource_release(wheel_event); return PP_MakeFloatPoint(0, 0); } struct PP_FloatPoint ret = ie->wheel_delta; pp_resource_release(wheel_event); return ret; } struct PP_FloatPoint ppb_wheel_input_event_get_ticks(PP_Resource wheel_event) { struct pp_input_event_s *ie = pp_resource_acquire(wheel_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return PP_MakeFloatPoint(0, 0); } if (ie->event_class != PP_INPUTEVENT_CLASS_WHEEL) { trace_error("%s, not a wheel event\n", __func__); pp_resource_release(wheel_event); return PP_MakeFloatPoint(0, 0); } struct PP_FloatPoint ret = ie->wheel_ticks; pp_resource_release(wheel_event); return ret; } PP_Bool ppb_wheel_input_event_get_scroll_by_page(PP_Resource wheel_event) { struct pp_input_event_s *ie = pp_resource_acquire(wheel_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } if (ie->event_class != PP_INPUTEVENT_CLASS_WHEEL) { trace_error("%s, not a wheel event\n", __func__); pp_resource_release(wheel_event); return PP_FALSE; } PP_Bool ret = ie->scroll_by_page; pp_resource_release(wheel_event); return ret; } PP_Resource ppb_keyboard_input_event_create_1_0(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, uint32_t key_code, struct PP_Var character_text) { return ppb_keyboard_input_event_create_1_2(instance, type, time_stamp, modifiers, key_code, character_text, PP_MakeUndefined()); } PP_Resource ppb_keyboard_input_event_create_1_2(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, uint32_t key_code, struct PP_Var character_text, struct PP_Var code) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource input_event = pp_resource_allocate(PP_RESOURCE_INPUT_EVENT, pp_i); struct pp_input_event_s *ie = pp_resource_acquire(input_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, can't allocate memory\n", __func__); return 0; } ie->event_class = PP_INPUTEVENT_CLASS_KEYBOARD; ie->type = type; ie->time_stamp = time_stamp; ie->modifiers = modifiers; ie->key_code = key_code; ie->text = ppb_var_add_ref2(character_text); ie->code = ppb_var_add_ref2(code); pp_resource_release(input_event); return input_event; } PP_Bool ppb_keyboard_input_event_is_keyboard_input_event(PP_Resource resource) { struct pp_input_event_s *ie = pp_resource_acquire(resource, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } PP_Bool res = ie->event_class == PP_INPUTEVENT_CLASS_KEYBOARD; pp_resource_release(resource); return res; } uint32_t ppb_keyboard_input_event_get_key_code(PP_Resource key_event) { struct pp_input_event_s *ie = pp_resource_acquire(key_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return 0; } if (ie->event_class != PP_INPUTEVENT_CLASS_KEYBOARD) { trace_error("%s, not a keyboard event\n", __func__); pp_resource_release(key_event); return 0; } uint32_t key_code = ie->key_code; pp_resource_release(key_event); return key_code; } struct PP_Var ppb_keyboard_input_event_get_character_text(PP_Resource character_event) { struct pp_input_event_s *ie = pp_resource_acquire(character_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return PP_MakeUndefined(); } if (ie->event_class != PP_INPUTEVENT_CLASS_KEYBOARD) { trace_error("%s, not a keyboard event\n", __func__); pp_resource_release(character_event); return PP_MakeUndefined(); } struct PP_Var character_text = ppb_var_add_ref2(ie->text); pp_resource_release(character_event); return character_text; } struct PP_Var ppb_keyboard_input_event_get_code(PP_Resource key_event) { return PP_MakeUndefined(); } PP_Resource ppb_touch_input_event_create(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers) { return 0; } void ppb_touch_input_event_add_touch_point(PP_Resource touch_event, PP_TouchListType list, const struct PP_TouchPoint *point) { } PP_Bool ppb_touch_input_event_is_touch_input_event(PP_Resource resource) { return PP_TRUE; } uint32_t ppb_touch_input_event_get_touch_count(PP_Resource resource, PP_TouchListType list) { return 0; } struct PP_TouchPoint ppb_touch_input_event_get_touch_by_index(PP_Resource resource, PP_TouchListType list, uint32_t index) { return PP_MakeTouchPoint(); } struct PP_TouchPoint ppb_touch_input_event_get_touch_by_id(PP_Resource resource, PP_TouchListType list, uint32_t touch_id) { return PP_MakeTouchPoint(); } PP_Resource ppb_ime_input_event_create(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, struct PP_Var text, uint32_t segment_number, const uint32_t segment_offsets[], int32_t target_segment, uint32_t selection_start, uint32_t selection_end) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } if (type != PP_INPUTEVENT_TYPE_IME_COMPOSITION_START && type != PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE && type != PP_INPUTEVENT_TYPE_IME_COMPOSITION_END && type != PP_INPUTEVENT_TYPE_IME_TEXT) { trace_warning("%s, wrong type=%d\n", __func__, type); return 0; } PP_Resource input_event = pp_resource_allocate(PP_RESOURCE_INPUT_EVENT, pp_i); struct pp_input_event_s *ie = pp_resource_acquire(input_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, can't allocate memory\n", __func__); return 0; } ie->event_class = PP_INPUTEVENT_CLASS_IME; ie->type = type; ie->time_stamp = time_stamp; ie->text = ppb_var_add_ref2(text); ie->segment_number = segment_number; ie->segment_offsets = NULL; if (segment_number > 0) { ie->segment_offsets = malloc((segment_number + 1) * sizeof(uint32_t)); memcpy(ie->segment_offsets, segment_offsets, (segment_number + 1) * sizeof(uint32_t)); } ie->target_segment = target_segment; ie->selection_start = selection_start; ie->selection_end = selection_end; pp_resource_release(input_event); return input_event; } PP_Bool ppb_ime_input_event_is_ime_input_event(PP_Resource resource) { struct pp_input_event_s *ie = pp_resource_acquire(resource, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } PP_Bool res = ie->event_class == PP_INPUTEVENT_CLASS_IME; pp_resource_release(resource); return res; } struct PP_Var ppb_ime_input_event_get_text(PP_Resource ime_event) { struct pp_input_event_s *ie = pp_resource_acquire(ime_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return PP_MakeUndefined(); } if (ie->event_class != PP_INPUTEVENT_CLASS_IME) { trace_error("%s, not an IME event\n", __func__); pp_resource_release(ime_event); return PP_MakeUndefined(); } struct PP_Var text = ppb_var_add_ref2(ie->text); pp_resource_release(ime_event); return text; } uint32_t ppb_ime_input_event_get_segment_number(PP_Resource ime_event) { struct pp_input_event_s *ie = pp_resource_acquire(ime_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return 0; } if (ie->event_class != PP_INPUTEVENT_CLASS_IME) { trace_error("%s, not an IME event\n", __func__); pp_resource_release(ime_event); return 0; } uint32_t segment_number = ie->segment_number; pp_resource_release(ime_event); return segment_number; } uint32_t ppb_ime_input_event_get_segment_offset(PP_Resource ime_event, uint32_t index) { struct pp_input_event_s *ie = pp_resource_acquire(ime_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return 0; } if (ie->event_class != PP_INPUTEVENT_CLASS_IME) { trace_error("%s, not an IME event\n", __func__); pp_resource_release(ime_event); return 0; } uint32_t segment_offset = (index <= ie->segment_number) ? ie->segment_offsets[index] : 0; pp_resource_release(ime_event); return segment_offset; } int32_t ppb_ime_input_event_get_target_segment(PP_Resource ime_event) { struct pp_input_event_s *ie = pp_resource_acquire(ime_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return 0; } if (ie->event_class != PP_INPUTEVENT_CLASS_IME) { trace_error("%s, not an IME event\n", __func__); pp_resource_release(ime_event); return 0; } int32_t target_segment = ie->target_segment; pp_resource_release(ime_event); return target_segment; } void ppb_ime_input_event_get_selection(PP_Resource ime_event, uint32_t *start, uint32_t *end) { struct pp_input_event_s *ie = pp_resource_acquire(ime_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, bad resource\n", __func__); return; } if (ie->event_class != PP_INPUTEVENT_CLASS_IME) { trace_error("%s, not an IME event\n", __func__); pp_resource_release(ime_event); return; } if (start) *start = ie->selection_start; if (end) *end = ie->selection_end; pp_resource_release(ime_event); } // trace wrappers TRACE_WRAPPER int32_t trace_ppb_input_event_request_input_events(PP_Instance instance, uint32_t event_classes) { char *s_event_classes = trace_event_classes_as_string(event_classes); trace_info("[PPB] {full} %s instance=%d, event_classes=%s\n", __func__+6, instance, s_event_classes); free(s_event_classes); return ppb_input_event_request_input_events(instance, event_classes); } TRACE_WRAPPER int32_t trace_ppb_input_event_request_filtering_input_events(PP_Instance instance, uint32_t event_classes) { char *s_event_classes = trace_event_classes_as_string(event_classes); trace_info("[PPB] {full} %s instance=%d, event_classes=%s\n", __func__+6, instance, s_event_classes); free(s_event_classes); return ppb_input_event_request_filtering_input_events(instance, event_classes); } TRACE_WRAPPER void trace_ppb_input_event_clear_input_event_request(PP_Instance instance, uint32_t event_classes) { char *s_event_classes = trace_event_classes_as_string(event_classes); trace_info("[PPB] {full} %s instance=%d, event_classes=%s\n", __func__+6, instance, s_event_classes); free(s_event_classes); ppb_input_event_clear_input_event_request(instance, event_classes); } TRACE_WRAPPER PP_Bool trace_ppb_input_event_is_input_event(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_input_event_is_input_event(resource); } TRACE_WRAPPER PP_InputEvent_Type trace_ppb_input_event_get_type(PP_Resource event) { trace_info("[PPB] {full} %s event=%d\n", __func__+6, event); return ppb_input_event_get_type(event); } TRACE_WRAPPER PP_TimeTicks trace_ppb_input_event_get_time_stamp(PP_Resource event) { trace_info("[PPB] {full} %s event=%d\n", __func__+6, event); return ppb_input_event_get_time_stamp(event); } TRACE_WRAPPER uint32_t trace_ppb_input_event_get_modifiers(PP_Resource event) { trace_info("[PPB] {full} %s event=%d\n", __func__+6, event); return ppb_input_event_get_modifiers(event); } TRACE_WRAPPER PP_Resource trace_ppb_mouse_input_event_create(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, PP_InputEvent_MouseButton mouse_button, const struct PP_Point *mouse_position, int32_t click_count, const struct PP_Point *mouse_movement) { char *s_mouse_position = trace_point_as_string(mouse_position); char *s_mouse_movement = trace_point_as_string(mouse_movement); trace_info("[PPB] {full} %s instance=%d, type=%d, time_stamp=%f, modifiers=0x%x, " "mouse_button=%d, mouse_position=%s, click_count=%d, mouse_movement=%s\n", __func__+6, instance, type, time_stamp, modifiers, mouse_button, s_mouse_position, click_count, s_mouse_movement); g_free(s_mouse_position); g_free(s_mouse_movement); return ppb_mouse_input_event_create(instance, type, time_stamp, modifiers, mouse_button, mouse_position, click_count, mouse_movement); } TRACE_WRAPPER PP_Bool trace_ppb_mouse_input_event_is_mouse_input_event(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_mouse_input_event_is_mouse_input_event(resource); } TRACE_WRAPPER PP_InputEvent_MouseButton trace_ppb_mouse_input_event_get_button(PP_Resource mouse_event) { trace_info("[PPB] {full} %s mouse_event=%d\n", __func__+6, mouse_event); return ppb_mouse_input_event_get_button(mouse_event); } TRACE_WRAPPER struct PP_Point trace_ppb_mouse_input_event_get_position(PP_Resource mouse_event) { trace_info("[PPB] {full} %s mouse_event=%d\n", __func__+6, mouse_event); return ppb_mouse_input_event_get_position(mouse_event); } TRACE_WRAPPER int32_t trace_ppb_mouse_input_event_get_click_count(PP_Resource mouse_event) { trace_info("[PPB] {full} %s mouse_event=%d\n", __func__+6, mouse_event); return ppb_mouse_input_event_get_click_count(mouse_event); } TRACE_WRAPPER struct PP_Point trace_ppb_mouse_input_event_get_movement(PP_Resource mouse_event) { trace_info("[PPB] {full} %s mouse_event=%d\n", __func__+6, mouse_event); return ppb_mouse_input_event_get_movement(mouse_event); } TRACE_WRAPPER PP_Resource trace_ppb_wheel_input_event_create(PP_Instance instance, PP_TimeTicks time_stamp, uint32_t modifiers, const struct PP_FloatPoint *wheel_delta, const struct PP_FloatPoint *wheel_ticks, PP_Bool scroll_by_page) { char *s_wheel_delta = trace_float_point_as_string(wheel_delta); char *s_wheel_ticks = trace_float_point_as_string(wheel_ticks); trace_info("[PPB] {full} %s instance=%d, time_stamp=%f, modifiers=0x%x, wheel_delta=%s, " "wheel_ticks=%s, scrool_by_page=%d\n", __func__+6, instance, time_stamp, modifiers, s_wheel_delta, s_wheel_ticks, scroll_by_page); g_free(s_wheel_delta); g_free(s_wheel_ticks); return ppb_wheel_input_event_create(instance, time_stamp, modifiers, wheel_delta, wheel_ticks, scroll_by_page); } TRACE_WRAPPER PP_Bool trace_ppb_wheel_input_event_is_wheel_input_event(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_wheel_input_event_is_wheel_input_event(resource); } TRACE_WRAPPER struct PP_FloatPoint trace_ppb_wheel_input_event_get_delta(PP_Resource wheel_event) { trace_info("[PPB] {full} %s wheel_event=%d\n", __func__+6, wheel_event); return ppb_wheel_input_event_get_delta(wheel_event); } TRACE_WRAPPER struct PP_FloatPoint trace_ppb_wheel_input_event_get_ticks(PP_Resource wheel_event) { trace_info("[PPB] {full} %s wheel_event=%d\n", __func__+6, wheel_event); return ppb_wheel_input_event_get_ticks(wheel_event); } TRACE_WRAPPER PP_Bool trace_ppb_wheel_input_event_get_scroll_by_page(PP_Resource wheel_event) { trace_info("[PPB] {full} %s wheel_event=%d\n", __func__+6, wheel_event); return ppb_wheel_input_event_get_scroll_by_page(wheel_event); } TRACE_WRAPPER PP_Resource trace_ppb_keyboard_input_event_create_1_0(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, uint32_t key_code, struct PP_Var character_text) { char *s_character_text = trace_var_as_string(character_text); trace_info("[PPB] {full} %s instance=%d, type=%d, time_stamp=%f, modifiers=0x%x, " "key_code=%u, character_text=%s\n", __func__+6, instance, type, time_stamp, modifiers, key_code, s_character_text); g_free(s_character_text); return ppb_keyboard_input_event_create_1_0(instance, type, time_stamp, modifiers, key_code, character_text); } TRACE_WRAPPER PP_Resource trace_ppb_keyboard_input_event_create_1_2(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, uint32_t key_code, struct PP_Var character_text, struct PP_Var code) { char *s_character_text = trace_var_as_string(character_text); char *s_code = trace_var_as_string(code); trace_info("[PPB] {full} %s instance=%d, type=%d, time_stamp=%f, modifiers=0x%x, " "key_code=%u, character_text=%s, code=%s\n", __func__+6, instance, type, time_stamp, modifiers, key_code, s_character_text, s_code); g_free(s_character_text); g_free(s_code); return ppb_keyboard_input_event_create_1_2(instance, type, time_stamp, modifiers, key_code, character_text, code); } TRACE_WRAPPER PP_Bool trace_ppb_keyboard_input_event_is_keyboard_input_event(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_keyboard_input_event_is_keyboard_input_event(resource); } TRACE_WRAPPER uint32_t trace_ppb_keyboard_input_event_get_key_code(PP_Resource key_event) { trace_info("[PPB] {full} %s key_event=%d\n", __func__+6, key_event); return ppb_keyboard_input_event_get_key_code(key_event); } TRACE_WRAPPER struct PP_Var trace_ppb_keyboard_input_event_get_character_text(PP_Resource character_event) { trace_info("[PPB] {full} %s character_event=%d\n", __func__+6, character_event); return ppb_keyboard_input_event_get_character_text(character_event); } TRACE_WRAPPER struct PP_Var trace_ppb_keyboard_input_event_get_code(PP_Resource key_event) { trace_info("[PPB] {zilch} %s key_event=%d\n", __func__+6, key_event); return ppb_keyboard_input_event_get_code(key_event); } TRACE_WRAPPER PP_Resource trace_ppb_touch_input_event_create(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers) { trace_info("[PPB] {zilch} %s instance=%d, type=%d, time_stamp=%f, modifiers=0x%x\n", __func__+6, instance, type, time_stamp, modifiers); return ppb_touch_input_event_create(instance, type, time_stamp, modifiers); } TRACE_WRAPPER void trace_ppb_touch_input_event_add_touch_point(PP_Resource touch_event, PP_TouchListType list, const struct PP_TouchPoint *point) { char *s_point = trace_touch_point_as_string(point); trace_info("[PPB] {zilch} %s touch_event=%d, list=%d, point=%s\n", __func__+6, touch_event, list, s_point); g_free(s_point); return ppb_touch_input_event_add_touch_point(touch_event, list, point); } TRACE_WRAPPER PP_Bool trace_ppb_touch_input_event_is_touch_input_event(PP_Resource resource) { trace_info("[PPB] {zilch} %s resource=%d\n", __func__+6, resource); return ppb_touch_input_event_is_touch_input_event(resource); } TRACE_WRAPPER uint32_t trace_ppb_touch_input_event_get_touch_count(PP_Resource resource, PP_TouchListType list) { trace_info("[PPB] {zilch} %s resource=%d, list=%d\n", __func__+6, resource, list); return ppb_touch_input_event_get_touch_count(resource, list); } TRACE_WRAPPER struct PP_TouchPoint trace_ppb_touch_input_event_get_touch_by_index(PP_Resource resource, PP_TouchListType list, uint32_t index) { trace_info("[PPB] {zilch} %s resource=%d, list=%d, index=%u\n", __func__+6, resource, list, index); return ppb_touch_input_event_get_touch_by_index(resource, list, index); } TRACE_WRAPPER struct PP_TouchPoint trace_ppb_touch_input_event_get_touch_by_id(PP_Resource resource, PP_TouchListType list, uint32_t touch_id) { trace_info("[PPB] {zilch} %s resource=%d, list=%d, touch_id=%u\n", __func__+6, resource, list, touch_id); return ppb_touch_input_event_get_touch_by_id(resource, list, touch_id); } TRACE_WRAPPER PP_Resource trace_ppb_ime_input_event_create(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, struct PP_Var text, uint32_t segment_number, const uint32_t segment_offsets[], int32_t target_segment, uint32_t selection_start, uint32_t selection_end) { char *s_text = trace_var_as_string(text); trace_info("[PPB] {full} %s instance=%d, type=%d, time_stamp=%f, text=%s, segment_number=%u, " "segment_offsets=%p, target_segment=%d, selection_start=%u, selection_end=%u\n", __func__+6, instance, type, time_stamp, s_text, segment_number, segment_offsets, target_segment, selection_start, selection_end); g_free(s_text); return ppb_ime_input_event_create(instance, type, time_stamp, text, segment_number, segment_offsets, target_segment, selection_start, selection_end); } TRACE_WRAPPER PP_Bool trace_ppb_ime_input_event_is_ime_input_event(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_ime_input_event_is_ime_input_event(resource); } TRACE_WRAPPER struct PP_Var trace_ppb_ime_input_event_get_text(PP_Resource ime_event) { trace_info("[PPB] {full} %s ime_event=%d\n", __func__+6, ime_event); return ppb_ime_input_event_get_text(ime_event); } TRACE_WRAPPER uint32_t trace_ppb_ime_input_event_get_segment_number(PP_Resource ime_event) { trace_info("[PPB] {full} %s ime_event=%d\n", __func__+6, ime_event); return ppb_ime_input_event_get_segment_number(ime_event); } TRACE_WRAPPER uint32_t trace_ppb_ime_input_event_get_segment_offset(PP_Resource ime_event, uint32_t index) { trace_info("[PPB] {full} %s ime_event=%d, index=%u\n", __func__+6, ime_event, index); return ppb_ime_input_event_get_segment_offset(ime_event, index); } TRACE_WRAPPER int32_t trace_ppb_ime_input_event_get_target_segment(PP_Resource ime_event) { trace_info("[PPB] {full} %s ime_event=%d\n", __func__+6, ime_event); return ppb_ime_input_event_get_target_segment(ime_event); } TRACE_WRAPPER void trace_ppb_ime_input_event_get_selection(PP_Resource ime_event, uint32_t *start, uint32_t *end) { trace_info("[PPB] {full} %s ime_event=%d\n", __func__+6, ime_event); return ppb_ime_input_event_get_selection(ime_event, start, end); } const struct PPB_InputEvent_1_0 ppb_input_event_interface_1_0 = { .RequestInputEvents = TWRAPF(ppb_input_event_request_input_events), .RequestFilteringInputEvents = TWRAPF(ppb_input_event_request_filtering_input_events), .ClearInputEventRequest = TWRAPF(ppb_input_event_clear_input_event_request), .IsInputEvent = TWRAPF(ppb_input_event_is_input_event), .GetType = TWRAPF(ppb_input_event_get_type), .GetTimeStamp = TWRAPF(ppb_input_event_get_time_stamp), .GetModifiers = TWRAPF(ppb_input_event_get_modifiers), }; const struct PPB_MouseInputEvent_1_1 ppb_mouse_input_event_interface_1_1 = { .Create = TWRAPF(ppb_mouse_input_event_create), .IsMouseInputEvent = TWRAPF(ppb_mouse_input_event_is_mouse_input_event), .GetButton = TWRAPF(ppb_mouse_input_event_get_button), .GetPosition = TWRAPF(ppb_mouse_input_event_get_position), .GetClickCount = TWRAPF(ppb_mouse_input_event_get_click_count), .GetMovement = TWRAPF(ppb_mouse_input_event_get_movement), }; const struct PPB_WheelInputEvent_1_0 ppb_wheel_input_event_interface_1_0 = { .Create = TWRAPF(ppb_wheel_input_event_create), .IsWheelInputEvent = TWRAPF(ppb_wheel_input_event_is_wheel_input_event), .GetDelta = TWRAPF(ppb_wheel_input_event_get_delta), .GetTicks = TWRAPF(ppb_wheel_input_event_get_ticks), .GetScrollByPage = TWRAPF(ppb_wheel_input_event_get_scroll_by_page), }; const struct PPB_KeyboardInputEvent_1_0 ppb_keyboard_input_event_interface_1_0 = { .Create = TWRAPF(ppb_keyboard_input_event_create_1_0), .IsKeyboardInputEvent = TWRAPF(ppb_keyboard_input_event_is_keyboard_input_event), .GetKeyCode = TWRAPF(ppb_keyboard_input_event_get_key_code), .GetCharacterText = TWRAPF(ppb_keyboard_input_event_get_character_text), }; const struct PPB_KeyboardInputEvent_1_2 ppb_keyboard_input_event_interface_1_2 = { .Create = TWRAPF(ppb_keyboard_input_event_create_1_2), .IsKeyboardInputEvent = TWRAPF(ppb_keyboard_input_event_is_keyboard_input_event), .GetKeyCode = TWRAPF(ppb_keyboard_input_event_get_key_code), .GetCharacterText = TWRAPF(ppb_keyboard_input_event_get_character_text), .GetCode = TWRAPZ(ppb_keyboard_input_event_get_code), }; const struct PPB_TouchInputEvent_1_0 ppb_touch_input_event_interface_1_0 = { .Create = TWRAPZ(ppb_touch_input_event_create), .AddTouchPoint = TWRAPZ(ppb_touch_input_event_add_touch_point), .IsTouchInputEvent = TWRAPZ(ppb_touch_input_event_is_touch_input_event), .GetTouchCount = TWRAPZ(ppb_touch_input_event_get_touch_count), .GetTouchByIndex = TWRAPZ(ppb_touch_input_event_get_touch_by_index), .GetTouchById = TWRAPZ(ppb_touch_input_event_get_touch_by_id), }; const struct PPB_IMEInputEvent_Dev_0_2 ppb_ime_input_event_dev_interface_0_2 = { .Create = TWRAPF(ppb_ime_input_event_create), .IsIMEInputEvent = TWRAPF(ppb_ime_input_event_is_ime_input_event), .GetText = TWRAPF(ppb_ime_input_event_get_text), .GetSegmentNumber = TWRAPF(ppb_ime_input_event_get_segment_number), .GetSegmentOffset = TWRAPF(ppb_ime_input_event_get_segment_offset), .GetTargetSegment = TWRAPF(ppb_ime_input_event_get_target_segment), .GetSelection = TWRAPF(ppb_ime_input_event_get_selection), }; const struct PPB_IMEInputEvent_1_0 ppb_ime_input_event_interface_1_0 = { .Create = TWRAPF(ppb_ime_input_event_create), .IsIMEInputEvent = TWRAPF(ppb_ime_input_event_is_ime_input_event), .GetText = TWRAPF(ppb_ime_input_event_get_text), .GetSegmentNumber = TWRAPF(ppb_ime_input_event_get_segment_number), .GetSegmentOffset = TWRAPF(ppb_ime_input_event_get_segment_offset), .GetTargetSegment = TWRAPF(ppb_ime_input_event_get_target_segment), .GetSelection = TWRAPF(ppb_ime_input_event_get_selection), }; static void __attribute__((constructor)) constructor_ppb_input_event(void) { register_interface(PPB_IME_INPUT_EVENT_DEV_INTERFACE_0_2, &ppb_ime_input_event_dev_interface_0_2); register_interface(PPB_INPUT_EVENT_INTERFACE_1_0, &ppb_input_event_interface_1_0); register_interface(PPB_MOUSE_INPUT_EVENT_INTERFACE_1_1, &ppb_mouse_input_event_interface_1_1); register_interface(PPB_WHEEL_INPUT_EVENT_INTERFACE_1_0, &ppb_wheel_input_event_interface_1_0); register_interface(PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_0, &ppb_keyboard_input_event_interface_1_0); register_interface(PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_2, &ppb_keyboard_input_event_interface_1_2); register_interface(PPB_TOUCH_INPUT_EVENT_INTERFACE_1_0, &ppb_touch_input_event_interface_1_0); register_interface(PPB_IME_INPUT_EVENT_INTERFACE_1_0, &ppb_ime_input_event_interface_1_0); register_resource(PP_RESOURCE_INPUT_EVENT, ppb_input_event_destroy); } freshplayerplugin-0.3.9/src/ppb_input_event.h000066400000000000000000000130221321746453100214330ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include #include int32_t ppb_input_event_request_input_events(PP_Instance instance, uint32_t event_classes); int32_t ppb_input_event_request_filtering_input_events(PP_Instance instance, uint32_t event_classes); void ppb_input_event_clear_input_event_request(PP_Instance instance, uint32_t event_classes); PP_Bool ppb_input_event_is_input_event(PP_Resource resource); PP_InputEvent_Type ppb_input_event_get_type(PP_Resource event); PP_TimeTicks ppb_input_event_get_time_stamp(PP_Resource event); uint32_t ppb_input_event_get_modifiers(PP_Resource event); PP_Resource ppb_mouse_input_event_create(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, PP_InputEvent_MouseButton mouse_button, const struct PP_Point *mouse_position, int32_t click_count, const struct PP_Point *mouse_movement); PP_Bool ppb_mouse_input_event_is_mouse_input_event(PP_Resource resource); PP_InputEvent_MouseButton ppb_mouse_input_event_get_button(PP_Resource mouse_event); struct PP_Point ppb_mouse_input_event_get_position(PP_Resource mouse_event); int32_t ppb_mouse_input_event_get_click_count(PP_Resource mouse_event); struct PP_Point ppb_mouse_input_event_get_movement(PP_Resource mouse_event); PP_Resource ppb_wheel_input_event_create(PP_Instance instance, PP_TimeTicks time_stamp, uint32_t modifiers, const struct PP_FloatPoint *wheel_delta, const struct PP_FloatPoint *wheel_ticks, PP_Bool scroll_by_page); PP_Bool ppb_wheel_input_event_is_wheel_input_event(PP_Resource resource); struct PP_FloatPoint ppb_wheel_input_event_get_delta(PP_Resource wheel_event); struct PP_FloatPoint ppb_wheel_input_event_get_ticks(PP_Resource wheel_event); PP_Bool ppb_wheel_input_event_get_scroll_by_page(PP_Resource wheel_event); PP_Resource ppb_keyboard_input_event_create_1_0(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, uint32_t key_code, struct PP_Var character_text); PP_Resource ppb_keyboard_input_event_create_1_2(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, uint32_t key_code, struct PP_Var character_text, struct PP_Var code); PP_Bool ppb_keyboard_input_event_is_keyboard_input_event(PP_Resource resource); uint32_t ppb_keyboard_input_event_get_key_code(PP_Resource key_event); struct PP_Var ppb_keyboard_input_event_get_character_text(PP_Resource character_event); PP_Resource ppb_touch_input_event_create(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers); void ppb_touch_input_event_add_touch_point(PP_Resource touch_event, PP_TouchListType list, const struct PP_TouchPoint *point); PP_Bool ppb_touch_input_event_is_touch_input_event(PP_Resource resource); uint32_t ppb_touch_input_event_get_touch_count(PP_Resource resource, PP_TouchListType list); struct PP_TouchPoint ppb_touch_input_event_get_touch_by_index(PP_Resource resource, PP_TouchListType list, uint32_t index); struct PP_TouchPoint ppb_touch_input_event_get_touch_by_id(PP_Resource resource, PP_TouchListType list, uint32_t touch_id); PP_Resource ppb_ime_input_event_create(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, struct PP_Var text, uint32_t segment_number, const uint32_t segment_offsets[], int32_t target_segment, uint32_t selection_start, uint32_t selection_end); PP_Bool ppb_ime_input_event_is_ime_input_event(PP_Resource resource); struct PP_Var ppb_ime_input_event_get_text(PP_Resource ime_event); uint32_t ppb_ime_input_event_get_segment_number(PP_Resource ime_event); uint32_t ppb_ime_input_event_get_segment_offset(PP_Resource ime_event, uint32_t index); int32_t ppb_ime_input_event_get_target_segment(PP_Resource ime_event); void ppb_ime_input_event_get_selection(PP_Resource ime_event, uint32_t *start, uint32_t *end); freshplayerplugin-0.3.9/src/ppb_instance.c000066400000000000000000000253341321746453100207030ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "n2p_proxy_class.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_core.h" #include "ppb_graphics2d.h" #include "ppb_graphics3d.h" #include "ppb_instance.h" #include "ppb_message_loop.h" #include "ppb_var.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include "utils.h" #include #include STATIC_ASSERT(sizeof(struct pp_instance_s) <= LARGEST_RESOURCE_SIZE); static void call_invalidaterect_ptac(void *param) { struct pp_instance_s *pp_i = tables_get_pp_instance(GPOINTER_TO_SIZE(param)); if (!pp_i) return; NPRect npr = {.top = 0, .left = 0, .bottom = pp_i->height, .right = pp_i->width}; npn.invalidaterect(pp_i->npp, &npr); npn.forceredraw(pp_i->npp); } PP_Bool ppb_instance_bind_graphics(PP_Instance instance, PP_Resource device) { PP_Bool retval; struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_FALSE; } if (device == 0) { // unbind ppb_core_release_resource(pp_i->graphics); pthread_mutex_lock(&display.lock); pp_i->graphics = 0; pthread_mutex_unlock(&display.lock); return PP_TRUE; } struct pp_graphics2d_s *g2d = pp_resource_acquire(device, PP_RESOURCE_GRAPHICS2D); struct pp_graphics3d_s *g3d = pp_resource_acquire(device, PP_RESOURCE_GRAPHICS3D); int invalidate_area = 0; if (g2d) { if (pp_i != g2d->instance) { retval = PP_FALSE; goto done; } pthread_mutex_lock(&display.lock); const PP_Resource previous_device = pp_i->graphics; pp_i->graphics = device; pthread_mutex_unlock(&display.lock); if (device != previous_device) { ppb_core_add_ref_resource(device); ppb_core_release_resource(previous_device); } pp_resource_release(device); retval = PP_TRUE; invalidate_area = 1; } else if (g3d) { if (pp_i != g3d->instance) { retval = PP_FALSE; goto done; } pthread_mutex_lock(&display.lock); const PP_Resource previous_device = pp_i->graphics; pp_i->graphics = device; pthread_mutex_unlock(&display.lock); if (device != previous_device) { ppb_core_add_ref_resource(device); ppb_core_release_resource(previous_device); } pp_resource_release(device); retval = PP_TRUE; invalidate_area = 1; } else { trace_warning("%s, unsupported graphics resource %d on instance %d\n", __func__, device, instance); retval = PP_FALSE; } done: if (invalidate_area) { // successful binding causes plugin graphics area invalidation ppb_core_call_on_browser_thread(instance, call_invalidaterect_ptac, GSIZE_TO_POINTER(instance)); } return retval; } PP_Bool ppb_instance_is_full_frame(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_FALSE; } pthread_mutex_lock(&display.lock); int is_fullframe = pp_i->is_fullframe; pthread_mutex_unlock(&display.lock); if (is_fullframe) return PP_TRUE; else return PP_FALSE; } struct get_window_object_param_s { PP_Instance instance; struct PP_Var result; PP_Resource m_loop; int depth; }; static void get_window_object_ptac(void *param) { struct get_window_object_param_s *p = param; struct pp_instance_s *pp_i = tables_get_pp_instance(p->instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); p->result = PP_MakeUndefined(); goto done; } npn.retainobject(pp_i->np_window_obj); p->result = ppb_var_create_object(p->instance, &n2p_proxy_class, pp_i->np_window_obj); done: ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void get_window_object_comt(void *user_data, int32_t result) { struct get_window_object_param_s *p = user_data; ppb_core_call_on_browser_thread(0, get_window_object_ptac, p); } struct PP_Var ppb_instance_get_window_object(PP_Instance instance) { struct get_window_object_param_s *p = g_slice_alloc(sizeof(*p)); p->instance = instance; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(get_window_object_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); struct PP_Var result = p->result; g_slice_free1(sizeof(*p), p); return result; } struct PP_Var ppb_instance_get_owner_element_object(PP_Instance instance) { return PP_MakeUndefined(); } struct execute_script_param_s { struct PP_Var script; struct PP_Var result; PP_Instance instance_id; PP_Resource m_loop; int depth; }; static void execute_script_ptac(void *user_data) { struct execute_script_param_s *p = user_data; NPString np_script; NPVariant np_result; struct pp_instance_s *pp_i = tables_get_pp_instance(p->instance_id); if (!pp_i) { p->result = PP_MakeUndefined(); goto quit; } // no need to lock, this function is run only in browser thread if (!pp_i->npp) { trace_error("%s, plugin instance was destroyed\n", __func__); p->result = PP_MakeUndefined(); goto quit; } np_script.UTF8Characters = ppb_var_var_to_utf8(p->script, &np_script.UTF8Length); if (!npn.evaluate(pp_i->npp, pp_i->np_window_obj, &np_script, &np_result)) { trace_error("%s, NPN_Evaluate failed\n", __func__); p->result = PP_MakeUndefined(); goto quit; } // TODO: find out what exception is p->result = np_variant_to_pp_var(np_result); if (np_result.type == NPVariantType_Object) tables_add_npobj_npp_mapping(np_result.value.objectValue, pp_i->npp); else npn.releasevariantvalue(&np_result); quit: ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void execute_script_comt(void *user_data, int32_t result) { struct execute_script_param_s *esp = user_data; ppb_core_call_on_browser_thread(0, execute_script_ptac, esp); } struct PP_Var ppb_instance_execute_script(PP_Instance instance, struct PP_Var script, struct PP_Var *exception) { if (script.type != PP_VARTYPE_STRING) { trace_error("%s, 'script' is not a string\n", __func__); // TODO: fill exception return PP_MakeUndefined(); } struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_MakeUndefined(); } struct execute_script_param_s *p = g_slice_alloc(sizeof(*p)); p->script = script; p->instance_id = instance; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_var_add_ref(script); ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(execute_script_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); ppb_var_release(script); struct PP_Var result = p->result; g_slice_free1(sizeof(*p), p); return result; } // trace wrappers TRACE_WRAPPER PP_Bool trace_ppb_instance_bind_graphics(PP_Instance instance, PP_Resource device) { trace_info("[PPB] {full} %s instance=%d, device=%d\n", __func__+6, instance, device); return ppb_instance_bind_graphics(instance, device); } TRACE_WRAPPER PP_Bool trace_ppb_instance_is_full_frame(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_instance_is_full_frame(instance); } TRACE_WRAPPER struct PP_Var trace_ppb_instance_get_window_object(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_instance_get_window_object(instance); } TRACE_WRAPPER struct PP_Var trace_ppb_instance_get_owner_element_object(PP_Instance instance) { trace_info("[PPB] {zilch} %s instance=%d\n", __func__+6, instance); return ppb_instance_get_owner_element_object(instance); } TRACE_WRAPPER struct PP_Var trace_ppb_instance_execute_script(PP_Instance instance, struct PP_Var script, struct PP_Var *exception) { char *s_script = trace_var_as_string(script); trace_info("[PPB] {full} %s instance=%d, script=%s\n", __func__+6, instance, s_script); g_free(s_script); return ppb_instance_execute_script(instance, script, exception); } const struct PPB_Instance_1_0 ppb_instance_interface_1_0 = { .BindGraphics = TWRAPF(ppb_instance_bind_graphics), .IsFullFrame = TWRAPF(ppb_instance_is_full_frame), }; const struct PPB_Instance_Private_0_1 ppb_instance_private_interface_0_1 = { .GetWindowObject = TWRAPF(ppb_instance_get_window_object), .GetOwnerElementObject = TWRAPZ(ppb_instance_get_owner_element_object), .ExecuteScript = TWRAPF(ppb_instance_execute_script), }; static void __attribute__((constructor)) constructor_ppb_instance(void) { register_interface(PPB_INSTANCE_INTERFACE_1_0, &ppb_instance_interface_1_0); register_interface(PPB_INSTANCE_PRIVATE_INTERFACE_0_1, &ppb_instance_private_interface_0_1); } freshplayerplugin-0.3.9/src/ppb_instance.h000066400000000000000000000126741321746453100207130ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include "gtk_wrapper.h" #include #include #include #include #include #include #include #include #include struct pp_instance_s { const struct PPP_Instance_1_1 *ppp_instance_1_1; const struct PPP_InputEvent_0_1 *ppp_input_event; const struct PPP_Instance_Private_0_1 *ppp_instance_private; const struct PPP_TextInput_Dev_0_1 *ppp_text_input_dev; struct PP_Var scriptable_pp_obj; NPObject *np_window_obj; NPObject *np_plugin_element_obj; uint32_t event_mask; uint32_t filtered_event_mask; Window wnd; Window browser_wnd; GtkWidget *catcher_widget; ///< catches keypresses returned from IME PP_Instance id; NPP npp; uint32_t is_fullframe; uint32_t is_fullscreen; uint32_t is_fullscreen_apparent; uint32_t is_transparent; uint32_t windowed_mode; uint32_t use_xembed; uint32_t incognito_mode; volatile gint instance_loaded; uint32_t ignore_focus_events_cnt; ///< number of focus events to ignore unsigned long last_button_release_timestamp; PP_Resource content_url_loader; uint32_t content_url_loader_used; volatile gint audio_source_count; ///< number of currently active audiosources volatile gint is_muted; Cursor prev_cursor; int have_prev_cursor; volatile gint cursor_inside_instance; // full screen pthread_t fs_thread; Window fs_wnd; ///< fullscreen window handle uint32_t fs_width; ///< established width of fullscreen window uint32_t fs_height; ///< established height of fullscreen window // current geometry of fullscreen window. Can change multiple times during transition uint32_t fs_width_current; uint32_t fs_height_current; // geometry int32_t x; int32_t y; uint32_t width; uint32_t height; int32_t offset_x; ///< relative to a browser window top left corner int32_t offset_y; ///< relative to a browser window top left corner struct { int32_t left; int32_t top; int32_t right; int32_t bottom; } clip_rect; int argc; char **argn; char **argv; struct PP_Var instance_url; ///< absolute instance url struct PP_Var document_url; struct PP_Var document_base_url; pthread_t main_thread; pthread_barrier_t main_thread_barrier; // graphics2d and graphics3d PP_Resource graphics; struct PP_CompletionCallback graphics_ccb; uint32_t graphics_in_progress; PP_Resource graphics_ccb_ml; // input method context PP_TextInput_Type_Dev textinput_type; GtkIMContext *im_context; GtkIMContext *im_context_multi; GtkIMContext *im_context_simple; }; PP_Bool ppb_instance_bind_graphics(PP_Instance instance, PP_Resource device); PP_Bool ppb_instance_is_full_frame(PP_Instance instance); struct PP_Var ppb_instance_get_window_object(PP_Instance instance); struct PP_Var ppb_instance_get_owner_element_object(PP_Instance instance); struct PP_Var ppb_instance_execute_script(PP_Instance instance, struct PP_Var script, struct PP_Var *exception); freshplayerplugin-0.3.9/src/ppb_memory.c000066400000000000000000000042131321746453100204000ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "ppb_memory.h" #include "tables.h" #include "trace_core.h" void * ppb_memory_mem_alloc(uint32_t num_bytes) { return npn.memalloc(num_bytes); // TODO: is it safe to call npn.memalloc()? } void ppb_memory_mem_free(void *ptr) { npn.memfree(ptr); // TODO: is it safe to call npn.memfree()? } // trace wrappers TRACE_WRAPPER void * trace_ppb_memory_mem_alloc(uint32_t num_bytes) { trace_info("[PPB] {full} %s num_bytes=%u\n", __func__+6, num_bytes); return ppb_memory_mem_alloc(num_bytes); } TRACE_WRAPPER void trace_ppb_memory_mem_free(void *ptr) { trace_info("[PPB] {full} %s ptr=%p\n", __func__+6, ptr); ppb_memory_mem_free(ptr); } const struct PPB_Memory_Dev_0_1 ppb_memory_dev_interface_0_1 = { .MemAlloc = TWRAPF(ppb_memory_mem_alloc), .MemFree = TWRAPF(ppb_memory_mem_free), }; static void __attribute__((constructor)) constructor_ppb_memory(void) { register_interface(PPB_MEMORY_DEV_INTERFACE_0_1, &ppb_memory_dev_interface_0_1); } freshplayerplugin-0.3.9/src/ppb_memory.h000066400000000000000000000024421321746453100204070ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include void * ppb_memory_mem_alloc(uint32_t num_bytes); void ppb_memory_mem_free(void *ptr); freshplayerplugin-0.3.9/src/ppb_message_loop.c000066400000000000000000000426121321746453100215520ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "compat.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_message_loop.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include #include #include #include #include #include struct pp_message_loop_s { COMMON_STRUCTURE_FIELDS GAsyncQueue *async_q; GTree *int_q; int running; int teardown; int depth; }; STATIC_ASSERT(sizeof(struct pp_message_loop_s) <= LARGEST_RESOURCE_SIZE); static __thread PP_Resource this_thread_message_loop = 0; static __thread int thread_is_not_suitable_for_message_loop = 0; static PP_Resource main_thread_message_loop = 0; static PP_Resource browser_thread_message_loop = 0; struct message_loop_task_s { struct timespec when; int terminate; int depth; const char *origin; ///< name of the function that scheduled the task struct PP_CompletionCallback ccb; int32_t result_to_pass; PP_Bool should_destroy_ml; }; static gint task_tree_compare_func(gconstpointer a, gconstpointer b) { const struct message_loop_task_s *task_a = a; const struct message_loop_task_s *task_b = b; if (task_a->when.tv_sec < task_b->when.tv_sec) return -1; else if (task_a->when.tv_sec > task_b->when.tv_sec) return 1; else if (task_a->when.tv_nsec < task_b->when.tv_nsec) return -1; else if (task_a->when.tv_nsec > task_b->when.tv_nsec) return 1; else return 0; } PP_Resource ppb_message_loop_create(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource message_loop = pp_resource_allocate(PP_RESOURCE_MESSAGE_LOOP, pp_i); struct pp_message_loop_s *ml = pp_resource_acquire(message_loop, PP_RESOURCE_MESSAGE_LOOP); if (!ml) { trace_error("%s, resource allocation failure\n", __func__); return 0; } ml->async_q = g_async_queue_new(); ml->int_q = g_tree_new(task_tree_compare_func); ml->depth = 0; // running loop will always have depth > 0 pp_resource_release(message_loop); return message_loop; } static void ppb_message_loop_destroy(void *p) { struct pp_message_loop_s *ml = p; if (ml->async_q) { g_async_queue_unref(ml->async_q); ml->async_q = NULL; } if (ml->int_q) { g_tree_destroy(ml->int_q); ml->int_q = NULL; } } PP_Resource ppb_message_loop_get_for_main_thread(void) { return main_thread_message_loop; } int32_t ppb_message_loop_proclaim_this_thread_main(void) { if (this_thread_message_loop == 0) { trace_error("%s, no message loop attached\n", __func__); return PP_ERROR_WRONG_THREAD; } main_thread_message_loop = this_thread_message_loop; return PP_OK; } PP_Resource ppb_message_loop_get_for_browser_thread(void) { return browser_thread_message_loop; } int32_t ppb_message_loop_proclaim_this_thread_browser(void) { if (this_thread_message_loop == 0) { trace_error("%s, no message loop attached\n", __func__); return PP_ERROR_WRONG_THREAD; } browser_thread_message_loop = this_thread_message_loop; return PP_OK; } PP_Resource ppb_message_loop_get_current(void) { return this_thread_message_loop; } int ppb_message_loop_get_depth(PP_Resource message_loop) { struct pp_message_loop_s *ml = pp_resource_acquire(message_loop, PP_RESOURCE_MESSAGE_LOOP); if (!ml) { trace_error("%s, bad resource\n", __func__); return 0; } int depth = ml->depth; pp_resource_release(message_loop); return depth; } void ppb_message_loop_mark_thread_unsuitable(void) { thread_is_not_suitable_for_message_loop = 1; } int32_t ppb_message_loop_attach_to_current_thread(PP_Resource message_loop) { if (pp_resource_get_type(message_loop) != PP_RESOURCE_MESSAGE_LOOP) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } if (thread_is_not_suitable_for_message_loop) { trace_error("%s, can't attach to this thread\n", __func__); return PP_ERROR_WRONG_THREAD; } if (this_thread_message_loop != 0) { trace_error("%s, thread already have message loop attached\n", __func__); return PP_ERROR_INPROGRESS; } this_thread_message_loop = message_loop; return PP_OK; } int32_t ppb_message_loop_run(PP_Resource message_loop) { // first actual depth will be 1. return ppb_message_loop_run_int(message_loop, ML_INCREASE_DEPTH); } int32_t ppb_message_loop_run_nested(PP_Resource message_loop) { return ppb_message_loop_run_int(message_loop, ML_NESTED | ML_INCREASE_DEPTH); } struct task_tree_traverse_func_state { int current_depth; struct message_loop_task_s *result; }; static gboolean task_tree_traverse_func(gpointer key, gpointer value, gpointer data) { (void)value; // value is not used here struct message_loop_task_s *task = key; struct task_tree_traverse_func_state *state = data; if (task->depth == 0 || task->depth >= state->current_depth) { // appropriate tasks are: // either tasks with depth 0, which means any time is good; // or tasks with current depth; // or tasks left from previous nesting. state->result = task; // stop here return TRUE; } // otherwise continue traversing return FALSE; } static struct message_loop_task_s * find_first_task_with_appropriate_depth(GTree *q, int current_depth) { struct task_tree_traverse_func_state state = { .result = NULL, .current_depth = current_depth, }; g_tree_foreach(q, task_tree_traverse_func, &state); return state.result; } int32_t ppb_message_loop_run_int(PP_Resource message_loop, uint32_t flags) { if (this_thread_message_loop != message_loop) { trace_error("%s, not attached to current thread\n", __func__); return PP_ERROR_WRONG_THREAD; } struct pp_message_loop_s *ml = pp_resource_acquire(message_loop, PP_RESOURCE_MESSAGE_LOOP); if (!ml) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } // prevent nested loops if (!(flags & ML_NESTED) && ml->running) { trace_error("%s, trying to run nested loop without declaring as nested\n", __func__); pp_resource_release(message_loop); return PP_ERROR_INPROGRESS; } struct { int running; int teardown; } saved_state = { .running = ml->running, .teardown = ml->teardown, }; ml->running = 1; ml->teardown = 0; if (flags & ML_INCREASE_DEPTH) ml->depth++; int teardown = 0; int destroy_ml = 0; int depth = ml->depth; pp_resource_ref(message_loop); GAsyncQueue *async_q = ml->async_q; GTree *int_q = ml->int_q; pp_resource_release(message_loop); if (flags & ML_EXIT_ON_EMPTY) { // pump tasks from async_q to int_q. If there is no ML_EXIT_ON_EMPTY in flags, such // action is not necessary struct message_loop_task_s *task; do { task = g_async_queue_try_pop(async_q); if (task) g_tree_insert(int_q, task, GINT_TO_POINTER(1)); } while (task != NULL); } while (1) { struct timespec now; struct message_loop_task_s *task = find_first_task_with_appropriate_depth(int_q, depth); gint64 timeout = 1000 * 1000; if (task) { clock_gettime(CLOCK_REALTIME, &now); timeout = (task->when.tv_sec - now.tv_sec) * 1000 * 1000 + (task->when.tv_nsec - now.tv_nsec) / 1000; if (timeout <= 0) { // remove task from the queue g_tree_remove(int_q, task); if (task->terminate) { // if depth > 1 or loop was reentered with no depth increase, it's a nested loop if (depth > 1 || !(flags & ML_INCREASE_DEPTH)) { // exit at once, all remaining task will be processed by outer loop g_slice_free(struct message_loop_task_s, task); break; } // it's the outermost loop, we should wait for all tasks to be run ml = pp_resource_acquire(message_loop, PP_RESOURCE_MESSAGE_LOOP); if (ml) { ml->teardown = 1; teardown = 1; destroy_ml = task->should_destroy_ml; pp_resource_release(message_loop); } g_slice_free(struct message_loop_task_s, task); continue; } // run task const struct PP_CompletionCallback ccb = task->ccb; if (ccb.func) { trace_info_f(" calling callback={.func=%p, .user_data=%p, .flags=%d}, " "result=%d, origin=%s\n", ccb.func, ccb.user_data, ccb.flags, task->result_to_pass, task->origin); ccb.func(ccb.user_data, task->result_to_pass); trace_info_f(" returning from callback={.func=%p, .user_data=%p, .flags=%d}, " "result=%d, origin=%s\n", ccb.func, ccb.user_data, ccb.flags, task->result_to_pass, task->origin); } // free task g_slice_free(struct message_loop_task_s, task); continue; // run cycle again } } else if (teardown) { // teardown, no tasks in queue left break; } else if (flags & ML_EXIT_ON_EMPTY) { // loop break was requested for "no-task" condition; and there is no tasks left break; } task = g_async_queue_timeout_pop(async_q, timeout); if (task) g_tree_insert(int_q, task, GINT_TO_POINTER(1)); } // mark thread as non-running ml = pp_resource_acquire(message_loop, PP_RESOURCE_MESSAGE_LOOP); if (ml) { if (flags & ML_INCREASE_DEPTH) ml->depth--; ml->running = 0; if (flags & ML_NESTED) { ml->running = saved_state.running; ml->teardown = saved_state.teardown; } pp_resource_release(message_loop); } pp_resource_unref(message_loop); if (destroy_ml) pp_resource_unref(message_loop); return PP_OK; } int32_t ppb_message_loop_post_work_with_result(PP_Resource message_loop, struct PP_CompletionCallback callback, int64_t delay_ms, int32_t result_to_pass, int depth, const char *origin) { if (callback.func == NULL) { trace_error("%s, callback.func == NULL\n", __func__); return PP_ERROR_BADARGUMENT; } struct pp_message_loop_s *ml = pp_resource_acquire(message_loop, PP_RESOURCE_MESSAGE_LOOP); if (!ml) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } // forbid pushing task when message loop is in teardown state, // but only if it's not a browser thread message loop if (message_loop != ppb_message_loop_get_for_browser_thread()) { if (ml->running && ml->teardown) { // message loop is in a teardown state pp_resource_release(message_loop); trace_error("%s, quit request received, no additional work could be posted\n", __func__); return PP_ERROR_FAILED; } } struct message_loop_task_s *task = g_slice_alloc0(sizeof(*task)); task->result_to_pass = result_to_pass; task->ccb = callback; task->depth = depth; task->origin = origin; // calculate absolute time callback should be run at clock_gettime(CLOCK_REALTIME, &task->when); task->when.tv_sec += delay_ms / 1000; task->when.tv_nsec += (delay_ms % 1000) * 1000 * 1000; while (task->when.tv_nsec >= 1000 * 1000 * 1000) { task->when.tv_sec += 1; task->when.tv_nsec -= 1000 * 1000 * 1000; } g_async_queue_push(ml->async_q, task); pp_resource_release(message_loop); return PP_OK; } int32_t ppb_message_loop_post_work(PP_Resource message_loop, struct PP_CompletionCallback callback, int64_t delay_ms) { return ppb_message_loop_post_work_with_result(message_loop, callback, delay_ms, PP_OK, 0, __func__); } int32_t ppb_message_loop_post_quit_depth(PP_Resource message_loop, PP_Bool should_destroy, int depth) { struct pp_message_loop_s *ml = pp_resource_acquire(message_loop, PP_RESOURCE_MESSAGE_LOOP); if (!ml) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } struct message_loop_task_s *task = g_slice_alloc0(sizeof(*task)); task->terminate = 1; task->depth = depth; task->should_destroy_ml = should_destroy; task->result_to_pass = PP_OK; clock_gettime(CLOCK_REALTIME, &task->when); // run as early as possible g_async_queue_push(ml->async_q, task); pp_resource_release(message_loop); return PP_OK; } int32_t ppb_message_loop_post_quit(PP_Resource message_loop, PP_Bool should_destroy) { int depth = ppb_message_loop_get_depth(message_loop); return ppb_message_loop_post_quit_depth(message_loop, should_destroy, depth); } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_message_loop_create(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_message_loop_create(instance); } TRACE_WRAPPER PP_Resource trace_ppb_message_loop_get_for_main_thread(void) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_message_loop_get_for_main_thread(); } TRACE_WRAPPER PP_Resource trace_ppb_message_loop_get_current(void) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_message_loop_get_current(); } TRACE_WRAPPER int32_t trace_ppb_message_loop_attach_to_current_thread(PP_Resource message_loop) { trace_info("[PPB] {full} %s message_loop=%d\n", __func__+6, message_loop); return ppb_message_loop_attach_to_current_thread(message_loop); } TRACE_WRAPPER int32_t trace_ppb_message_loop_run(PP_Resource message_loop) { trace_info("[PPB] {full} %s message_loop=%d\n", __func__+6, message_loop); return ppb_message_loop_run(message_loop); } TRACE_WRAPPER int32_t trace_ppb_message_loop_post_work(PP_Resource message_loop, struct PP_CompletionCallback callback, int64_t delay_ms) { trace_info("[PPB] {full} %s message_loop=%d, callback={.func=%p, .user_data=%p, .flags=%u}, " "delay_ms=%"PRId64"\n", __func__+6, message_loop, callback.func, callback.user_data, callback.flags, delay_ms); return ppb_message_loop_post_work(message_loop, callback, delay_ms); } TRACE_WRAPPER int32_t trace_ppb_message_loop_post_quit(PP_Resource message_loop, PP_Bool should_destroy) { trace_info("[PPB] {full} %s message_loop=%d, should_destroy=%d\n", __func__+6, message_loop, should_destroy); return ppb_message_loop_post_quit(message_loop, should_destroy); } const struct PPB_MessageLoop_1_0 ppb_message_loop_interface_1_0 = { .Create = TWRAPF(ppb_message_loop_create), .GetForMainThread = TWRAPF(ppb_message_loop_get_for_main_thread), .GetCurrent = TWRAPF(ppb_message_loop_get_current), .AttachToCurrentThread = TWRAPF(ppb_message_loop_attach_to_current_thread), .Run = TWRAPF(ppb_message_loop_run), .PostWork = TWRAPF(ppb_message_loop_post_work), .PostQuit = TWRAPF(ppb_message_loop_post_quit), }; static void __attribute__((constructor)) constructor_ppb_message_loop(void) { register_interface(PPB_MESSAGELOOP_INTERFACE_1_0, &ppb_message_loop_interface_1_0); register_resource(PP_RESOURCE_MESSAGE_LOOP, ppb_message_loop_destroy); } freshplayerplugin-0.3.9/src/ppb_message_loop.h000066400000000000000000000052701321746453100215560ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include enum ppb_message_loop_flags_e { ML_NO_FLAGS = 0, ML_NESTED = (1 << 0), ML_INCREASE_DEPTH = (1 << 1), ML_EXIT_ON_EMPTY = (1 << 2), }; PP_Resource ppb_message_loop_create(PP_Instance instance); PP_Resource ppb_message_loop_get_for_main_thread(void); int32_t ppb_message_loop_proclaim_this_thread_main(void); PP_Resource ppb_message_loop_get_for_browser_thread(void); int32_t ppb_message_loop_proclaim_this_thread_browser(void); PP_Resource ppb_message_loop_get_current(void); int ppb_message_loop_get_depth(PP_Resource message_loop); int32_t ppb_message_loop_attach_to_current_thread(PP_Resource message_loop); int32_t ppb_message_loop_run(PP_Resource message_loop); int32_t ppb_message_loop_run_int(PP_Resource message_loop, uint32_t flags); int32_t ppb_message_loop_run_nested(PP_Resource message_loop); int32_t ppb_message_loop_post_work_with_result(PP_Resource message_loop, struct PP_CompletionCallback callback, int64_t delay_ms, int32_t result_to_pass, int depth, const char *origin); int32_t ppb_message_loop_post_work(PP_Resource message_loop, struct PP_CompletionCallback callback, int64_t delay_ms); int32_t ppb_message_loop_post_quit(PP_Resource message_loop, PP_Bool should_destroy); int32_t ppb_message_loop_post_quit_depth(PP_Resource message_loop, PP_Bool should_destroy, int depth); void ppb_message_loop_mark_thread_unsuitable(void); freshplayerplugin-0.3.9/src/ppb_messaging.c000066400000000000000000000071411321746453100210500ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "ppb_messaging.h" #include "trace_core.h" #include "trace_helpers.h" #include #include void ppb_messaging_post_message(PP_Instance instance, struct PP_Var message) { } int32_t ppb_messaging_register_message_handler(PP_Instance instance, void *user_data, const struct PPP_MessageHandler_0_2 *handler, PP_Resource message_loop) { return PP_OK; } void ppb_messaging_unregister_message_handler(PP_Instance instance) { } // trace wrappers TRACE_WRAPPER void trace_ppb_messaging_post_message(PP_Instance instance, struct PP_Var message) { gchar *s_message = trace_var_as_string(message); trace_info("[PPB] {zilch} %s instance=%d, message=%s\n", __func__+6, instance, s_message); g_free(s_message); return ppb_messaging_post_message(instance, message); } TRACE_WRAPPER int32_t trace_ppb_messaging_register_message_handler(PP_Instance instance, void *user_data, const struct PPP_MessageHandler_0_2 *handler, PP_Resource message_loop) { trace_info("[PPB] {zilch} %s instance=%d, user_data=%p, handler={.HandleMessage=%p, " ".HandleBlockingMessage=%p, .Destroy=%p}, message_loop=%d\n", __func__+6, instance, user_data, handler->HandleMessage, handler->HandleBlockingMessage, handler->Destroy, message_loop); return ppb_messaging_register_message_handler(instance, user_data, handler, message_loop); } TRACE_WRAPPER void trace_ppb_messaging_unregister_message_handler(PP_Instance instance) { trace_info("[PPB] {zilch} %s instance=%d\n", __func__+6, instance); return ppb_messaging_unregister_message_handler(instance); } const struct PPB_Messaging_1_2 ppb_messaging_interface_1_2 = { .PostMessage = TWRAPZ(ppb_messaging_post_message), .RegisterMessageHandler = TWRAPZ(ppb_messaging_register_message_handler), .UnregisterMessageHandler = TWRAPZ(ppb_messaging_unregister_message_handler), }; const struct PPB_Messaging_1_0 ppb_messaging_interface_1_0 = { .PostMessage = TWRAPZ(ppb_messaging_post_message), }; static void __attribute__((constructor)) constructor_ppb_messaging(void) { register_interface(PPB_MESSAGING_INTERFACE_1_0, &ppb_messaging_interface_1_0); register_interface(PPB_MESSAGING_INTERFACE_1_2, &ppb_messaging_interface_1_2); } freshplayerplugin-0.3.9/src/ppb_messaging.h000066400000000000000000000031101321746453100210450ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include void ppb_messaging_post_message(PP_Instance instance, struct PP_Var message); int32_t ppb_messaging_register_message_handler(PP_Instance instance, void *user_data, const struct PPP_MessageHandler_0_2 *handler, PP_Resource message_loop); void ppb_messaging_unregister_message_handler(PP_Instance instance); freshplayerplugin-0.3.9/src/ppb_net_address.c000066400000000000000000000515111321746453100213660ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "pp_resource.h" #include "ppb_net_address.h" #include "ppb_var.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include #include #include STATIC_ASSERT(sizeof(struct pp_net_address_s) <= LARGEST_RESOURCE_SIZE); PP_Bool ppb_net_address_private_are_equal(const struct PP_NetAddress_Private *addr1, const struct PP_NetAddress_Private *addr2) { int ret = (addr1->size == addr2->size) && (memcmp(addr1->data, addr2->data, addr1->size) == 0); return ret ? PP_TRUE : PP_FALSE; } PP_Bool ppb_net_address_private_are_hosts_equal(const struct PP_NetAddress_Private *addr1, const struct PP_NetAddress_Private *addr2) { if (addr1->size != addr2->size) return PP_FALSE; if (addr1->size == sizeof(struct sockaddr_in)) { struct sockaddr_in *a1 = (struct sockaddr_in *)addr1->data; struct sockaddr_in *a2 = (struct sockaddr_in *)addr2->data; int res = memcmp(&a1->sin_addr, &a2->sin_addr, sizeof(a1->sin_addr)); return res == 0 ? PP_TRUE : PP_FALSE; } else if (addr1->size == sizeof(struct sockaddr_in6)) { struct sockaddr_in6 *a1 = (struct sockaddr_in6 *)addr1->data; struct sockaddr_in6 *a2 = (struct sockaddr_in6 *)addr2->data; int res = memcmp(&a1->sin6_addr, &a2->sin6_addr, sizeof(a1->sin6_addr)); return res == 0 ? PP_TRUE : PP_FALSE; } else { return PP_FALSE; } } struct PP_Var ppb_net_address_private_describe(PP_Module module, const struct PP_NetAddress_Private *addr, PP_Bool include_port) { (void)module; if (addr->size == sizeof(struct sockaddr_in)) { struct sockaddr_in sai; char *s; uint8_t ip[4]; STATIC_ASSERT(sizeof(ip) == sizeof(sai.sin_addr)); memcpy(&sai, addr->data, sizeof(struct sockaddr_in)); memcpy(ip, &sai.sin_addr, sizeof(ip)); if (include_port) s = g_strdup_printf("%u.%u.%u.%u:%u", ip[0], ip[1], ip[2], ip[3], ntohs(sai.sin_port)); else s = g_strdup_printf("%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]); struct PP_Var var = ppb_var_var_from_utf8_z(s); g_free(s); return var; } else if (addr->size == sizeof(struct sockaddr_in6)) { struct sockaddr_in6 sai6; char *s; uint16_t ip[8]; STATIC_ASSERT(sizeof(ip) == sizeof(sai6.sin6_addr)); memcpy(&sai6, addr->data, sizeof(struct sockaddr_in6)); memcpy(ip, &sai6.sin6_addr, sizeof(ip)); if (include_port) { s = g_strdup_printf("[%x:%x:%x:%x:%x:%x:%x:%x]:%u", ntohs(ip[0]), ntohs(ip[1]), ntohs(ip[2]), ntohs(ip[3]), ntohs(ip[4]), ntohs(ip[5]), ntohs(ip[6]), ntohs(ip[7]), ntohs(sai6.sin6_port)); } else { s = g_strdup_printf("%x:%x:%x:%x:%x:%x:%x:%x", ntohs(ip[0]), ntohs(ip[1]), ntohs(ip[2]), ntohs(ip[3]), ntohs(ip[4]), ntohs(ip[5]), ntohs(ip[6]), ntohs(ip[7])); } struct PP_Var var = ppb_var_var_from_utf8_z(s); g_free(s); return var; } else { return PP_MakeUndefined(); } } PP_Bool ppb_net_address_private_replace_port(const struct PP_NetAddress_Private *src_addr, uint16_t port, struct PP_NetAddress_Private *addr_out) { *addr_out = *src_addr; if (addr_out->size == sizeof(struct sockaddr_in)) { struct sockaddr_in *a = (struct sockaddr_in *)addr_out->data; a->sin_port = htons(port); return PP_TRUE; } else if (addr_out->size == sizeof(struct sockaddr_in6)) { struct sockaddr_in6 *a = (struct sockaddr_in6 *)addr_out->data; a->sin6_port = htons(port); return PP_TRUE; } else { return PP_FALSE; } } void ppb_net_address_private_get_any_address(PP_Bool is_ipv6, struct PP_NetAddress_Private *addr) { if (is_ipv6) { struct sockaddr_in6 a; memset(&a, 0, sizeof(a)); a.sin6_addr = in6addr_any; memcpy(addr->data, &a, sizeof(a)); addr->size = sizeof(a); } else { // ipv4 struct sockaddr_in a; memset(&a, 0, sizeof(a)); a.sin_addr.s_addr = INADDR_ANY; memcpy(addr->data, &a, sizeof(a)); addr->size = sizeof(a); } } PP_NetAddressFamily_Private ppb_net_address_private_get_family(const struct PP_NetAddress_Private *addr) { if (addr->size == sizeof(struct sockaddr_in)) return PP_NETADDRESSFAMILY_PRIVATE_IPV4; else if (addr->size == sizeof(struct sockaddr_in6)) return PP_NETADDRESSFAMILY_PRIVATE_IPV6; else return PP_NETADDRESSFAMILY_PRIVATE_UNSPECIFIED; } uint16_t ppb_net_address_private_get_port(const struct PP_NetAddress_Private *addr) { if (addr->size == sizeof(struct sockaddr_in)) { struct sockaddr_in *a = (struct sockaddr_in *)addr->data; return ntohs(a->sin_port); } else if (addr->size == sizeof(struct sockaddr_in6)) { struct sockaddr_in6 *a = (struct sockaddr_in6 *)addr->data; return ntohs(a->sin6_port); } else { return 0; } } PP_Bool ppb_net_address_private_get_address(const struct PP_NetAddress_Private *addr, void *address, uint16_t address_size) { if (addr->size == sizeof(struct sockaddr_in)) { struct sockaddr_in *a = (struct sockaddr_in *)addr->data; if (address_size >= sizeof(a->sin_addr)) { memcpy(address, &a->sin_addr, sizeof(a->sin_addr)); return PP_TRUE; } } else if (addr->size == sizeof(struct sockaddr_in6)) { struct sockaddr_in6 *a = (struct sockaddr_in6 *)addr->data; if (address_size >= sizeof(a->sin6_addr)) { memcpy(address, &a->sin6_addr, sizeof(a->sin6_addr)); return PP_TRUE; } } return PP_FALSE; } uint32_t ppb_net_address_private_get_scope_id(const struct PP_NetAddress_Private *addr) { if (addr->size == sizeof(struct sockaddr_in6)) { struct sockaddr_in6 sai6; memcpy(&sai6, addr->data, sizeof(sai6)); return ntohl(sai6.sin6_scope_id); } // it's IPv4, function should return 0 return 0; } void ppb_net_address_private_create_from_ipv4_address(const uint8_t ip[4], uint16_t port, struct PP_NetAddress_Private *addr_out) { struct sockaddr_in sai = { .sin_port = htons(port) }; memcpy(&sai.sin_addr, ip, sizeof(sai.sin_addr)); memset(addr_out, 0, sizeof(struct PP_NetAddress_Private)); addr_out->size = sizeof(sai); memcpy(addr_out->data, &sai, sizeof(sai)); } void ppb_net_address_private_create_from_ipv6_address(const uint8_t ip[16], uint32_t scope_id, uint16_t port, struct PP_NetAddress_Private *addr_out) { struct sockaddr_in6 sai6 = { .sin6_port = htons(port), .sin6_scope_id = htonl(scope_id) }; memcpy(&sai6.sin6_addr, ip, sizeof(sai6.sin6_addr)); memset(addr_out, 0, sizeof(struct PP_NetAddress_Private)); addr_out->size = sizeof(sai6); memcpy(addr_out->data, &sai6, sizeof(sai6)); } PP_Resource ppb_net_address_create_from_ipv4_address(PP_Instance instance, const struct PP_NetAddress_IPv4 *ipv4_addr) { if (!ipv4_addr) { trace_error("%s, ipv4_addr == NULL\n", __func__); return 0; } struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource net_address = pp_resource_allocate(PP_RESOURCE_NET_ADDRESS, pp_i); struct pp_net_address_s *na = pp_resource_acquire(net_address, PP_RESOURCE_NET_ADDRESS); if (!na) { trace_error("%s, resource allocation failed\n", __func__); return 0; } ppb_net_address_private_create_from_ipv4_address(ipv4_addr->addr, ntohs(ipv4_addr->port), &na->addr); pp_resource_release(net_address); return net_address; } PP_Resource ppb_net_address_create_from_ipv6_address(PP_Instance instance, const struct PP_NetAddress_IPv6 *ipv6_addr) { if (!ipv6_addr) { trace_error("%s, ipv6_addr == NULL\n", __func__); return 0; } struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource net_address = pp_resource_allocate(PP_RESOURCE_NET_ADDRESS, pp_i); struct pp_net_address_s *na = pp_resource_acquire(net_address, PP_RESOURCE_NET_ADDRESS); if (!na) { trace_error("%s, resource allocation failed\n", __func__); return 0; } ppb_net_address_private_create_from_ipv6_address(ipv6_addr->addr, 0, ntohs(ipv6_addr->port), &na->addr); pp_resource_release(net_address); return net_address; } static void ppb_net_address_destroy(void *ptr) { // nothing to do } PP_Bool ppb_net_address_is_net_address(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_NET_ADDRESS; } PP_NetAddress_Family ppb_net_address_get_family(PP_Resource addr) { struct pp_net_address_s *na = pp_resource_acquire(addr, PP_RESOURCE_NET_ADDRESS); if (!na) { trace_error("%s, bad resource\n", __func__); return PP_NETADDRESS_FAMILY_UNSPECIFIED; } PP_NetAddress_Family family; if (na->addr.size == sizeof(struct sockaddr_in)) family = PP_NETADDRESS_FAMILY_IPV4; else if (na->addr.size == sizeof(struct sockaddr_in6)) family = PP_NETADDRESS_FAMILY_IPV6; else family = PP_NETADDRESS_FAMILY_UNSPECIFIED; pp_resource_release(addr); return family; } struct PP_Var ppb_net_address_describe_as_string(PP_Resource addr, PP_Bool include_port) { struct pp_net_address_s *na = pp_resource_acquire(addr, PP_RESOURCE_NET_ADDRESS); if (!na) { trace_error("%s, bad resource\n", __func__); return PP_MakeUndefined(); } struct PP_Var var = ppb_net_address_private_describe(0, &na->addr, include_port); pp_resource_release(addr); return var; } PP_Bool ppb_net_address_describe_as_ipv4_address(PP_Resource addr, struct PP_NetAddress_IPv4 *ipv4_addr) { if (!ipv4_addr) { trace_error("%s, ipv4_addr == NULL\n", __func__); return PP_FALSE; } struct pp_net_address_s *na = pp_resource_acquire(addr, PP_RESOURCE_NET_ADDRESS); if (!na) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } if (na->addr.size != sizeof(struct sockaddr_in)) { // not ipv4 pp_resource_release(addr); return PP_FALSE; } struct sockaddr_in *sai = (void *)na->addr.data; memcpy(ipv4_addr->addr, &sai->sin_addr, sizeof(sai->sin_addr)); ipv4_addr->port = sai->sin_port; pp_resource_release(addr); return PP_TRUE; } PP_Bool ppb_net_address_describe_as_ipv6_address(PP_Resource addr, struct PP_NetAddress_IPv6 *ipv6_addr) { if (!ipv6_addr) { trace_error("%s, ipv6_addr == NULL\n", __func__); return PP_FALSE; } struct pp_net_address_s *na = pp_resource_acquire(addr, PP_RESOURCE_NET_ADDRESS); if (!na) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } if (na->addr.size != sizeof(struct sockaddr_in6)) { // not ipv6 pp_resource_release(addr); return PP_FALSE; } struct sockaddr_in6 *sai6 = (void *)na->addr.data; memcpy(ipv6_addr->addr, &sai6->sin6_addr, sizeof(sai6->sin6_addr)); ipv6_addr->port = sai6->sin6_port; pp_resource_release(addr); return PP_TRUE; } // trace wrappers TRACE_WRAPPER PP_Bool trace_ppb_net_address_private_are_equal(const struct PP_NetAddress_Private *addr1, const struct PP_NetAddress_Private *addr2) { trace_info("[PPB] {full} %s addr1={%p}, addr2={%p}\n", __func__+6, addr1, addr2); return ppb_net_address_private_are_equal(addr1, addr2); } TRACE_WRAPPER PP_Bool trace_ppb_net_address_private_are_hosts_equal(const struct PP_NetAddress_Private *addr1, const struct PP_NetAddress_Private *addr2) { trace_info("[PPB] {full} %s addr1={%p}, addr2={%p}\n", __func__+6, addr1, addr2); return ppb_net_address_private_are_hosts_equal(addr1, addr2); } TRACE_WRAPPER struct PP_Var trace_ppb_net_address_private_describe(PP_Module module, const struct PP_NetAddress_Private *addr, PP_Bool include_port) { trace_info("[PPB] {full} %s module=%d, addr={%p}, include_port=%u\n", __func__+6, module, addr, include_port); return ppb_net_address_private_describe(module, addr, include_port); } TRACE_WRAPPER PP_Bool trace_ppb_net_address_private_replace_port(const struct PP_NetAddress_Private *src_addr, uint16_t port, struct PP_NetAddress_Private *addr_out) { trace_info("[PPB] {full} %s src_addr={%p}, port=%u\n", __func__+6, src_addr, port); return ppb_net_address_private_replace_port(src_addr, port, addr_out); } TRACE_WRAPPER void trace_ppb_net_address_private_get_any_address(PP_Bool is_ipv6, struct PP_NetAddress_Private *addr) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_net_address_private_get_any_address(is_ipv6, addr); } TRACE_WRAPPER PP_NetAddressFamily_Private trace_ppb_net_address_private_get_family(const struct PP_NetAddress_Private *addr) { trace_info("[PPB] {full} %s addr={%p}\n", __func__+6, addr); return ppb_net_address_private_get_family(addr); } TRACE_WRAPPER uint16_t trace_ppb_net_address_private_get_port(const struct PP_NetAddress_Private *addr) { trace_info("[PPB] {full} %s addr={%p}\n", __func__+6, addr); return ppb_net_address_private_get_port(addr); } TRACE_WRAPPER PP_Bool trace_ppb_net_address_private_get_address(const struct PP_NetAddress_Private *addr, void *address, uint16_t address_size) { trace_info("[PPB] {full} %s addr={%p}, address=%p, address_size=%u\n", __func__+6, addr, address, address_size); return ppb_net_address_private_get_address(addr, address, address_size); } TRACE_WRAPPER uint32_t trace_ppb_net_address_private_get_scope_id(const struct PP_NetAddress_Private *addr) { trace_info("[PPB] {full} %s addr=%p\n", __func__+6, addr); return ppb_net_address_private_get_scope_id(addr); } TRACE_WRAPPER void trace_ppb_net_address_private_create_from_ipv4_address(const uint8_t ip[4], uint16_t port, struct PP_NetAddress_Private *addr_out) { trace_info("[PPB] {full} %s ip=%u.%u.%u.%u, port=%u\n", __func__+6, ip[0], ip[1], ip[2], ip[3], port); return ppb_net_address_private_create_from_ipv4_address(ip, port, addr_out); } TRACE_WRAPPER void trace_ppb_net_address_private_create_from_ipv6_address(const uint8_t ip[16], uint32_t scope_id, uint16_t port, struct PP_NetAddress_Private *addr_out) { trace_info("[PPB] {full} %s ip=[%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:" "%02x%02x], scope_id=%u, port=%u\n", __func__+6, ip[0], ip[1], ip[2], ip[3], ip[4], ip[5], ip[6], ip[7], ip[8], ip[9], ip[10], ip[11], ip[12], ip[13], ip[14], ip[15], scope_id, port); return ppb_net_address_private_create_from_ipv6_address(ip, scope_id, port, addr_out); } TRACE_WRAPPER PP_Resource trace_ppb_net_address_create_from_ipv4_address(PP_Instance instance, const struct PP_NetAddress_IPv4 *ipv4_addr) { gchar *s_ipv4_addr = trace_netaddress_ipv4_as_string(ipv4_addr); trace_info("[PPB] {full} %s instance=%d, ipv4_addr=%s\n", __func__+6, instance, s_ipv4_addr); g_free(s_ipv4_addr); return ppb_net_address_create_from_ipv4_address(instance, ipv4_addr); } TRACE_WRAPPER PP_Resource trace_ppb_net_address_create_from_ipv6_address(PP_Instance instance, const struct PP_NetAddress_IPv6 *ipv6_addr) { gchar *s_ipv6_addr = trace_netaddress_ipv6_as_string(ipv6_addr); trace_info("[PPB] {full} %s instance=%d, ipv6_addr=%s\n", __func__+6, instance, s_ipv6_addr); g_free(s_ipv6_addr); return ppb_net_address_create_from_ipv6_address(instance, ipv6_addr); } TRACE_WRAPPER PP_Bool trace_ppb_net_address_is_net_address(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_net_address_is_net_address(resource); } TRACE_WRAPPER PP_NetAddress_Family trace_ppb_net_address_get_family(PP_Resource addr) { trace_info("[PPB] {full} %s addr=%d\n", __func__+6, addr); return ppb_net_address_get_family(addr); } TRACE_WRAPPER struct PP_Var trace_ppb_net_address_describe_as_string(PP_Resource addr, PP_Bool include_port) { trace_info("[PPB] {full} %s addr=%d, include_port=%u\n", __func__+6, addr, include_port); return ppb_net_address_describe_as_string(addr, include_port); } TRACE_WRAPPER PP_Bool trace_ppb_net_address_describe_as_ipv4_address(PP_Resource addr, struct PP_NetAddress_IPv4 *ipv4_addr) { trace_info("[PPB] {full} %s addr=%d\n", __func__+6, addr); return ppb_net_address_describe_as_ipv4_address(addr, ipv4_addr); } TRACE_WRAPPER PP_Bool trace_ppb_net_address_describe_as_ipv6_address(PP_Resource addr, struct PP_NetAddress_IPv6 *ipv6_addr) { trace_info("[PPB] {full} %s addr=%d\n", __func__+6, addr); return ppb_net_address_describe_as_ipv6_address(addr, ipv6_addr); } const struct PPB_NetAddress_Private_1_1 ppb_net_address_private_interface_1_1 = { .AreEqual = TWRAPF(ppb_net_address_private_are_equal), .AreHostsEqual = TWRAPF(ppb_net_address_private_are_hosts_equal), .Describe = TWRAPF(ppb_net_address_private_describe), .ReplacePort = TWRAPF(ppb_net_address_private_replace_port), .GetAnyAddress = TWRAPF(ppb_net_address_private_get_any_address), .GetFamily = TWRAPF(ppb_net_address_private_get_family), .GetPort = TWRAPF(ppb_net_address_private_get_port), .GetAddress = TWRAPF(ppb_net_address_private_get_address), .GetScopeID = TWRAPF(ppb_net_address_private_get_scope_id), .CreateFromIPv4Address = TWRAPF(ppb_net_address_private_create_from_ipv4_address), .CreateFromIPv6Address = TWRAPF(ppb_net_address_private_create_from_ipv6_address), }; const struct PPB_NetAddress_1_0 ppb_net_address_interface_1_0 = { .CreateFromIPv4Address = TWRAPF(ppb_net_address_create_from_ipv4_address), .CreateFromIPv6Address = TWRAPF(ppb_net_address_create_from_ipv6_address), .IsNetAddress = TWRAPF(ppb_net_address_is_net_address), .GetFamily = TWRAPF(ppb_net_address_get_family), .DescribeAsString = TWRAPF(ppb_net_address_describe_as_string), .DescribeAsIPv4Address = TWRAPF(ppb_net_address_describe_as_ipv4_address), .DescribeAsIPv6Address = TWRAPF(ppb_net_address_describe_as_ipv6_address), }; static void __attribute__((constructor)) constructor_ppb_net_address(void) { register_interface(PPB_NETADDRESS_PRIVATE_INTERFACE_1_1, &ppb_net_address_private_interface_1_1); register_interface(PPB_NETADDRESS_INTERFACE_1_0, &ppb_net_address_interface_1_0); register_resource(PP_RESOURCE_NET_ADDRESS, ppb_net_address_destroy); } freshplayerplugin-0.3.9/src/ppb_net_address.h000066400000000000000000000073611321746453100213770ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include "pp_resource.h" #include #include struct pp_net_address_s { COMMON_STRUCTURE_FIELDS struct PP_NetAddress_Private addr; }; PP_Bool ppb_net_address_private_are_equal(const struct PP_NetAddress_Private *addr1, const struct PP_NetAddress_Private *addr2); PP_Bool ppb_net_address_private_are_hosts_equal(const struct PP_NetAddress_Private *addr1, const struct PP_NetAddress_Private *addr2); struct PP_Var ppb_net_address_private_describe(PP_Module module, const struct PP_NetAddress_Private *addr, PP_Bool include_port); PP_Bool ppb_net_address_private_replace_port(const struct PP_NetAddress_Private *src_addr, uint16_t port, struct PP_NetAddress_Private *addr_out); void ppb_net_address_private_get_any_address(PP_Bool is_ipv6, struct PP_NetAddress_Private *addr); PP_NetAddressFamily_Private ppb_net_address_private_get_family(const struct PP_NetAddress_Private *addr); uint16_t ppb_net_address_private_get_port(const struct PP_NetAddress_Private *addr); PP_Bool ppb_net_address_private_get_address(const struct PP_NetAddress_Private *addr, void *address, uint16_t address_size); uint32_t ppb_net_address_private_get_scope_id(const struct PP_NetAddress_Private *addr); void ppb_net_address_private_create_from_ipv4_address(const uint8_t ip[4], uint16_t port, struct PP_NetAddress_Private *addr_out); void ppb_net_address_private_create_from_ipv6_address(const uint8_t ip[16], uint32_t scope_id, uint16_t port, struct PP_NetAddress_Private *addr_out); PP_Resource ppb_net_address_create_from_ipv4_address(PP_Instance instance, const struct PP_NetAddress_IPv4 *ipv4_addr); PP_Resource ppb_net_address_create_from_ipv6_address(PP_Instance instance, const struct PP_NetAddress_IPv6 *ipv6_addr); PP_Bool ppb_net_address_is_net_address(PP_Resource resource); PP_NetAddress_Family ppb_net_address_get_family(PP_Resource addr); struct PP_Var ppb_net_address_describe_as_string(PP_Resource addr, PP_Bool include_port); PP_Bool ppb_net_address_describe_as_ipv4_address(PP_Resource addr, struct PP_NetAddress_IPv4 *ipv4_addr); PP_Bool ppb_net_address_describe_as_ipv6_address(PP_Resource addr, struct PP_NetAddress_IPv6 *ipv6_addr); freshplayerplugin-0.3.9/src/ppb_network_monitor.c000066400000000000000000000070571321746453100223410ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "pp_resource.h" #include "ppb_network_monitor.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include struct pp_network_monitor_s { COMMON_STRUCTURE_FIELDS }; STATIC_ASSERT(sizeof(struct pp_network_monitor_s) <= LARGEST_RESOURCE_SIZE); PP_Resource ppb_network_monitor_create(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource network_monitor = pp_resource_allocate(PP_RESOURCE_NETWORK_MONITOR, pp_i); return network_monitor; } static void ppb_network_monitor_destroy(void *ptr) { } int32_t ppb_network_monitor_update_network_list(PP_Resource network_monitor, PP_Resource *network_list, struct PP_CompletionCallback callback) { return PP_ERROR_NOACCESS; } PP_Bool ppb_network_monitor_is_network_monitor(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_NETWORK_MONITOR; } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_network_monitor_create(PP_Instance instance) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_network_monitor_create(instance); } TRACE_WRAPPER int32_t trace_ppb_network_monitor_update_network_list(PP_Resource network_monitor, PP_Resource *network_list, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s\n", __func__+6); return ppb_network_monitor_update_network_list(network_monitor, network_list, callback); } TRACE_WRAPPER PP_Bool trace_ppb_network_monitor_is_network_monitor(PP_Resource resource) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_network_monitor_is_network_monitor(resource); } const struct PPB_NetworkMonitor_1_0 ppb_network_monitor_interface_1_0 = { .Create = TWRAPF(ppb_network_monitor_create), .UpdateNetworkList = TWRAPZ(ppb_network_monitor_update_network_list), .IsNetworkMonitor = TWRAPF(ppb_network_monitor_is_network_monitor), }; static void __attribute__((constructor)) constructor_ppb_network_monitor(void) { register_interface(PPB_NETWORKMONITOR_INTERFACE_1_0, &ppb_network_monitor_interface_1_0); register_resource(PP_RESOURCE_NETWORK_MONITOR, ppb_network_monitor_destroy); } freshplayerplugin-0.3.9/src/ppb_network_monitor.h000066400000000000000000000030121321746453100223310ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include PP_Resource ppb_network_monitor_create(PP_Instance instance); int32_t ppb_network_monitor_update_network_list(PP_Resource network_monitor, PP_Resource *network_list, struct PP_CompletionCallback callback); PP_Bool ppb_network_monitor_is_network_monitor(PP_Resource resource); freshplayerplugin-0.3.9/src/ppb_opengles2.c000066400000000000000000003305701321746453100207760ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "pp_resource.h" #include "ppb_graphics3d.h" #include "ppb_opengles2.h" #include "reverse_constant.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include #include #include #include #include #include #include #if !HAVE_GLES2 #include "shader_translator.h" #endif STATIC_ASSERT(sizeof(struct pp_graphics3d_s) <= LARGEST_RESOURCE_SIZE); #define PROLOGUE(g3d, escape_statement) \ struct pp_graphics3d_s *g3d = pp_resource_acquire(context, PP_RESOURCE_GRAPHICS3D); \ if (!g3d) { \ trace_error("%s, bad resource\n", __func__); \ escape_statement; \ } \ pthread_mutex_lock(&display.lock); \ glXMakeCurrent(display.x, g3d->glx_pixmap, g3d->glc) #define EPILOGUE() \ glXMakeCurrent(display.x, None, NULL); \ pthread_mutex_unlock(&display.lock); \ pp_resource_release(context) #if !HAVE_GLES2 static GHashTable *shader_type_ht = NULL; // shader id -> shader type static GHashTable *shader_source_ht = NULL; // shader id -> original shader source #endif static void __attribute__((destructor)) destructor_ppb_opengles2(void) { #if !HAVE_GLES2 if (shader_type_ht) g_hash_table_unref(shader_type_ht); if (shader_source_ht) g_hash_table_unref(shader_source_ht); #endif } void ppb_opengles2_ActiveTexture(PP_Resource context, GLenum texture) { PROLOGUE(g3d, return); glActiveTexture(texture); EPILOGUE(); } void ppb_opengles2_AttachShader(PP_Resource context, GLuint program, GLuint shader) { PROLOGUE(g3d, return); glAttachShader(program, shader); EPILOGUE(); } void ppb_opengles2_BindAttribLocation(PP_Resource context, GLuint program, GLuint index, const char *name) { PROLOGUE(g3d, return); glBindAttribLocation(program, index, name); EPILOGUE(); } void ppb_opengles2_BindBuffer(PP_Resource context, GLenum target, GLuint buffer) { PROLOGUE(g3d, return); glBindBuffer(target, buffer); EPILOGUE(); } void ppb_opengles2_BindFramebuffer(PP_Resource context, GLenum target, GLuint framebuffer) { PROLOGUE(g3d, return); glBindFramebuffer(target, framebuffer); EPILOGUE(); } void ppb_opengles2_BindRenderbuffer(PP_Resource context, GLenum target, GLuint renderbuffer) { PROLOGUE(g3d, return); glBindRenderbuffer(target, renderbuffer); EPILOGUE(); } void ppb_opengles2_BindTexture(PP_Resource context, GLenum target, GLuint texture) { PROLOGUE(g3d, return); glBindTexture(target, texture); EPILOGUE(); } void ppb_opengles2_BlendColor(PP_Resource context, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { PROLOGUE(g3d, return); glBlendColor(red, green, blue, alpha); EPILOGUE(); } void ppb_opengles2_BlendEquation(PP_Resource context, GLenum mode) { PROLOGUE(g3d, return); glBlendEquation(mode); EPILOGUE(); } void ppb_opengles2_BlendEquationSeparate(PP_Resource context, GLenum modeRGB, GLenum modeAlpha) { PROLOGUE(g3d, return); glBlendEquationSeparate(modeRGB, modeAlpha); EPILOGUE(); } void ppb_opengles2_BlendFunc(PP_Resource context, GLenum sfactor, GLenum dfactor) { PROLOGUE(g3d, return); glBlendFunc(sfactor, dfactor); EPILOGUE(); } void ppb_opengles2_BlendFuncSeparate(PP_Resource context, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) { PROLOGUE(g3d, return); glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); EPILOGUE(); } void ppb_opengles2_BufferData(PP_Resource context, GLenum target, GLsizeiptr size, const void *data, GLenum usage) { PROLOGUE(g3d, return); glBufferData(target, size, data, usage); EPILOGUE(); } void ppb_opengles2_BufferSubData(PP_Resource context, GLenum target, GLintptr offset, GLsizeiptr size, const void *data) { PROLOGUE(g3d, return); glBufferSubData(target, offset, size, data); EPILOGUE(); } GLenum ppb_opengles2_CheckFramebufferStatus(PP_Resource context, GLenum target) { PROLOGUE(g3d, return GL_FRAMEBUFFER_UNSUPPORTED); GLenum res = glCheckFramebufferStatus(target); EPILOGUE(); return res; } void ppb_opengles2_Clear(PP_Resource context, GLbitfield mask) { PROLOGUE(g3d, return); glClear(mask); EPILOGUE(); } void ppb_opengles2_ClearColor(PP_Resource context, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { PROLOGUE(g3d, return); glClearColor(red, green, blue, alpha); EPILOGUE(); } void ppb_opengles2_ClearDepthf(PP_Resource context, GLclampf depth) { PROLOGUE(g3d, return); glClearDepthf(depth); EPILOGUE(); } void ppb_opengles2_ClearStencil(PP_Resource context, GLint s) { PROLOGUE(g3d, return); glClearStencil(s); EPILOGUE(); } void ppb_opengles2_ColorMask(PP_Resource context, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { PROLOGUE(g3d, return); glColorMask(red, green, blue, alpha); EPILOGUE(); } void ppb_opengles2_CompileShader(PP_Resource context, GLuint shader) { PROLOGUE(g3d, return); glCompileShader(shader); EPILOGUE(); } void ppb_opengles2_CompressedTexImage2D(PP_Resource context, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data) { PROLOGUE(g3d, return); glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); EPILOGUE(); } void ppb_opengles2_CompressedTexSubImage2D(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data) { PROLOGUE(g3d, return); glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); EPILOGUE(); } void ppb_opengles2_CopyTexImage2D(PP_Resource context, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { PROLOGUE(g3d, return); glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); EPILOGUE(); } void ppb_opengles2_CopyTexSubImage2D(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { PROLOGUE(g3d, return); glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); EPILOGUE(); } GLuint ppb_opengles2_CreateProgram(PP_Resource context) { PROLOGUE(g3d, return 0); GLuint res = glCreateProgram(); EPILOGUE(); return res; } GLuint ppb_opengles2_CreateShader(PP_Resource context, GLenum type) { PROLOGUE(g3d, return 0); GLuint res = glCreateShader(type); #if !HAVE_GLES2 g_hash_table_insert(shader_type_ht, GSIZE_TO_POINTER(res), GSIZE_TO_POINTER(type)); #endif EPILOGUE(); return res; } void ppb_opengles2_CullFace(PP_Resource context, GLenum mode) { PROLOGUE(g3d, return); glCullFace(mode); EPILOGUE(); } void ppb_opengles2_DeleteBuffers(PP_Resource context, GLsizei n, const GLuint *buffers) { PROLOGUE(g3d, return); glDeleteBuffers(n, buffers); EPILOGUE(); } void ppb_opengles2_DeleteFramebuffers(PP_Resource context, GLsizei n, const GLuint *framebuffers) { PROLOGUE(g3d, return); glDeleteFramebuffers(n, framebuffers); EPILOGUE(); } void ppb_opengles2_DeleteProgram(PP_Resource context, GLuint program) { PROLOGUE(g3d, return); glDeleteProgram(program); EPILOGUE(); } void ppb_opengles2_DeleteRenderbuffers(PP_Resource context, GLsizei n, const GLuint *renderbuffers) { PROLOGUE(g3d, return); glDeleteRenderbuffers(n, renderbuffers); EPILOGUE(); } void ppb_opengles2_DeleteShader(PP_Resource context, GLuint shader) { PROLOGUE(g3d, return); glDeleteShader(shader); #if !HAVE_GLES2 g_hash_table_remove(shader_source_ht, GSIZE_TO_POINTER(shader)); g_hash_table_remove(shader_type_ht, GSIZE_TO_POINTER(shader)); #endif EPILOGUE(); } void ppb_opengles2_DeleteTextures(PP_Resource context, GLsizei n, const GLuint *textures) { PROLOGUE(g3d, return); glDeleteTextures(n, textures); EPILOGUE(); } void ppb_opengles2_DepthFunc(PP_Resource context, GLenum func) { PROLOGUE(g3d, return); glDepthFunc(func); EPILOGUE(); } void ppb_opengles2_DepthMask(PP_Resource context, GLboolean flag) { PROLOGUE(g3d, return); glDepthMask(flag); EPILOGUE(); } void ppb_opengles2_DepthRangef(PP_Resource context, GLclampf zNear, GLclampf zFar) { PROLOGUE(g3d, return); glDepthRangef(zNear, zFar); EPILOGUE(); } void ppb_opengles2_DetachShader(PP_Resource context, GLuint program, GLuint shader) { PROLOGUE(g3d, return); glDetachShader(program, shader); EPILOGUE(); } void ppb_opengles2_Disable(PP_Resource context, GLenum cap) { PROLOGUE(g3d, return); glDisable(cap); EPILOGUE(); } void ppb_opengles2_DisableVertexAttribArray(PP_Resource context, GLuint index) { PROLOGUE(g3d, return); glDisableVertexAttribArray(index); EPILOGUE(); } void ppb_opengles2_DrawArrays(PP_Resource context, GLenum mode, GLint first, GLsizei count) { PROLOGUE(g3d, return); glDrawArrays(mode, first, count); EPILOGUE(); } void ppb_opengles2_DrawElements(PP_Resource context, GLenum mode, GLsizei count, GLenum type, const void *indices) { PROLOGUE(g3d, return); glDrawElements(mode, count, type, indices); EPILOGUE(); } void ppb_opengles2_Enable(PP_Resource context, GLenum cap) { PROLOGUE(g3d, return); glEnable(cap); EPILOGUE(); } void ppb_opengles2_EnableVertexAttribArray(PP_Resource context, GLuint index) { PROLOGUE(g3d, return); glEnableVertexAttribArray(index); EPILOGUE(); } void ppb_opengles2_Finish(PP_Resource context) { PROLOGUE(g3d, return); glFinish(); EPILOGUE(); } void ppb_opengles2_Flush(PP_Resource context) { PROLOGUE(g3d, return); glFlush(); EPILOGUE(); } void ppb_opengles2_FramebufferRenderbuffer(PP_Resource context, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) { PROLOGUE(g3d, return); glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer); EPILOGUE(); } void ppb_opengles2_FramebufferTexture2D(PP_Resource context, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { PROLOGUE(g3d, return); glFramebufferTexture2D(target, attachment, textarget, texture, level); EPILOGUE(); } void ppb_opengles2_FrontFace(PP_Resource context, GLenum mode) { PROLOGUE(g3d, return); glFrontFace(mode); EPILOGUE(); } void ppb_opengles2_GenBuffers(PP_Resource context, GLsizei n, GLuint *buffers) { PROLOGUE(g3d, return); glGenBuffers(n, buffers); EPILOGUE(); } void ppb_opengles2_GenerateMipmap(PP_Resource context, GLenum target) { PROLOGUE(g3d, return); glGenerateMipmap(target); EPILOGUE(); } void ppb_opengles2_GenFramebuffers(PP_Resource context, GLsizei n, GLuint *framebuffers) { PROLOGUE(g3d, return); glGenFramebuffers(n, framebuffers); EPILOGUE(); } void ppb_opengles2_GenRenderbuffers(PP_Resource context, GLsizei n, GLuint *renderbuffers) { PROLOGUE(g3d, return); glGenRenderbuffers(n, renderbuffers); EPILOGUE(); } void ppb_opengles2_GenTextures(PP_Resource context, GLsizei n, GLuint *textures) { PROLOGUE(g3d, return); glGenTextures(n, textures); EPILOGUE(); } void ppb_opengles2_GetActiveAttrib(PP_Resource context, GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name) { PROLOGUE(g3d, return); glGetActiveAttrib(program, index, bufsize, length, size, type, name); EPILOGUE(); } void ppb_opengles2_GetActiveUniform(PP_Resource context, GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name) { PROLOGUE(g3d, return); glGetActiveUniform(program, index, bufsize, length, size, type, name); EPILOGUE(); } void ppb_opengles2_GetAttachedShaders(PP_Resource context, GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders) { PROLOGUE(g3d, return); glGetAttachedShaders(program, maxcount, count, shaders); EPILOGUE(); } GLint ppb_opengles2_GetAttribLocation(PP_Resource context, GLuint program, const char *name) { PROLOGUE(g3d, return 0); GLint res = glGetAttribLocation(program, name); EPILOGUE(); return res; } void ppb_opengles2_GetBooleanv(PP_Resource context, GLenum pname, GLboolean *params) { PROLOGUE(g3d, return); glGetBooleanv(pname, params); EPILOGUE(); } void ppb_opengles2_GetBufferParameteriv(PP_Resource context, GLenum target, GLenum pname, GLint *params) { PROLOGUE(g3d, return); glGetBufferParameteriv(target, pname, params); EPILOGUE(); } GLenum ppb_opengles2_GetError(PP_Resource context) { PROLOGUE(g3d, return GL_NO_ERROR); GLenum res = glGetError(); EPILOGUE(); return res; } void ppb_opengles2_GetFloatv(PP_Resource context, GLenum pname, GLfloat *params) { PROLOGUE(g3d, return); glGetFloatv(pname, params); EPILOGUE(); } void ppb_opengles2_GetFramebufferAttachmentParameteriv(PP_Resource context, GLenum target, GLenum attachment, GLenum pname, GLint *params) { PROLOGUE(g3d, return); glGetFramebufferAttachmentParameteriv(target, attachment, pname, params); EPILOGUE(); } void ppb_opengles2_GetIntegerv(PP_Resource context, GLenum pname, GLint *params) { PROLOGUE(g3d, return); glGetIntegerv(pname, params); EPILOGUE(); } void ppb_opengles2_GetProgramiv(PP_Resource context, GLuint program, GLenum pname, GLint *params) { PROLOGUE(g3d, return); glGetProgramiv(program, pname, params); EPILOGUE(); } void ppb_opengles2_GetProgramInfoLog(PP_Resource context, GLuint program, GLsizei bufsize, GLsizei *length, char *infolog) { PROLOGUE(g3d, return); glGetProgramInfoLog(program, bufsize, length, infolog); EPILOGUE(); } void ppb_opengles2_GetRenderbufferParameteriv(PP_Resource context, GLenum target, GLenum pname, GLint *params) { PROLOGUE(g3d, return); glGetRenderbufferParameteriv(target, pname, params); EPILOGUE(); } void ppb_opengles2_GetShaderiv(PP_Resource context, GLuint shader, GLenum pname, GLint *params) { PROLOGUE(g3d, return); #if HAVE_GLES2 glGetShaderiv(shader, pname, params); #else if (pname == GL_SHADER_SOURCE_LENGTH) { char *s = g_hash_table_lookup(shader_source_ht, GSIZE_TO_POINTER(shader)); size_t len = s ? strlen(s) : 0; if (params) params[0] = len; } else { glGetShaderiv(shader, pname, params); } #endif EPILOGUE(); } void ppb_opengles2_GetShaderInfoLog(PP_Resource context, GLuint shader, GLsizei bufsize, GLsizei *length, char *infolog) { PROLOGUE(g3d, return); glGetShaderInfoLog(shader, bufsize, length, infolog); EPILOGUE(); } void ppb_opengles2_GetShaderPrecisionFormat(PP_Resource context, GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision) { PROLOGUE(g3d, return); glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision); EPILOGUE(); } void ppb_opengles2_GetShaderSource(PP_Resource context, GLuint shader, GLsizei bufsize, GLsizei *length, char *source) { PROLOGUE(g3d, return); #if HAVE_GLES2 glGetShaderSource(shader, bufsize, length, source); #else GLsizei len; char *s = g_hash_table_lookup(shader_source_ht, GSIZE_TO_POINTER(shader)); if (!s) { len = 0; goto done; } len = strlen(s); // if shader source is too big, copy only what could be fit into a buffer if (len + 1 > bufsize) len = bufsize - 1; memcpy(source, s, len); source[len] = '\0'; done: if (length) *length = len; #endif EPILOGUE(); } const GLubyte * ppb_opengles2_GetString(PP_Resource context, GLenum name) { PROLOGUE(g3d, return (const GLubyte *)""); const GLubyte *res = glGetString(name); EPILOGUE(); return res; } void ppb_opengles2_GetTexParameterfv(PP_Resource context, GLenum target, GLenum pname, GLfloat *params) { PROLOGUE(g3d, return); glGetTexParameterfv(target, pname, params); EPILOGUE(); } void ppb_opengles2_GetTexParameteriv(PP_Resource context, GLenum target, GLenum pname, GLint *params) { PROLOGUE(g3d, return); glGetTexParameteriv(target, pname, params); EPILOGUE(); } void ppb_opengles2_GetUniformfv(PP_Resource context, GLuint program, GLint location, GLfloat *params) { PROLOGUE(g3d, return); glGetUniformfv(program, location, params); EPILOGUE(); } void ppb_opengles2_GetUniformiv(PP_Resource context, GLuint program, GLint location, GLint *params) { PROLOGUE(g3d, return); glGetUniformiv(program, location, params); EPILOGUE(); } GLint ppb_opengles2_GetUniformLocation(PP_Resource context, GLuint program, const char *name) { PROLOGUE(g3d, return 0); GLint res = glGetUniformLocation(program, name); EPILOGUE(); return res; } void ppb_opengles2_GetVertexAttribfv(PP_Resource context, GLuint index, GLenum pname, GLfloat *params) { PROLOGUE(g3d, return); glGetVertexAttribfv(index, pname, params); EPILOGUE(); } void ppb_opengles2_GetVertexAttribiv(PP_Resource context, GLuint index, GLenum pname, GLint *params) { PROLOGUE(g3d, return); glGetVertexAttribiv(index, pname, params); EPILOGUE(); } void ppb_opengles2_GetVertexAttribPointerv(PP_Resource context, GLuint index, GLenum pname, void **pointer) { PROLOGUE(g3d, return); glGetVertexAttribPointerv(index, pname, pointer); EPILOGUE(); } void ppb_opengles2_Hint(PP_Resource context, GLenum target, GLenum mode) { PROLOGUE(g3d, return); glHint(target, mode); EPILOGUE(); } GLboolean ppb_opengles2_IsBuffer(PP_Resource context, GLuint buffer) { PROLOGUE(g3d, return GL_FALSE); GLboolean res = glIsBuffer(buffer); EPILOGUE(); return res; } GLboolean ppb_opengles2_IsEnabled(PP_Resource context, GLenum cap) { PROLOGUE(g3d, return GL_FALSE); GLboolean res = glIsEnabled(cap); EPILOGUE(); return res; } GLboolean ppb_opengles2_IsFramebuffer(PP_Resource context, GLuint framebuffer) { PROLOGUE(g3d, return GL_FALSE); GLboolean res = glIsFramebuffer(framebuffer); EPILOGUE(); return res; } GLboolean ppb_opengles2_IsProgram(PP_Resource context, GLuint program) { PROLOGUE(g3d, return GL_FALSE); GLboolean res = glIsProgram(program); EPILOGUE(); return res; } GLboolean ppb_opengles2_IsRenderbuffer(PP_Resource context, GLuint renderbuffer) { PROLOGUE(g3d, return GL_FALSE); GLboolean res = glIsRenderbuffer(renderbuffer); EPILOGUE(); return res; } GLboolean ppb_opengles2_IsShader(PP_Resource context, GLuint shader) { PROLOGUE(g3d, return GL_FALSE); GLboolean res = glIsShader(shader); EPILOGUE(); return res; } GLboolean ppb_opengles2_IsTexture(PP_Resource context, GLuint texture) { PROLOGUE(g3d, return GL_FALSE); GLboolean res = glIsTexture(texture); EPILOGUE(); return res; } void ppb_opengles2_LineWidth(PP_Resource context, GLfloat width) { PROLOGUE(g3d, return); glLineWidth(width); EPILOGUE(); } void ppb_opengles2_LinkProgram(PP_Resource context, GLuint program) { PROLOGUE(g3d, return); glLinkProgram(program); EPILOGUE(); } void ppb_opengles2_PixelStorei(PP_Resource context, GLenum pname, GLint param) { PROLOGUE(g3d, return); glPixelStorei(pname, param); EPILOGUE(); } void ppb_opengles2_PolygonOffset(PP_Resource context, GLfloat factor, GLfloat units) { PROLOGUE(g3d, return); glPolygonOffset(factor, units); EPILOGUE(); } void ppb_opengles2_ReadPixels(PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels) { PROLOGUE(g3d, return); glReadPixels(x, y, width, height, format, type, pixels); EPILOGUE(); } void ppb_opengles2_ReleaseShaderCompiler(PP_Resource context) { PROLOGUE(g3d, return); glReleaseShaderCompiler(); EPILOGUE(); } void ppb_opengles2_RenderbufferStorage(PP_Resource context, GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { PROLOGUE(g3d, return); glRenderbufferStorage(target, internalformat, width, height); EPILOGUE(); } void ppb_opengles2_SampleCoverage(PP_Resource context, GLclampf value, GLboolean invert) { PROLOGUE(g3d, return); glSampleCoverage(value, invert); EPILOGUE(); } void ppb_opengles2_Scissor(PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height) { PROLOGUE(g3d, return); glScissor(x, y, width, height); EPILOGUE(); } void ppb_opengles2_ShaderBinary(PP_Resource context, GLsizei n, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length) { PROLOGUE(g3d, return); #if !HAVE_GLES2 trace_error("%s, glShaderBinary is not supported yet, beware unexpected behavior\n", __func__); #endif glShaderBinary(n, shaders, binaryformat, binary, length); EPILOGUE(); } #if !HAVE_GLES2 static char * combine_shader_source_parts(GLsizei count, const char **str, const GLint *length) { GString *res = g_string_new(NULL); for (GLsizei k = 0; k < count; k ++) { if (length) res = g_string_append_len(res, str[k], length[k]); else res = g_string_append(res, str[k]); } return g_string_free(res, FALSE); } #endif void ppb_opengles2_ShaderSource(PP_Resource context, GLuint shader, GLsizei count, const char **str, const GLint *length) { PROLOGUE(g3d, return); #if HAVE_GLES2 glShaderSource(shader, count, str, length); #else GLenum type = GPOINTER_TO_SIZE(g_hash_table_lookup(shader_type_ht, GSIZE_TO_POINTER(shader))); // save combined body char *body = combine_shader_source_parts(count, str, length); g_hash_table_insert(shader_source_ht, GSIZE_TO_POINTER(shader), body); // provide GL function with translated shader body char *translated_body = translate_shader(type, body); glShaderSource(shader, 1, (const char **)&translated_body, NULL); g_free(translated_body); #endif EPILOGUE(); } void ppb_opengles2_StencilFunc(PP_Resource context, GLenum func, GLint ref, GLuint mask) { PROLOGUE(g3d, return); glStencilFunc(func, ref, mask); EPILOGUE(); } void ppb_opengles2_StencilFuncSeparate(PP_Resource context, GLenum face, GLenum func, GLint ref, GLuint mask) { PROLOGUE(g3d, return); glStencilFuncSeparate(face, func, ref, mask); EPILOGUE(); } void ppb_opengles2_StencilMask(PP_Resource context, GLuint mask) { PROLOGUE(g3d, return); glStencilMask(mask); EPILOGUE(); } void ppb_opengles2_StencilMaskSeparate(PP_Resource context, GLenum face, GLuint mask) { PROLOGUE(g3d, return); glStencilMaskSeparate(face, mask); EPILOGUE(); } void ppb_opengles2_StencilOp(PP_Resource context, GLenum fail, GLenum zfail, GLenum zpass) { PROLOGUE(g3d, return); glStencilOp(fail, zfail, zpass); EPILOGUE(); } void ppb_opengles2_StencilOpSeparate(PP_Resource context, GLenum face, GLenum fail, GLenum zfail, GLenum zpass) { PROLOGUE(g3d, return); glStencilOpSeparate(face, fail, zfail, zpass); EPILOGUE(); } void ppb_opengles2_TexImage2D(PP_Resource context, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels) { PROLOGUE(g3d, return); glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); EPILOGUE(); } void ppb_opengles2_TexParameterf(PP_Resource context, GLenum target, GLenum pname, GLfloat param) { PROLOGUE(g3d, return); glTexParameterf(target, pname, param); EPILOGUE(); } void ppb_opengles2_TexParameterfv(PP_Resource context, GLenum target, GLenum pname, const GLfloat *params) { PROLOGUE(g3d, return); glTexParameterfv(target, pname, params); EPILOGUE(); } void ppb_opengles2_TexParameteri(PP_Resource context, GLenum target, GLenum pname, GLint param) { PROLOGUE(g3d, return); glTexParameteri(target, pname, param); EPILOGUE(); } void ppb_opengles2_TexParameteriv(PP_Resource context, GLenum target, GLenum pname, const GLint *params) { PROLOGUE(g3d, return); glTexParameteriv(target, pname, params); EPILOGUE(); } void ppb_opengles2_TexSubImage2D(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels) { PROLOGUE(g3d, return); glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); EPILOGUE(); } void ppb_opengles2_Uniform1f(PP_Resource context, GLint location, GLfloat x) { PROLOGUE(g3d, return); glUniform1f(location, x); EPILOGUE(); } void ppb_opengles2_Uniform1fv(PP_Resource context, GLint location, GLsizei count, const GLfloat *v) { PROLOGUE(g3d, return); glUniform1fv(location, count, v); EPILOGUE(); } void ppb_opengles2_Uniform1i(PP_Resource context, GLint location, GLint x) { PROLOGUE(g3d, return); glUniform1i(location, x); EPILOGUE(); } void ppb_opengles2_Uniform1iv(PP_Resource context, GLint location, GLsizei count, const GLint *v) { PROLOGUE(g3d, return); glUniform1iv(location, count, v); EPILOGUE(); } void ppb_opengles2_Uniform2f(PP_Resource context, GLint location, GLfloat x, GLfloat y) { PROLOGUE(g3d, return); glUniform2f(location, x, y); EPILOGUE(); } void ppb_opengles2_Uniform2fv(PP_Resource context, GLint location, GLsizei count, const GLfloat *v) { PROLOGUE(g3d, return); glUniform2fv(location, count, v); EPILOGUE(); } void ppb_opengles2_Uniform2i(PP_Resource context, GLint location, GLint x, GLint y) { PROLOGUE(g3d, return); glUniform2i(location, x, y); EPILOGUE(); } void ppb_opengles2_Uniform2iv(PP_Resource context, GLint location, GLsizei count, const GLint *v) { PROLOGUE(g3d, return); glUniform2iv(location, count, v); EPILOGUE(); } void ppb_opengles2_Uniform3f(PP_Resource context, GLint location, GLfloat x, GLfloat y, GLfloat z) { PROLOGUE(g3d, return); glUniform3f(location, x, y, z); EPILOGUE(); } void ppb_opengles2_Uniform3fv(PP_Resource context, GLint location, GLsizei count, const GLfloat *v) { PROLOGUE(g3d, return); glUniform3fv(location, count, v); EPILOGUE(); } void ppb_opengles2_Uniform3i(PP_Resource context, GLint location, GLint x, GLint y, GLint z) { PROLOGUE(g3d, return); glUniform3i(location, x, y, z); EPILOGUE(); } void ppb_opengles2_Uniform3iv(PP_Resource context, GLint location, GLsizei count, const GLint *v) { PROLOGUE(g3d, return); glUniform3iv(location, count, v); EPILOGUE(); } void ppb_opengles2_Uniform4f(PP_Resource context, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { PROLOGUE(g3d, return); glUniform4f(location, x, y, z, w); EPILOGUE(); } void ppb_opengles2_Uniform4fv(PP_Resource context, GLint location, GLsizei count, const GLfloat *v) { PROLOGUE(g3d, return); glUniform4fv(location, count, v); EPILOGUE(); } void ppb_opengles2_Uniform4i(PP_Resource context, GLint location, GLint x, GLint y, GLint z, GLint w) { PROLOGUE(g3d, return); glUniform4i(location, x, y, z, w); EPILOGUE(); } void ppb_opengles2_Uniform4iv(PP_Resource context, GLint location, GLsizei count, const GLint *v) { PROLOGUE(g3d, return); glUniform4iv(location, count, v); EPILOGUE(); } void ppb_opengles2_UniformMatrix2fv(PP_Resource context, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { PROLOGUE(g3d, return); glUniformMatrix2fv(location, count, transpose, value); EPILOGUE(); } void ppb_opengles2_UniformMatrix3fv(PP_Resource context, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { PROLOGUE(g3d, return); glUniformMatrix3fv(location, count, transpose, value); EPILOGUE(); } void ppb_opengles2_UniformMatrix4fv(PP_Resource context, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { PROLOGUE(g3d, return); glUniformMatrix4fv(location, count, transpose, value); EPILOGUE(); } void ppb_opengles2_UseProgram(PP_Resource context, GLuint program) { PROLOGUE(g3d, return); glUseProgram(program); EPILOGUE(); } void ppb_opengles2_ValidateProgram(PP_Resource context, GLuint program) { PROLOGUE(g3d, return); glValidateProgram(program); EPILOGUE(); } void ppb_opengles2_VertexAttrib1f(PP_Resource context, GLuint indx, GLfloat x) { PROLOGUE(g3d, return); glVertexAttrib1f(indx, x); EPILOGUE(); } void ppb_opengles2_VertexAttrib1fv(PP_Resource context, GLuint indx, const GLfloat *values) { PROLOGUE(g3d, return); glVertexAttrib1fv(indx, values); EPILOGUE(); } void ppb_opengles2_VertexAttrib2f(PP_Resource context, GLuint indx, GLfloat x, GLfloat y) { PROLOGUE(g3d, return); glVertexAttrib2f(indx, x, y); EPILOGUE(); } void ppb_opengles2_VertexAttrib2fv(PP_Resource context, GLuint indx, const GLfloat *values) { PROLOGUE(g3d, return); glVertexAttrib2fv(indx, values); EPILOGUE(); } void ppb_opengles2_VertexAttrib3f(PP_Resource context, GLuint indx, GLfloat x, GLfloat y, GLfloat z) { PROLOGUE(g3d, return); glVertexAttrib3f(indx, x, y, z); EPILOGUE(); } void ppb_opengles2_VertexAttrib3fv(PP_Resource context, GLuint indx, const GLfloat *values) { PROLOGUE(g3d, return); glVertexAttrib3fv(indx, values); EPILOGUE(); } void ppb_opengles2_VertexAttrib4f(PP_Resource context, GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { PROLOGUE(g3d, return); glVertexAttrib4f(indx, x, y, z, w); EPILOGUE(); } void ppb_opengles2_VertexAttrib4fv(PP_Resource context, GLuint indx, const GLfloat *values) { PROLOGUE(g3d, return); glVertexAttrib4fv(indx, values); EPILOGUE(); } void ppb_opengles2_VertexAttribPointer(PP_Resource context, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *ptr) { PROLOGUE(g3d, return); glVertexAttribPointer(indx, size, type, normalized, stride, ptr); EPILOGUE(); } void ppb_opengles2_Viewport(PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height) { PROLOGUE(g3d, return); glViewport(x, y, width, height); EPILOGUE(); } GLboolean ppb_opengles2_chromium_enable_feature_enable_feature_chromium(PP_Resource context, const char *feature) { return PP_FALSE; } void * ppb_opengles2_chromium_map_sub_map_buffer_sub_data_chromium(PP_Resource context, GLuint target, GLintptr offset, GLsizeiptr size, GLenum access) { return NULL; } void ppb_opengles2_chromium_map_sub_unmap_buffer_sub_data_chromium(PP_Resource context, const void *mem) { } struct tex_sub_mapping_param_s { GLint level; GLint xoffset; GLint yoffset; GLsizei width; GLsizei height; GLenum format; GLenum type; GLenum access; }; void * ppb_opengles2_chromium_map_sub_map_tex_sub_image_2d_chromium(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLenum access) { if (target != GL_TEXTURE_2D || level != 0 || access != GL_WRITE_ONLY_OES) { trace_error("%s, bad arguments\n", __func__); return NULL; } struct pp_graphics3d_s *g3d = pp_resource_acquire(context, PP_RESOURCE_GRAPHICS3D); if (!g3d) { trace_error("%s, bad resource\n", __func__); return NULL; } struct tex_sub_mapping_param_s *map_params = g_slice_alloc(sizeof(*map_params)); map_params->level = level; map_params->xoffset = xoffset; map_params->yoffset = yoffset; map_params->width = width; map_params->height = height; map_params->format = format; map_params->type = type; map_params->access = access; int bytes_per_pixel = (GL_RGB == format) ? 3 : 4; void *res = malloc(width * height * bytes_per_pixel); g_hash_table_insert(g3d->sub_maps, res, map_params); pp_resource_release(context); return res; } void ppb_opengles2_chromium_map_sub_unmap_tex_sub_image_2d_chromium(PP_Resource context, const void *mem) { PROLOGUE(g3d, return); struct tex_sub_mapping_param_s *mp = g_hash_table_lookup(g3d->sub_maps, mem); if (!mp) { trace_error("%s, memory was not mapped\n", __func__); goto err; } g_hash_table_remove(g3d->sub_maps, mem); glTexSubImage2D(GL_TEXTURE_2D, mp->level, mp->xoffset, mp->yoffset, mp->width, mp->height, mp->format, mp->type, mem); g_slice_free(struct tex_sub_mapping_param_s, mp); free((void *)mem); err: EPILOGUE(); } void ppb_opengles2_framebuffer_blit_blit_framebuffer_ext(PP_Resource context, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) { } void ppb_opengles2_framebuffer_multisample_renderbuffer_storage_multisample_ext (PP_Resource context, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) { } void ppb_opengles2_instanced_arrays_draw_arrays_instanced_angle(PP_Resource context, GLenum mode, GLint first, GLsizei count, GLsizei primcount) { } void ppb_opengles2_instanced_arrays_draw_elements_instanced_angle(PP_Resource context, GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount) { } void ppb_opengles2_instanced_arrays_vertex_attrib_divisor_angle(PP_Resource context, GLuint index, GLuint divisor) { } void ppb_opengles2_query_gen_queries_ext(PP_Resource context, GLsizei n, GLuint *queries) { } void ppb_opengles2_query_delete_queries_ext(PP_Resource context, GLsizei n, const GLuint *queries) { } GLboolean ppb_opengles2_query_is_query_ext(PP_Resource context, GLuint id) { return PP_TRUE; } void ppb_opengles2_query_begin_query_ext(PP_Resource context, GLenum target, GLuint id) { } void ppb_opengles2_query_end_query_ext(PP_Resource context, GLenum target) { } void ppb_opengles2_query_get_queryiv_ext(PP_Resource context, GLenum target, GLenum pname, GLint *params) { } void ppb_opengles2_query_get_query_objectuiv_ext(PP_Resource context, GLuint id, GLenum pname, GLuint *params) { } // trace wrappers TRACE_WRAPPER void trace_ppb_opengles2_ActiveTexture(PP_Resource context, GLenum texture) { trace_info("[PPB] {full} %s context=%d, texture=%u(%s)\n", __func__+6, context, texture, reverse_gl_enum(texture)); ppb_opengles2_ActiveTexture(context, texture); } TRACE_WRAPPER void trace_ppb_opengles2_AttachShader(PP_Resource context, GLuint program, GLuint shader) { trace_info("[PPB] {full} %s context=%d, program=%d, shader=%d\n", __func__+6, context, program, shader); ppb_opengles2_AttachShader(context, program, shader); } TRACE_WRAPPER void trace_ppb_opengles2_BindAttribLocation(PP_Resource context, GLuint program, GLuint index, const char *name) { trace_info("[PPB] {full} %s context=%d, program=%d, index=%d, name=%s\n", __func__+6, context, program, index, name); ppb_opengles2_BindAttribLocation(context, program, index, name); } TRACE_WRAPPER void trace_ppb_opengles2_BindBuffer(PP_Resource context, GLenum target, GLuint buffer) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), buffer=%u\n", __func__+6, context, target, reverse_gl_enum(target), buffer); ppb_opengles2_BindBuffer(context, target, buffer); } TRACE_WRAPPER void trace_ppb_opengles2_BindFramebuffer(PP_Resource context, GLenum target, GLuint framebuffer) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), framebuffer=%u\n", __func__+6, context, target, reverse_gl_enum(target), framebuffer); ppb_opengles2_BindFramebuffer(context, target, framebuffer); } TRACE_WRAPPER void trace_ppb_opengles2_BindRenderbuffer(PP_Resource context, GLenum target, GLuint renderbuffer) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), renderbuffer=%u\n", __func__+6, context, target, reverse_gl_enum(target), renderbuffer); ppb_opengles2_BindRenderbuffer(context, target, renderbuffer); } TRACE_WRAPPER void trace_ppb_opengles2_BindTexture(PP_Resource context, GLenum target, GLuint texture) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), texture=%u\n", __func__+6, context, target, reverse_gl_enum(target), texture); ppb_opengles2_BindTexture(context, target, texture); } TRACE_WRAPPER void trace_ppb_opengles2_BlendColor(PP_Resource context, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { trace_info("[PPB] {full} %s context=%d, red=%f, green=%f, blue=%f, alpha=%f\n", __func__+6, context, red, green, blue, alpha); ppb_opengles2_BlendColor(context, red, green, blue, alpha); } TRACE_WRAPPER void trace_ppb_opengles2_BlendEquation(PP_Resource context, GLenum mode) { trace_info("[PPB] {full} %s context=%d, mode=%u(%s)\n", __func__+6, context, mode, reverse_gl_enum(mode)); ppb_opengles2_BlendEquation(context, mode); } TRACE_WRAPPER void trace_ppb_opengles2_BlendEquationSeparate(PP_Resource context, GLenum modeRGB, GLenum modeAlpha) { trace_info("[PPB] {full} %s context=%d, modeRGB=%u(%s), modeAlpha=%u(%s)\n", __func__+6, context, modeRGB, reverse_gl_enum(modeRGB), modeAlpha, reverse_gl_enum(modeAlpha)); ppb_opengles2_BlendEquationSeparate(context, modeRGB, modeAlpha); } TRACE_WRAPPER void trace_ppb_opengles2_BlendFunc(PP_Resource context, GLenum sfactor, GLenum dfactor) { trace_info("[PPB] {full} %s context=%d, sfactor=%u(%s), dfactor=%u(%s)\n", __func__+6, context, sfactor, reverse_gl_enum(sfactor), dfactor, reverse_gl_enum(dfactor)); ppb_opengles2_BlendFunc(context, sfactor, dfactor); } TRACE_WRAPPER void trace_ppb_opengles2_BlendFuncSeparate(PP_Resource context, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) { trace_info("[PPB] {full} %s context=%d, srcRGB=%u(%s), dstRGB=%u(%s), srcAlpha=%u(%s), " "dstAlpha=%u(%s)\n", __func__+6, context, srcRGB, reverse_gl_enum(srcRGB), dstRGB, reverse_gl_enum(dstRGB), srcAlpha, reverse_gl_enum(srcAlpha), dstAlpha, reverse_gl_enum(dstAlpha)); ppb_opengles2_BlendFuncSeparate(context, srcRGB, dstRGB, srcAlpha, dstAlpha); } TRACE_WRAPPER void trace_ppb_opengles2_BufferData(PP_Resource context, GLenum target, GLsizeiptr size, const void *data, GLenum usage) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), size=%ld, data=%p, usage=%u(%s)\n", __func__+6, context, target, reverse_gl_enum(target), (long int)size, data, usage, reverse_gl_enum(usage)); ppb_opengles2_BufferData(context, target, size, data, usage); } TRACE_WRAPPER void trace_ppb_opengles2_BufferSubData(PP_Resource context, GLenum target, GLintptr offset, GLsizeiptr size, const void *data) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), offset=%ld, size=%ld, data=%p\n", __func__+6, context, target, reverse_gl_enum(target), (long)offset, (long)size, data); ppb_opengles2_BufferSubData(context, target, offset, size, data); } TRACE_WRAPPER GLenum trace_ppb_opengles2_CheckFramebufferStatus(PP_Resource context, GLenum target) { trace_info("[PPB] {full} %s context=%d, target=%u(%s)\n", __func__+6, context, target, reverse_gl_enum(target)); return ppb_opengles2_CheckFramebufferStatus(context, target); } TRACE_WRAPPER void trace_ppb_opengles2_Clear(PP_Resource context, GLbitfield mask) { trace_info("[PPB] {full} %s context=%d, mask=0x%x\n", __func__+6, context, mask); ppb_opengles2_Clear(context, mask); } TRACE_WRAPPER void trace_ppb_opengles2_ClearColor(PP_Resource context, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { trace_info("[PPB] {full} %s context=%d, red=%f, green=%f, blue=%f, alpha=%f\n", __func__+6, context, red, green, blue, alpha); ppb_opengles2_ClearColor(context, red, green, blue, alpha); } TRACE_WRAPPER void trace_ppb_opengles2_ClearDepthf(PP_Resource context, GLclampf depth) { trace_info("[PPB] {full} %s context=%d, depth=%f\n", __func__+6, context, depth); ppb_opengles2_ClearDepthf(context, depth); } TRACE_WRAPPER void trace_ppb_opengles2_ClearStencil(PP_Resource context, GLint s) { trace_info("[PPB] {full} %s context=%d, s=%d\n", __func__+6, context, s); ppb_opengles2_ClearStencil(context, s); } TRACE_WRAPPER void trace_ppb_opengles2_ColorMask(PP_Resource context, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { trace_info("[PPB] {full} %s context=%d, red=%d, green=%d, blue=%d, alpha=%d\n", __func__+6, context, red, green, blue, alpha); ppb_opengles2_ColorMask(context, red, green, blue, alpha); } TRACE_WRAPPER void trace_ppb_opengles2_CompileShader(PP_Resource context, GLuint shader) { trace_info("[PPB] {full} %s context=%d, shader=%d\n", __func__+6, context, shader); ppb_opengles2_CompileShader(context, shader); } TRACE_WRAPPER void trace_ppb_opengles2_CompressedTexImage2D(PP_Resource context, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), level=%d, internalformat=%u(%s), " "width=%d, height=%d, border=%d, imageSize=%d, data=%p\n", __func__+6, context, target, reverse_gl_enum(target), level, internalformat, reverse_gl_enum(internalformat), width, height, border, imageSize, data); ppb_opengles2_CompressedTexImage2D(context, target, level, internalformat, width, height, border, imageSize, data); } TRACE_WRAPPER void trace_ppb_opengles2_CompressedTexSubImage2D(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), level=%d, xoffset=%d, yoffset=%d, " "width=%d, height=%d, format=%u(%s), imageSize=%d, data=%p\n", __func__+6, context, target, reverse_gl_enum(target), level, xoffset, yoffset, width, height, format, reverse_gl_enum(format), imageSize, data); ppb_opengles2_CompressedTexSubImage2D(context, target, level, xoffset, yoffset, width, height, format, imageSize, data); } TRACE_WRAPPER void trace_ppb_opengles2_CopyTexImage2D(PP_Resource context, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), level=%d, internalformat=%u(%s), x=%d, " "y=%d, width=%d, height=%d, border=%d\n", __func__+6, context, target, reverse_gl_enum(target), level, internalformat, reverse_gl_enum(internalformat), x, y, width, height, border); ppb_opengles2_CopyTexImage2D(context, target, level, internalformat, x, y, width, height, border); } TRACE_WRAPPER void trace_ppb_opengles2_CopyTexSubImage2D(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), level=%d, xoffset=%d, yoffset=%d, " "x=%d, y=%d, width=%d, height=%d\n", __func__+6, context, target, reverse_gl_enum(target), level, xoffset, yoffset, x, y, width, height); ppb_opengles2_CopyTexSubImage2D(context, target, level, xoffset, yoffset, x, y, width, height); } TRACE_WRAPPER GLuint trace_ppb_opengles2_CreateProgram(PP_Resource context) { trace_info("[PPB] {full} %s context=%d\n", __func__+6, context); return ppb_opengles2_CreateProgram(context); } TRACE_WRAPPER GLuint trace_ppb_opengles2_CreateShader(PP_Resource context, GLenum type) { trace_info("[PPB] {full} %s context=%d type=%u(%s)\n", __func__+6, context, type, reverse_gl_enum(type)); return ppb_opengles2_CreateShader(context, type); } TRACE_WRAPPER void trace_ppb_opengles2_CullFace(PP_Resource context, GLenum mode) { trace_info("[PPB] {full} %s context=%d, mode=%u(%s)\n", __func__+6, context, mode, reverse_gl_enum(mode)); ppb_opengles2_CullFace(context, mode); } TRACE_WRAPPER void trace_ppb_opengles2_DeleteBuffers(PP_Resource context, GLsizei n, const GLuint *buffers) { trace_info("[PPB] {full} %s context=%d, n=%d, buffers=%p\n", __func__+6, context, n, buffers); ppb_opengles2_DeleteBuffers(context, n, buffers); } TRACE_WRAPPER void trace_ppb_opengles2_DeleteFramebuffers(PP_Resource context, GLsizei n, const GLuint *framebuffers) { trace_info("[PPB] {full} %s context=%d, n=%d, framebuffers=%p\n", __func__+6, context, n, framebuffers); ppb_opengles2_DeleteFramebuffers(context, n, framebuffers); } TRACE_WRAPPER void trace_ppb_opengles2_DeleteProgram(PP_Resource context, GLuint program) { trace_info("[PPB] {full} %s context=%d, program=%u\n", __func__+6, context, program); ppb_opengles2_DeleteProgram(context, program); } TRACE_WRAPPER void trace_ppb_opengles2_DeleteRenderbuffers(PP_Resource context, GLsizei n, const GLuint *renderbuffers) { trace_info("[PPB] {full} %s context=%d, n=%d, renderbuffers=%p\n", __func__+6, context, n, renderbuffers); ppb_opengles2_DeleteRenderbuffers(context, n, renderbuffers); } TRACE_WRAPPER void trace_ppb_opengles2_DeleteShader(PP_Resource context, GLuint shader) { trace_info("[PPB] {full} %s context=%d, shader=%u\n", __func__+6, context, shader); ppb_opengles2_DeleteShader(context, shader); } TRACE_WRAPPER void trace_ppb_opengles2_DeleteTextures(PP_Resource context, GLsizei n, const GLuint *textures) { trace_info("[PPB] {full} %s context=%d, n=%d, textures=%p\n", __func__+6, context, n, textures); ppb_opengles2_DeleteTextures(context, n, textures); } TRACE_WRAPPER void trace_ppb_opengles2_DepthFunc(PP_Resource context, GLenum func) { trace_info("[PPB] {full} %s context=%d, func=%u(%s)\n", __func__+6, context, func, reverse_gl_enum(func)); ppb_opengles2_DepthFunc(context, func); } TRACE_WRAPPER void trace_ppb_opengles2_DepthMask(PP_Resource context, GLboolean flag) { trace_info("[PPB] {full} %s context=%d, flag=%d\n", __func__+6, context, flag); ppb_opengles2_DepthMask(context, flag); } TRACE_WRAPPER void trace_ppb_opengles2_DepthRangef(PP_Resource context, GLclampf zNear, GLclampf zFar) { trace_info("[PPB] {full} %s context=%d, zNear=%f, zFar=%f\n", __func__+6, context, zNear, zFar); ppb_opengles2_DepthRangef(context, zNear, zFar); } TRACE_WRAPPER void trace_ppb_opengles2_DetachShader(PP_Resource context, GLuint program, GLuint shader) { trace_info("[PPB] {full} %s context=%d, program=%u, shader=%u\n", __func__+6, context, program, shader); ppb_opengles2_DetachShader(context, program, shader); } TRACE_WRAPPER void trace_ppb_opengles2_Disable(PP_Resource context, GLenum cap) { trace_info("[PPB] {full} %s context=%d, cap=%u(%s)\n", __func__+6, context, cap, reverse_gl_enum(cap)); ppb_opengles2_Disable(context, cap); } TRACE_WRAPPER void trace_ppb_opengles2_DisableVertexAttribArray(PP_Resource context, GLuint index) { trace_info("[PPB] {full} %s context=%d, index=%u\n", __func__+6, context, index); ppb_opengles2_DisableVertexAttribArray(context, index); } TRACE_WRAPPER void trace_ppb_opengles2_DrawArrays(PP_Resource context, GLenum mode, GLint first, GLsizei count) { trace_info("[PPB] {full} %s context=%d, mode=%u(%s), first=%d, count=%d\n", __func__+6, context, mode, reverse_gl_enum(mode), first, count); ppb_opengles2_DrawArrays(context, mode, first, count); } TRACE_WRAPPER void trace_ppb_opengles2_DrawElements(PP_Resource context, GLenum mode, GLsizei count, GLenum type, const void *indices) { trace_info("[PPB] {full} %s context=%d, mode=%u(%s), count=%d, type=%u(%s), indices=%p\n", __func__+6, context, mode, reverse_gl_enum(mode), count, type, reverse_gl_enum(type), indices); ppb_opengles2_DrawElements(context, mode, count, type, indices); } TRACE_WRAPPER void trace_ppb_opengles2_Enable(PP_Resource context, GLenum cap) { trace_info("[PPB] {full} %s context=%d, cap=%u(%s)\n", __func__+6, context, cap, reverse_gl_enum(cap)); ppb_opengles2_Enable(context, cap); } TRACE_WRAPPER void trace_ppb_opengles2_EnableVertexAttribArray(PP_Resource context, GLuint index) { trace_info("[PPB] {full} %s context=%d, index=%u\n", __func__+6, context, index); ppb_opengles2_EnableVertexAttribArray(context, index); } TRACE_WRAPPER void trace_ppb_opengles2_Finish(PP_Resource context) { trace_info("[PPB] {full} %s context=%d\n", __func__+6, context); ppb_opengles2_Finish(context); } TRACE_WRAPPER void trace_ppb_opengles2_Flush(PP_Resource context) { trace_info("[PPB] {full} %s context=%d\n", __func__+6, context); ppb_opengles2_Flush(context); } TRACE_WRAPPER void trace_ppb_opengles2_FramebufferRenderbuffer(PP_Resource context, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), attachment=%u(%s), renderbuffertarget=" "%u(%s), renderbuffer=%u\n", __func__+6, context, target, reverse_gl_enum(target), attachment, reverse_gl_enum(attachment), renderbuffertarget, reverse_gl_enum(renderbuffertarget), renderbuffer); ppb_opengles2_FramebufferRenderbuffer(context, target, attachment, renderbuffertarget, renderbuffer); } TRACE_WRAPPER void trace_ppb_opengles2_FramebufferTexture2D(PP_Resource context, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), attachment=%u(%s), textarget=%u(%s), " "texture=%u, level=%d\n", __func__+6, context, target, reverse_gl_enum(target), attachment, reverse_gl_enum(attachment), textarget, reverse_gl_enum(textarget), texture, level); ppb_opengles2_FramebufferTexture2D(context, target, attachment, textarget, texture, level); } TRACE_WRAPPER void trace_ppb_opengles2_FrontFace(PP_Resource context, GLenum mode) { trace_info("[PPB] {full} %s context=%d, mode=%u(%s)\n", __func__+6, context, mode, reverse_gl_enum(mode)); ppb_opengles2_FrontFace(context, mode); } TRACE_WRAPPER void trace_ppb_opengles2_GenBuffers(PP_Resource context, GLsizei n, GLuint *buffers) { trace_info("[PPB] {full} %s context=%d, n=%d, buffers=%p\n", __func__+6, context, n, buffers); ppb_opengles2_GenBuffers(context, n, buffers); } TRACE_WRAPPER void trace_ppb_opengles2_GenerateMipmap(PP_Resource context, GLenum target) { trace_info("[PPB] {full} %s context=%d, target=%u(%s)\n", __func__+6, context, target, reverse_gl_enum(target)); ppb_opengles2_GenerateMipmap(context, target); } TRACE_WRAPPER void trace_ppb_opengles2_GenFramebuffers(PP_Resource context, GLsizei n, GLuint *framebuffers) { trace_info("[PPB] {full} %s context=%d, n=%d, framebuffers=%p\n", __func__+6, context, n, framebuffers); ppb_opengles2_GenFramebuffers(context, n, framebuffers); } TRACE_WRAPPER void trace_ppb_opengles2_GenRenderbuffers(PP_Resource context, GLsizei n, GLuint *renderbuffers) { trace_info("[PPB] {full} %s context=%d, n=%d, renderbuffers=%p\n", __func__+6, context, n, renderbuffers); ppb_opengles2_GenRenderbuffers(context, n, renderbuffers); } TRACE_WRAPPER void trace_ppb_opengles2_GenTextures(PP_Resource context, GLsizei n, GLuint *textures) { trace_info("[PPB] {full} %s context=%d, n=%d, textures=%p\n", __func__+6, context, n, textures); ppb_opengles2_GenTextures(context, n, textures); } TRACE_WRAPPER void trace_ppb_opengles2_GetActiveAttrib(PP_Resource context, GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name) { trace_info("[PPB] {full} %s context=%d, program=%u, index=%u, bufsize=%d\n", __func__+6, context, program, index, bufsize); ppb_opengles2_GetActiveAttrib(context, program, index, bufsize, length, size, type, name); } TRACE_WRAPPER void trace_ppb_opengles2_GetActiveUniform(PP_Resource context, GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name) { trace_info("[PPB] {full} %s context=%d, program=%u, index=%u, bufsize=%d\n", __func__+6, context, program, index, bufsize); ppb_opengles2_GetActiveUniform(context, program, index, bufsize, length, size, type, name); } TRACE_WRAPPER void trace_ppb_opengles2_GetAttachedShaders(PP_Resource context, GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders) { trace_info("[PPB] {full} %s context=%d, program=%u, maxcount=%d\n", __func__+6, context, program, maxcount); ppb_opengles2_GetAttachedShaders(context, program, maxcount, count, shaders); } TRACE_WRAPPER GLint trace_ppb_opengles2_GetAttribLocation(PP_Resource context, GLuint program, const char *name) { trace_info("[PPB] {full} %s context=%d, program=%u, name=%s\n", __func__+6, context, program, name); return ppb_opengles2_GetAttribLocation(context, program, name); } TRACE_WRAPPER void trace_ppb_opengles2_GetBooleanv(PP_Resource context, GLenum pname, GLboolean *params) { trace_info("[PPB] {full} %s context=%d, pname=%u(%s)\n", __func__+6, context, pname, reverse_gl_enum(pname)); ppb_opengles2_GetBooleanv(context, pname, params); } TRACE_WRAPPER void trace_ppb_opengles2_GetBufferParameteriv(PP_Resource context, GLenum target, GLenum pname, GLint *params) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), pname=%u(%s)\n", __func__+6, context, target, reverse_gl_enum(target), pname, reverse_gl_enum(pname)); ppb_opengles2_GetBufferParameteriv(context, target, pname, params); } TRACE_WRAPPER GLenum trace_ppb_opengles2_GetError(PP_Resource context) { trace_info("[PPB] {full} %s context=%d\n", __func__+6, context); return ppb_opengles2_GetError(context); } TRACE_WRAPPER void trace_ppb_opengles2_GetFloatv(PP_Resource context, GLenum pname, GLfloat *params) { trace_info("[PPB] {full} %s context=%d, pname=%u(%s)\n", __func__+6, context, pname, reverse_gl_enum(pname)); ppb_opengles2_GetFloatv(context, pname, params); } TRACE_WRAPPER void trace_ppb_opengles2_GetFramebufferAttachmentParameteriv(PP_Resource context, GLenum target, GLenum attachment, GLenum pname, GLint *params) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), attachment=%u(%s), pname=%u(%s)\n", __func__+6, context, target, reverse_gl_enum(target), attachment, reverse_gl_enum(attachment), pname, reverse_gl_enum(pname)); ppb_opengles2_GetFramebufferAttachmentParameteriv(context, target, attachment, pname, params); } TRACE_WRAPPER void trace_ppb_opengles2_GetIntegerv(PP_Resource context, GLenum pname, GLint *params) { trace_info("[PPB] {full} %s context=%d, pname=%u(%s)\n", __func__+6, context, pname, reverse_gl_enum(pname)); ppb_opengles2_GetIntegerv(context, pname, params); } TRACE_WRAPPER void trace_ppb_opengles2_GetProgramiv(PP_Resource context, GLuint program, GLenum pname, GLint *params) { trace_info("[PPB] {full} %s context=%d, program=%u, pname=%u(%s)\n", __func__+6, context, program, pname, reverse_gl_enum(pname)); ppb_opengles2_GetProgramiv(context, program, pname, params); } TRACE_WRAPPER void trace_ppb_opengles2_GetProgramInfoLog(PP_Resource context, GLuint program, GLsizei bufsize, GLsizei *length, char *infolog) { trace_info("[PPB] {full} %s context=%d, program=%u, bufsize=%d\n", __func__+6, context, program, bufsize); ppb_opengles2_GetProgramInfoLog(context, program, bufsize, length, infolog); } TRACE_WRAPPER void trace_ppb_opengles2_GetRenderbufferParameteriv(PP_Resource context, GLenum target, GLenum pname, GLint *params) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), pname=%u(%s)\n", __func__+6, context, target, reverse_gl_enum(target), pname, reverse_gl_enum(pname)); ppb_opengles2_GetRenderbufferParameteriv(context, target, pname, params); } TRACE_WRAPPER void trace_ppb_opengles2_GetShaderiv(PP_Resource context, GLuint shader, GLenum pname, GLint *params) { trace_info("[PPB] {full} %s context=%d, shader=%u, pname=%u(%s)\n", __func__+6, context, shader, pname, reverse_gl_enum(pname)); ppb_opengles2_GetShaderiv(context, shader, pname, params); } TRACE_WRAPPER void trace_ppb_opengles2_GetShaderInfoLog(PP_Resource context, GLuint shader, GLsizei bufsize, GLsizei *length, char *infolog) { trace_info("[PPB] {full} %s context=%d, shader=%u, bufsize=%d\n", __func__+6, context, shader, bufsize); ppb_opengles2_GetShaderInfoLog(context, shader, bufsize, length, infolog); } TRACE_WRAPPER void trace_ppb_opengles2_GetShaderPrecisionFormat(PP_Resource context, GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision) { trace_info("[PPB] {full} %s context=%d, shadertype=%u(%s), precisiontype=%u(%s)\n", __func__+6, context, shadertype, reverse_gl_enum(shadertype), precisiontype, reverse_gl_enum(precisiontype)); ppb_opengles2_GetShaderPrecisionFormat(context, shadertype, precisiontype, range, precision); } TRACE_WRAPPER void trace_ppb_opengles2_GetShaderSource(PP_Resource context, GLuint shader, GLsizei bufsize, GLsizei *length, char *source) { trace_info("[PPB] {full} %s context=%d, shader=%u, bufsize=%d\n", __func__+6, context, shader, bufsize); ppb_opengles2_GetShaderSource(context, shader, bufsize, length, source); } TRACE_WRAPPER const GLubyte * trace_ppb_opengles2_GetString(PP_Resource context, GLenum name) { trace_info("[PPB] {full} %s context=%d name=%u(%s)\n", __func__+6, context, name, reverse_gl_enum(name)); return ppb_opengles2_GetString(context, name); } TRACE_WRAPPER void trace_ppb_opengles2_GetTexParameterfv(PP_Resource context, GLenum target, GLenum pname, GLfloat *params) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), pname=%u(%s)\n", __func__+6, context, target, reverse_gl_enum(target), pname, reverse_gl_enum(pname)); ppb_opengles2_GetTexParameterfv(context, target, pname, params); } TRACE_WRAPPER void trace_ppb_opengles2_GetTexParameteriv(PP_Resource context, GLenum target, GLenum pname, GLint *params) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), pname=%u(%s)\n", __func__+6, context, target, reverse_gl_enum(target), pname, reverse_gl_enum(pname)); ppb_opengles2_GetTexParameteriv(context, target, pname, params); } TRACE_WRAPPER void trace_ppb_opengles2_GetUniformfv(PP_Resource context, GLuint program, GLint location, GLfloat *params) { trace_info("[PPB] {full} %s context=%d, program=%u, location=%d\n", __func__+6, context, program, location); ppb_opengles2_GetUniformfv(context, program, location, params); } TRACE_WRAPPER void trace_ppb_opengles2_GetUniformiv(PP_Resource context, GLuint program, GLint location, GLint *params) { trace_info("[PPB] {full} %s context=%d, program=%u, location=%d\n", __func__+6, context, program, location); ppb_opengles2_GetUniformiv(context, program, location, params); } TRACE_WRAPPER GLint trace_ppb_opengles2_GetUniformLocation(PP_Resource context, GLuint program, const char *name) { trace_info("[PPB] {full} %s context=%d, program=%u, name=%s\n", __func__+6, context, program, name); return ppb_opengles2_GetUniformLocation(context, program, name); } TRACE_WRAPPER void trace_ppb_opengles2_GetVertexAttribfv(PP_Resource context, GLuint index, GLenum pname, GLfloat *params) { trace_info("[PPB] {full} %s context=%d, index=%u, pname=%u(%s)\n", __func__+6, context, index, pname, reverse_gl_enum(pname)); ppb_opengles2_GetVertexAttribfv(context, index, pname, params); } TRACE_WRAPPER void trace_ppb_opengles2_GetVertexAttribiv(PP_Resource context, GLuint index, GLenum pname, GLint *params) { trace_info("[PPB] {full} %s context=%d, index=%u, pname=%u(%s)\n", __func__+6, context, index, pname, reverse_gl_enum(pname)); ppb_opengles2_GetVertexAttribiv(context, index, pname, params); } TRACE_WRAPPER void trace_ppb_opengles2_GetVertexAttribPointerv(PP_Resource context, GLuint index, GLenum pname, void **pointer) { trace_info("[PPB] {full} %s context=%d, index=%u, pname=%u(%s)\n", __func__+6, context, index, pname, reverse_gl_enum(pname)); ppb_opengles2_GetVertexAttribPointerv(context, index, pname, pointer); } TRACE_WRAPPER void trace_ppb_opengles2_Hint(PP_Resource context, GLenum target, GLenum mode) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), mode=%u(%s)\n", __func__+6, context, target, reverse_gl_enum(target), mode, reverse_gl_enum(mode)); ppb_opengles2_Hint(context, target, mode); } TRACE_WRAPPER GLboolean trace_ppb_opengles2_IsBuffer(PP_Resource context, GLuint buffer) { trace_info("[PPB] {full} %s context=%d, buffer=%u\n", __func__+6, context, buffer); return ppb_opengles2_IsBuffer(context, buffer); } TRACE_WRAPPER GLboolean trace_ppb_opengles2_IsEnabled(PP_Resource context, GLenum cap) { trace_info("[PPB] {full} %s context=%d, cap=%u(%s)\n", __func__+6, context, cap, reverse_gl_enum(cap)); return ppb_opengles2_IsEnabled(context, cap); } TRACE_WRAPPER GLboolean trace_ppb_opengles2_IsFramebuffer(PP_Resource context, GLuint framebuffer) { trace_info("[PPB] {full} %s context=%d, framebuffer=%u\n", __func__+6, context, framebuffer); return ppb_opengles2_IsFramebuffer(context, framebuffer); } TRACE_WRAPPER GLboolean trace_ppb_opengles2_IsProgram(PP_Resource context, GLuint program) { trace_info("[PPB] {full} %s context=%d, program=%u\n", __func__+6, context, program); return ppb_opengles2_IsProgram(context, program); } TRACE_WRAPPER GLboolean trace_ppb_opengles2_IsRenderbuffer(PP_Resource context, GLuint renderbuffer) { trace_info("[PPB] {full} %s context=%d, renderbuffer=%u\n", __func__+6, context, renderbuffer); return ppb_opengles2_IsRenderbuffer(context, renderbuffer); } TRACE_WRAPPER GLboolean trace_ppb_opengles2_IsShader(PP_Resource context, GLuint shader) { trace_info("[PPB] {full} %s context=%d, shader=%u\n", __func__+6, context, shader); return ppb_opengles2_IsShader(context, shader); } TRACE_WRAPPER GLboolean trace_ppb_opengles2_IsTexture(PP_Resource context, GLuint texture) { trace_info("[PPB] {full} %s context=%d, texture=%u\n", __func__+6, context, texture); return ppb_opengles2_IsTexture(context, texture); } TRACE_WRAPPER void trace_ppb_opengles2_LineWidth(PP_Resource context, GLfloat width) { trace_info("[PPB] {full} %s context=%d, width=%f\n", __func__+6, context, width); ppb_opengles2_LineWidth(context, width); } TRACE_WRAPPER void trace_ppb_opengles2_LinkProgram(PP_Resource context, GLuint program) { trace_info("[PPB] {full} %s context=%d, program=%u\n", __func__+6, context, program); ppb_opengles2_LinkProgram(context, program); } TRACE_WRAPPER void trace_ppb_opengles2_PixelStorei(PP_Resource context, GLenum pname, GLint param) { trace_info("[PPB] {full} %s context=%d, pname=%u(%s), param=%d\n", __func__+6, context, pname, reverse_gl_enum(pname), param); ppb_opengles2_PixelStorei(context, pname, param); } TRACE_WRAPPER void trace_ppb_opengles2_PolygonOffset(PP_Resource context, GLfloat factor, GLfloat units) { trace_info("[PPB] {full} %s context=%d, factor=%f, units=%f\n", __func__+6, context, factor, units); ppb_opengles2_PolygonOffset(context, factor, units); } TRACE_WRAPPER void trace_ppb_opengles2_ReadPixels(PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels) { trace_info("[PPB] {full} %s context=%d, x=%d, y=%d, width=%d, height=%d, format=%u(%s), " "type=%u(%s), pixels=%p\n", __func__+6, context, x, y, width, height, format, reverse_gl_enum(format), type, reverse_gl_enum(type), pixels); ppb_opengles2_ReadPixels(context, x, y, width, height, format, type, pixels); } TRACE_WRAPPER void trace_ppb_opengles2_ReleaseShaderCompiler(PP_Resource context) { trace_info("[PPB] {full} %s context=%d\n", __func__+6, context); ppb_opengles2_ReleaseShaderCompiler(context); } TRACE_WRAPPER void trace_ppb_opengles2_RenderbufferStorage(PP_Resource context, GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), internalformat=%u(%s), width=%d, " "height=%d\n", __func__+6, context, target, reverse_gl_enum(target), internalformat, reverse_gl_enum(internalformat), width, height); ppb_opengles2_RenderbufferStorage(context, target, internalformat, width, height); } TRACE_WRAPPER void trace_ppb_opengles2_SampleCoverage(PP_Resource context, GLclampf value, GLboolean invert) { trace_info("[PPB] {full} %s context=%d, value=%f, invert=%d\n", __func__+6, context, value, invert); ppb_opengles2_SampleCoverage(context, value, invert); } TRACE_WRAPPER void trace_ppb_opengles2_Scissor(PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height) { trace_info("[PPB] {full} %s context=%d, x=%d, y=%d, width=%d, height=%d\n", __func__+6, context, x, y, width, height); ppb_opengles2_Scissor(context, x, y, width, height); } TRACE_WRAPPER void trace_ppb_opengles2_ShaderBinary(PP_Resource context, GLsizei n, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length) { trace_info("[PPB] {full} %s context=%d, n=%d, shaders=%p, binaryformat=%u(%s), binary=%p, " "length=%d\n", __func__+6, context, n, shaders, binaryformat, reverse_gl_enum(binaryformat), binary, length); ppb_opengles2_ShaderBinary(context, n, shaders, binaryformat, binary, length); } TRACE_WRAPPER void trace_ppb_opengles2_ShaderSource(PP_Resource context, GLuint shader, GLsizei count, const char **str, const GLint *length) { trace_info("[PPB] {full} %s context=%d, shader=%u, count=%d, str=%p, length=%p\n", __func__+6, context, shader, count, str, length); for (intptr_t k = 0; k < count; k++) { trace_info(" shader_source[%u] = \n%s\n", (unsigned)k, str[k]); } ppb_opengles2_ShaderSource(context, shader, count, str, length); } TRACE_WRAPPER void trace_ppb_opengles2_StencilFunc(PP_Resource context, GLenum func, GLint ref, GLuint mask) { trace_info("[PPB] {full} %s context=%d, func=%u(%s), ref=%d, mask=0x%x\n", __func__+6, context, func, reverse_gl_enum(func), ref, mask); ppb_opengles2_StencilFunc(context, func, ref, mask); } TRACE_WRAPPER void trace_ppb_opengles2_StencilFuncSeparate(PP_Resource context, GLenum face, GLenum func, GLint ref, GLuint mask) { trace_info("[PPB] {full} %s context=%d, face=%u(%s), func=%u(%s), ref=%d, mask=0x%x\n", __func__+6, context, face, reverse_gl_enum(face), func, reverse_gl_enum(func), ref, mask); ppb_opengles2_StencilFuncSeparate(context, face, func, ref, mask); } TRACE_WRAPPER void trace_ppb_opengles2_StencilMask(PP_Resource context, GLuint mask) { trace_info("[PPB] {full} %s context=%d, mask=0x%x\n", __func__+6, context, mask); ppb_opengles2_StencilMask(context, mask); } TRACE_WRAPPER void trace_ppb_opengles2_StencilMaskSeparate(PP_Resource context, GLenum face, GLuint mask) { trace_info("[PPB] {full} %s context=%d, face=%u(%s), mask=0x%x\n", __func__+6, context, face, reverse_gl_enum(face), mask); ppb_opengles2_StencilMaskSeparate(context, face, mask); } TRACE_WRAPPER void trace_ppb_opengles2_StencilOp(PP_Resource context, GLenum fail, GLenum zfail, GLenum zpass) { trace_info("[PPB] {full} %s context=%d, fail=%u(%s), zfail=%u(%s), zpass=%u(%s)\n", __func__+6, context, fail, reverse_gl_enum(fail), zfail, reverse_gl_enum(zfail), zpass, reverse_gl_enum(zpass)); ppb_opengles2_StencilOp(context, fail, zfail, zpass); } TRACE_WRAPPER void trace_ppb_opengles2_StencilOpSeparate(PP_Resource context, GLenum face, GLenum fail, GLenum zfail, GLenum zpass) { trace_info("[PPB] {full} %s context=%d, face=%u(%s), fail=%u(%s), zfail=%u(%s), zpass=%u(%s)\n", __func__+6, context, face, reverse_gl_enum(face), fail, reverse_gl_enum(fail), zfail, reverse_gl_enum(zfail), zpass, reverse_gl_enum(zpass)); ppb_opengles2_StencilOpSeparate(context, face, fail, zfail, zpass); } TRACE_WRAPPER void trace_ppb_opengles2_TexImage2D(PP_Resource context, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), level=%d, internalformat=%u(%s), " "width=%d, height=%d, border=%d, format=%u(%s), type=%u(%s), pixels=%p\n", __func__+6, context, target, reverse_gl_enum(target), level, internalformat, reverse_gl_enum(internalformat), width, height, border, format, reverse_gl_enum(format), type, reverse_gl_enum(type), pixels); ppb_opengles2_TexImage2D(context, target, level, internalformat, width, height, border, format, type, pixels); } TRACE_WRAPPER void trace_ppb_opengles2_TexParameterf(PP_Resource context, GLenum target, GLenum pname, GLfloat param) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), pname=%u(%s), param=%f\n", __func__+6, context, target, reverse_gl_enum(target), pname, reverse_gl_enum(pname), param); ppb_opengles2_TexParameterf(context, target, pname, param); } TRACE_WRAPPER void trace_ppb_opengles2_TexParameterfv(PP_Resource context, GLenum target, GLenum pname, const GLfloat *params) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), pname=%u(%s), params=%p\n", __func__+6, context, target, reverse_gl_enum(target), pname, reverse_gl_enum(pname), params); ppb_opengles2_TexParameterfv(context, target, pname, params); } TRACE_WRAPPER void trace_ppb_opengles2_TexParameteri(PP_Resource context, GLenum target, GLenum pname, GLint param) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), pname=%u(%s), param=%d\n", __func__+6, context, target, reverse_gl_enum(target), pname, reverse_gl_enum(pname), param); ppb_opengles2_TexParameteri(context, target, pname, param); } TRACE_WRAPPER void trace_ppb_opengles2_TexParameteriv(PP_Resource context, GLenum target, GLenum pname, const GLint *params) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), pname=%u(%s), params=%p\n", __func__+6, context, target, reverse_gl_enum(target), pname, reverse_gl_enum(pname), params); ppb_opengles2_TexParameteriv(context, target, pname, params); } TRACE_WRAPPER void trace_ppb_opengles2_TexSubImage2D(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), level=%d, xoffset=%d, yoffset=%d, " "width=%d, height=%d, format=%u(%s), type=%u(%s), pixels=%p\n", __func__+6, context, target, reverse_gl_enum(target), level, xoffset, yoffset, width, height, format, reverse_gl_enum(format), type, reverse_gl_enum(type), pixels); ppb_opengles2_TexSubImage2D(context, target, level, xoffset, yoffset, width, height, format, type, pixels); } TRACE_WRAPPER void trace_ppb_opengles2_Uniform1f(PP_Resource context, GLint location, GLfloat x) { trace_info("[PPB] {full} %s context=%d, location=%d, x=%f\n", __func__+6, context, location, x); ppb_opengles2_Uniform1f(context, location, x); } TRACE_WRAPPER void trace_ppb_opengles2_Uniform1fv(PP_Resource context, GLint location, GLsizei count, const GLfloat *v) { trace_info("[PPB] {full} %s context=%d, location=%d, count=%d, v=%p\n", __func__+6, context, location, count, v); ppb_opengles2_Uniform1fv(context, location, count, v); } TRACE_WRAPPER void trace_ppb_opengles2_Uniform1i(PP_Resource context, GLint location, GLint x) { trace_info("[PPB] {full} %s context=%d, location=%d, x=%d\n", __func__+6, context, location, x); ppb_opengles2_Uniform1i(context, location, x); } TRACE_WRAPPER void trace_ppb_opengles2_Uniform1iv(PP_Resource context, GLint location, GLsizei count, const GLint *v) { trace_info("[PPB] {full} %s context=%d, location=%d, count=%d, v=%p\n", __func__+6, context, location, count, v); ppb_opengles2_Uniform1iv(context, location, count, v); } TRACE_WRAPPER void trace_ppb_opengles2_Uniform2f(PP_Resource context, GLint location, GLfloat x, GLfloat y) { trace_info("[PPB] {full} %s context=%d, location=%d, x=%f, y=%f\n", __func__+6, context, location, x, y); ppb_opengles2_Uniform2f(context, location, x, y); } TRACE_WRAPPER void trace_ppb_opengles2_Uniform2fv(PP_Resource context, GLint location, GLsizei count, const GLfloat *v) { trace_info("[PPB] {full} %s context=%d, location=%d, count=%d, v=%p\n", __func__+6, context, location, count, v); ppb_opengles2_Uniform2fv(context, location, count, v); } TRACE_WRAPPER void trace_ppb_opengles2_Uniform2i(PP_Resource context, GLint location, GLint x, GLint y) { trace_info("[PPB] {full} %s context=%d, location=%d, x=%d, y=%d\n", __func__+6, context, location, x, y); ppb_opengles2_Uniform2i(context, location, x, y); } TRACE_WRAPPER void trace_ppb_opengles2_Uniform2iv(PP_Resource context, GLint location, GLsizei count, const GLint *v) { trace_info("[PPB] {full} %s context=%d, location=%d, count=%d, v=%p\n", __func__+6, context, location, count, v); ppb_opengles2_Uniform2iv(context, location, count, v); } TRACE_WRAPPER void trace_ppb_opengles2_Uniform3f(PP_Resource context, GLint location, GLfloat x, GLfloat y, GLfloat z) { trace_info("[PPB] {full} %s context=%d, location=%d, x=%f, y=%f, z=%f\n", __func__+6, context, location, x, y, z); ppb_opengles2_Uniform3f(context, location, x, y, z); } TRACE_WRAPPER void trace_ppb_opengles2_Uniform3fv(PP_Resource context, GLint location, GLsizei count, const GLfloat *v) { trace_info("[PPB] {full} %s context=%d, location=%d, count=%d, v=%p\n", __func__+6, context, location, count, v); ppb_opengles2_Uniform3fv(context, location, count, v); } TRACE_WRAPPER void trace_ppb_opengles2_Uniform3i(PP_Resource context, GLint location, GLint x, GLint y, GLint z) { trace_info("[PPB] {full} %s context=%d, location=%d, x=%d, y=%d, z=%d\n", __func__+6, context, location, x, y, z); ppb_opengles2_Uniform3i(context, location, x, y, z); } TRACE_WRAPPER void trace_ppb_opengles2_Uniform3iv(PP_Resource context, GLint location, GLsizei count, const GLint *v) { trace_info("[PPB] {full} %s context=%d, location=%d, count=%d, v=%p\n", __func__+6, context, location, count, v); ppb_opengles2_Uniform3iv(context, location, count, v); } TRACE_WRAPPER void trace_ppb_opengles2_Uniform4f(PP_Resource context, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { trace_info("[PPB] {full} %s context=%d, location=%d, x=%f, y=%f, z=%f, w=%f\n", __func__+6, context, location, x, y, z, w); ppb_opengles2_Uniform4f(context, location, x, y, z, w); } TRACE_WRAPPER void trace_ppb_opengles2_Uniform4fv(PP_Resource context, GLint location, GLsizei count, const GLfloat *v) { trace_info("[PPB] {full} %s context=%d, location=%d, count=%d, v=%p\n", __func__+6, context, location, count, v); ppb_opengles2_Uniform4fv(context, location, count, v); } TRACE_WRAPPER void trace_ppb_opengles2_Uniform4i(PP_Resource context, GLint location, GLint x, GLint y, GLint z, GLint w) { trace_info("[PPB] {full} %s context=%d, location=%d, x=%d, y=%d, z=%d, w=%d\n", __func__+6, context, location, x, y, z, w); ppb_opengles2_Uniform4i(context, location, x, y, z, w); } TRACE_WRAPPER void trace_ppb_opengles2_Uniform4iv(PP_Resource context, GLint location, GLsizei count, const GLint *v) { trace_info("[PPB] {full} %s context=%d, location=%d, count=%d, v=%p\n", __func__+6, context, location, count, v); ppb_opengles2_Uniform4iv(context, location, count, v); } TRACE_WRAPPER void trace_ppb_opengles2_UniformMatrix2fv(PP_Resource context, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { trace_info("[PPB] {full} %s context=%d, location=%d, count=%d, transpose=%d, value=%p\n", __func__+6, context, location, count, transpose, value); ppb_opengles2_UniformMatrix2fv(context, location, count, transpose, value); } TRACE_WRAPPER void trace_ppb_opengles2_UniformMatrix3fv(PP_Resource context, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { trace_info("[PPB] {full} %s context=%d, location=%d, count=%d, transpose=%d, value=%p\n", __func__+6, context, location, count, transpose, value); ppb_opengles2_UniformMatrix3fv(context, location, count, transpose, value); } TRACE_WRAPPER void trace_ppb_opengles2_UniformMatrix4fv(PP_Resource context, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { trace_info("[PPB] {full} %s context=%d, location=%d, count=%d, transpose=%d, value=%p\n", __func__+6, context, location, count, transpose, value); ppb_opengles2_UniformMatrix4fv(context, location, count, transpose, value); } TRACE_WRAPPER void trace_ppb_opengles2_UseProgram(PP_Resource context, GLuint program) { trace_info("[PPB] {full} %s context=%d, program=%u\n", __func__+6, context, program); ppb_opengles2_UseProgram(context, program); } TRACE_WRAPPER void trace_ppb_opengles2_ValidateProgram(PP_Resource context, GLuint program) { trace_info("[PPB] {full} %s context=%d, program=%u\n", __func__+6, context, program); ppb_opengles2_ValidateProgram(context, program); } TRACE_WRAPPER void trace_ppb_opengles2_VertexAttrib1f(PP_Resource context, GLuint indx, GLfloat x) { trace_info("[PPB] {full} %s context=%d, indx=%u, x=%f\n", __func__+6, context, indx, x); ppb_opengles2_VertexAttrib1f(context, indx, x); } TRACE_WRAPPER void trace_ppb_opengles2_VertexAttrib1fv(PP_Resource context, GLuint indx, const GLfloat *values) { trace_info("[PPB] {full} %s context=%d, indx=%u, values=%p\n", __func__+6, context, indx, values); ppb_opengles2_VertexAttrib1fv(context, indx, values); } TRACE_WRAPPER void trace_ppb_opengles2_VertexAttrib2f(PP_Resource context, GLuint indx, GLfloat x, GLfloat y) { trace_info("[PPB] {full} %s context=%d, indx=%u, x=%f, y=%f\n", __func__+6, context, indx, x, y); ppb_opengles2_VertexAttrib2f(context, indx, x, y); } TRACE_WRAPPER void trace_ppb_opengles2_VertexAttrib2fv(PP_Resource context, GLuint indx, const GLfloat *values) { trace_info("[PPB] {full} %s context=%d, indx=%u, values=%p\n", __func__+6, context, indx, values); ppb_opengles2_VertexAttrib2fv(context, indx, values); } TRACE_WRAPPER void trace_ppb_opengles2_VertexAttrib3f(PP_Resource context, GLuint indx, GLfloat x, GLfloat y, GLfloat z) { trace_info("[PPB] {full} %s context=%d, indx=%u, x=%f, y=%f, z=%f\n", __func__+6, context, indx, x, y, z); ppb_opengles2_VertexAttrib3f(context, indx, x, y, z); } TRACE_WRAPPER void trace_ppb_opengles2_VertexAttrib3fv(PP_Resource context, GLuint indx, const GLfloat *values) { trace_info("[PPB] {full} %s context=%d, indx=%u, values=%p\n", __func__+6, context, indx, values); ppb_opengles2_VertexAttrib3fv(context, indx, values); } TRACE_WRAPPER void trace_ppb_opengles2_VertexAttrib4f(PP_Resource context, GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { trace_info("[PPB] {full} %s context=%d, indx=%u, x=%f, y=%f, z=%f, w=%f\n", __func__+6, context, indx, x, y, z, w); ppb_opengles2_VertexAttrib4f(context, indx, x, y, z, w); } TRACE_WRAPPER void trace_ppb_opengles2_VertexAttrib4fv(PP_Resource context, GLuint indx, const GLfloat *values) { trace_info("[PPB] {full} %s context=%d, indx=%u, values=%p\n", __func__+6, context, indx, values); ppb_opengles2_VertexAttrib4fv(context, indx, values); } TRACE_WRAPPER void trace_ppb_opengles2_VertexAttribPointer(PP_Resource context, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *ptr) { trace_info("[PPB] {full} %s context=%d, indx=%u, size=%d, type=%u(%s), normalized=%d, " "stride=%d, ptr=%p\n", __func__+6, context, indx, size, type, reverse_gl_enum(type), normalized, stride, ptr); ppb_opengles2_VertexAttribPointer(context, indx, size, type, normalized, stride, ptr); } TRACE_WRAPPER void trace_ppb_opengles2_Viewport(PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height) { trace_info("[PPB] {full} %s context=%d, x=%d, y=%d, width=%d, height=%d\n", __func__+6, context, x, y, width, height); ppb_opengles2_Viewport(context, x, y, width, height); } TRACE_WRAPPER GLboolean trace_ppb_opengles2_chromium_enable_feature_enable_feature_chromium(PP_Resource context, const char *feature) { trace_info("[PPB] {zilch} %s feature=%s\n", __func__+6, feature); return ppb_opengles2_chromium_enable_feature_enable_feature_chromium(context, feature); } TRACE_WRAPPER void * trace_ppb_opengles2_chromium_map_sub_map_buffer_sub_data_chromium(PP_Resource context, GLuint target, GLintptr offset, GLsizeiptr size, GLenum access) { trace_info("[PPB] {zilch} %s context=%d, target=%u, offset=%ld, size=%lu, access=%u(%s)\n", __func__+6, context, target, (long)offset, (unsigned long)size, access, reverse_gl_enum(access)); return ppb_opengles2_chromium_map_sub_map_buffer_sub_data_chromium(context, target, offset, size, access); } TRACE_WRAPPER void trace_ppb_opengles2_chromium_map_sub_unmap_buffer_sub_data_chromium(PP_Resource context, const void *mem) { trace_info("[PPB] {zilch} %s context=%d, mem=%p\n", __func__+6, context, mem); ppb_opengles2_chromium_map_sub_unmap_buffer_sub_data_chromium(context, mem); } TRACE_WRAPPER void * trace_ppb_opengles2_chromium_map_sub_map_tex_sub_image_2d_chromium(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLenum access) { trace_info("[PPB] {full} %s context=%d, target=%u(%s), level=%d, xoffset=%d, yoffset=%d, " "width=%d, height=%d, format=%u(%s), type=%u(%s), access=%u(%s)\n", __func__+6, context, target, reverse_gl_enum(target), level, xoffset, yoffset, width, height, format, reverse_gl_enum(format), type, reverse_gl_enum(type), access, reverse_gl_enum(access)); return ppb_opengles2_chromium_map_sub_map_tex_sub_image_2d_chromium(context, target, level, xoffset, yoffset, width, height, format, type, access); } TRACE_WRAPPER void trace_ppb_opengles2_chromium_map_sub_unmap_tex_sub_image_2d_chromium(PP_Resource context, const void *mem) { trace_info("[PPB] {full} %s context=%d, mem=%p\n", __func__+6, context, mem); ppb_opengles2_chromium_map_sub_unmap_tex_sub_image_2d_chromium(context, mem); } TRACE_WRAPPER void trace_ppb_opengles2_framebuffer_blit_blit_framebuffer_ext(PP_Resource context, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) { trace_info("[PPB] {zilch} %s context=%d, srcX0=%d, srcY0=%d, srcX1=%d, srcY1=%d, dstX0=%d, " "dstY0=%d, dstX1=%d, dstY1=%d, mask=0x%x, filter=%u(%s)\n", __func__+6, context, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter, reverse_gl_enum(filter)); return ppb_opengles2_framebuffer_blit_blit_framebuffer_ext(context, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); } TRACE_WRAPPER void trace_ppb_opengles2_framebuffer_multisample_renderbuffer_storage_multisample_ext (PP_Resource context, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) { trace_info("[PPB] {zilch} %s context=%d, target=%u(%s), samples=%d, internalformat=%u(%s), " "width=%d, height=%d\n", __func__+6, context, target, reverse_gl_enum(target), samples, internalformat, reverse_gl_enum(internalformat), width, height); ppb_opengles2_framebuffer_multisample_renderbuffer_storage_multisample_ext(context, target, samples, internalformat, width, height); } TRACE_WRAPPER void trace_ppb_opengles2_instanced_arrays_draw_arrays_instanced_angle(PP_Resource context, GLenum mode, GLint first, GLsizei count, GLsizei primcount) { trace_info("[PPB] {zilch} %s context=%d, mode=%u(%s), first=%d, count=%d, primcount=%d\n", __func__+6, context, mode, reverse_gl_enum(mode), first, count, primcount); ppb_opengles2_instanced_arrays_draw_arrays_instanced_angle(context, mode, first, count, primcount); } TRACE_WRAPPER void trace_ppb_opengles2_instanced_arrays_draw_elements_instanced_angle(PP_Resource context, GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount) { trace_info("[PPB] {zilch} %s context=%d, mode=%u(%s), count=%d, type=%u(%s), indices=%p, " "primcount=%d\n", __func__+6, context, mode, reverse_gl_enum(mode), count, type, reverse_gl_enum(type), indices, primcount); ppb_opengles2_instanced_arrays_draw_elements_instanced_angle(context, mode, count, type, indices, primcount); } TRACE_WRAPPER void trace_ppb_opengles2_instanced_arrays_vertex_attrib_divisor_angle(PP_Resource context, GLuint index, GLuint divisor) { trace_info("[PPB] {zilch} %s countext=%d, index=%u, divisor=%u\n", __func__+6, context, index, divisor); ppb_opengles2_instanced_arrays_vertex_attrib_divisor_angle(context, index, divisor); } TRACE_WRAPPER void trace_ppb_opengles2_query_gen_queries_ext(PP_Resource context, GLsizei n, GLuint *queries) { trace_info("[PPB] {zilch} %s context=%d, n=%d, queries=%p\n", __func__+6, context, n, queries); ppb_opengles2_query_gen_queries_ext(context, n, queries); } TRACE_WRAPPER void trace_ppb_opengles2_query_delete_queries_ext(PP_Resource context, GLsizei n, const GLuint *queries) { trace_info("[PPB] {zilch} %s context=%d, n=%d, queries=%p\n", __func__+6, context, n, queries); ppb_opengles2_query_delete_queries_ext(context, n, queries); } TRACE_WRAPPER GLboolean trace_ppb_opengles2_query_is_query_ext(PP_Resource context, GLuint id) { trace_info("[PPB] {zilch} %s context=%d, id=%u\n", __func__+6, context, id); return ppb_opengles2_query_is_query_ext(context, id); } TRACE_WRAPPER void trace_ppb_opengles2_query_begin_query_ext(PP_Resource context, GLenum target, GLuint id) { trace_info("[PPB] {zilch} %s context=%d, target=%u(%s), id=%u\n", __func__+6, context, target, reverse_gl_enum(target), id); ppb_opengles2_query_begin_query_ext(context, target, id); } TRACE_WRAPPER void trace_ppb_opengles2_query_end_query_ext(PP_Resource context, GLenum target) { trace_info("[PPB] {zilch} %s context=%d, target=%u(%s)\n", __func__+6, context, target, reverse_gl_enum(target)); ppb_opengles2_query_end_query_ext(context, target); } TRACE_WRAPPER void trace_ppb_opengles2_query_get_queryiv_ext(PP_Resource context, GLenum target, GLenum pname, GLint *params) { trace_info("[PPB] {zilch} %s context=%d, target=%u(%s), pname=%u(%s), params=%p\n", __func__+6, context, target, reverse_gl_enum(target), pname, reverse_gl_enum(pname), params); ppb_opengles2_query_get_queryiv_ext(context, target, pname, params); } TRACE_WRAPPER void trace_ppb_opengles2_query_get_query_objectuiv_ext(PP_Resource context, GLuint id, GLenum pname, GLuint *params) { trace_info("[PPB] {zilch} %s context=%d, id=%u, pname=%u(%s), params=%p\n", __func__+6, context, id, pname, reverse_gl_enum(pname), params); ppb_opengles2_query_get_query_objectuiv_ext(context, id, pname, params); } const struct PPB_OpenGLES2 ppb_opengles2_interface_1_0 = { .ActiveTexture = TWRAPF(ppb_opengles2_ActiveTexture), .AttachShader = TWRAPF(ppb_opengles2_AttachShader), .BindAttribLocation = TWRAPF(ppb_opengles2_BindAttribLocation), .BindBuffer = TWRAPF(ppb_opengles2_BindBuffer), .BindFramebuffer = TWRAPF(ppb_opengles2_BindFramebuffer), .BindRenderbuffer = TWRAPF(ppb_opengles2_BindRenderbuffer), .BindTexture = TWRAPF(ppb_opengles2_BindTexture), .BlendColor = TWRAPF(ppb_opengles2_BlendColor), .BlendEquation = TWRAPF(ppb_opengles2_BlendEquation), .BlendEquationSeparate = TWRAPF(ppb_opengles2_BlendEquationSeparate), .BlendFunc = TWRAPF(ppb_opengles2_BlendFunc), .BlendFuncSeparate = TWRAPF(ppb_opengles2_BlendFuncSeparate), .BufferData = TWRAPF(ppb_opengles2_BufferData), .BufferSubData = TWRAPF(ppb_opengles2_BufferSubData), .CheckFramebufferStatus = TWRAPF(ppb_opengles2_CheckFramebufferStatus), .Clear = TWRAPF(ppb_opengles2_Clear), .ClearColor = TWRAPF(ppb_opengles2_ClearColor), .ClearDepthf = TWRAPF(ppb_opengles2_ClearDepthf), .ClearStencil = TWRAPF(ppb_opengles2_ClearStencil), .ColorMask = TWRAPF(ppb_opengles2_ColorMask), .CompileShader = TWRAPF(ppb_opengles2_CompileShader), .CompressedTexImage2D = TWRAPF(ppb_opengles2_CompressedTexImage2D), .CompressedTexSubImage2D = TWRAPF(ppb_opengles2_CompressedTexSubImage2D), .CopyTexImage2D = TWRAPF(ppb_opengles2_CopyTexImage2D), .CopyTexSubImage2D = TWRAPF(ppb_opengles2_CopyTexSubImage2D), .CreateProgram = TWRAPF(ppb_opengles2_CreateProgram), .CreateShader = TWRAPF(ppb_opengles2_CreateShader), .CullFace = TWRAPF(ppb_opengles2_CullFace), .DeleteBuffers = TWRAPF(ppb_opengles2_DeleteBuffers), .DeleteFramebuffers = TWRAPF(ppb_opengles2_DeleteFramebuffers), .DeleteProgram = TWRAPF(ppb_opengles2_DeleteProgram), .DeleteRenderbuffers = TWRAPF(ppb_opengles2_DeleteRenderbuffers), .DeleteShader = TWRAPF(ppb_opengles2_DeleteShader), .DeleteTextures = TWRAPF(ppb_opengles2_DeleteTextures), .DepthFunc = TWRAPF(ppb_opengles2_DepthFunc), .DepthMask = TWRAPF(ppb_opengles2_DepthMask), .DepthRangef = TWRAPF(ppb_opengles2_DepthRangef), .DetachShader = TWRAPF(ppb_opengles2_DetachShader), .Disable = TWRAPF(ppb_opengles2_Disable), .DisableVertexAttribArray = TWRAPF(ppb_opengles2_DisableVertexAttribArray), .DrawArrays = TWRAPF(ppb_opengles2_DrawArrays), .DrawElements = TWRAPF(ppb_opengles2_DrawElements), .Enable = TWRAPF(ppb_opengles2_Enable), .EnableVertexAttribArray = TWRAPF(ppb_opengles2_EnableVertexAttribArray), .Finish = TWRAPF(ppb_opengles2_Finish), .Flush = TWRAPF(ppb_opengles2_Flush), .FramebufferRenderbuffer = TWRAPF(ppb_opengles2_FramebufferRenderbuffer), .FramebufferTexture2D = TWRAPF(ppb_opengles2_FramebufferTexture2D), .FrontFace = TWRAPF(ppb_opengles2_FrontFace), .GenBuffers = TWRAPF(ppb_opengles2_GenBuffers), .GenerateMipmap = TWRAPF(ppb_opengles2_GenerateMipmap), .GenFramebuffers = TWRAPF(ppb_opengles2_GenFramebuffers), .GenRenderbuffers = TWRAPF(ppb_opengles2_GenRenderbuffers), .GenTextures = TWRAPF(ppb_opengles2_GenTextures), .GetActiveAttrib = TWRAPF(ppb_opengles2_GetActiveAttrib), .GetActiveUniform = TWRAPF(ppb_opengles2_GetActiveUniform), .GetAttachedShaders = TWRAPF(ppb_opengles2_GetAttachedShaders), .GetAttribLocation = TWRAPF(ppb_opengles2_GetAttribLocation), .GetBooleanv = TWRAPF(ppb_opengles2_GetBooleanv), .GetBufferParameteriv = TWRAPF(ppb_opengles2_GetBufferParameteriv), .GetError = TWRAPF(ppb_opengles2_GetError), .GetFloatv = TWRAPF(ppb_opengles2_GetFloatv), .GetFramebufferAttachmentParameteriv = TWRAPF(ppb_opengles2_GetFramebufferAttachmentParameteriv), .GetIntegerv = TWRAPF(ppb_opengles2_GetIntegerv), .GetProgramiv = TWRAPF(ppb_opengles2_GetProgramiv), .GetProgramInfoLog = TWRAPF(ppb_opengles2_GetProgramInfoLog), .GetRenderbufferParameteriv = TWRAPF(ppb_opengles2_GetRenderbufferParameteriv), .GetShaderiv = TWRAPF(ppb_opengles2_GetShaderiv), .GetShaderInfoLog = TWRAPF(ppb_opengles2_GetShaderInfoLog), .GetShaderPrecisionFormat = TWRAPF(ppb_opengles2_GetShaderPrecisionFormat), .GetShaderSource = TWRAPF(ppb_opengles2_GetShaderSource), .GetString = TWRAPF(ppb_opengles2_GetString), .GetTexParameterfv = TWRAPF(ppb_opengles2_GetTexParameterfv), .GetTexParameteriv = TWRAPF(ppb_opengles2_GetTexParameteriv), .GetUniformfv = TWRAPF(ppb_opengles2_GetUniformfv), .GetUniformiv = TWRAPF(ppb_opengles2_GetUniformiv), .GetUniformLocation = TWRAPF(ppb_opengles2_GetUniformLocation), .GetVertexAttribfv = TWRAPF(ppb_opengles2_GetVertexAttribfv), .GetVertexAttribiv = TWRAPF(ppb_opengles2_GetVertexAttribiv), .GetVertexAttribPointerv = TWRAPF(ppb_opengles2_GetVertexAttribPointerv), .Hint = TWRAPF(ppb_opengles2_Hint), .IsBuffer = TWRAPF(ppb_opengles2_IsBuffer), .IsEnabled = TWRAPF(ppb_opengles2_IsEnabled), .IsFramebuffer = TWRAPF(ppb_opengles2_IsFramebuffer), .IsProgram = TWRAPF(ppb_opengles2_IsProgram), .IsRenderbuffer = TWRAPF(ppb_opengles2_IsRenderbuffer), .IsShader = TWRAPF(ppb_opengles2_IsShader), .IsTexture = TWRAPF(ppb_opengles2_IsTexture), .LineWidth = TWRAPF(ppb_opengles2_LineWidth), .LinkProgram = TWRAPF(ppb_opengles2_LinkProgram), .PixelStorei = TWRAPF(ppb_opengles2_PixelStorei), .PolygonOffset = TWRAPF(ppb_opengles2_PolygonOffset), .ReadPixels = TWRAPF(ppb_opengles2_ReadPixels), .ReleaseShaderCompiler = TWRAPF(ppb_opengles2_ReleaseShaderCompiler), .RenderbufferStorage = TWRAPF(ppb_opengles2_RenderbufferStorage), .SampleCoverage = TWRAPF(ppb_opengles2_SampleCoverage), .Scissor = TWRAPF(ppb_opengles2_Scissor), .ShaderBinary = TWRAPF(ppb_opengles2_ShaderBinary), .ShaderSource = TWRAPF(ppb_opengles2_ShaderSource), .StencilFunc = TWRAPF(ppb_opengles2_StencilFunc), .StencilFuncSeparate = TWRAPF(ppb_opengles2_StencilFuncSeparate), .StencilMask = TWRAPF(ppb_opengles2_StencilMask), .StencilMaskSeparate = TWRAPF(ppb_opengles2_StencilMaskSeparate), .StencilOp = TWRAPF(ppb_opengles2_StencilOp), .StencilOpSeparate = TWRAPF(ppb_opengles2_StencilOpSeparate), .TexImage2D = TWRAPF(ppb_opengles2_TexImage2D), .TexParameterf = TWRAPF(ppb_opengles2_TexParameterf), .TexParameterfv = TWRAPF(ppb_opengles2_TexParameterfv), .TexParameteri = TWRAPF(ppb_opengles2_TexParameteri), .TexParameteriv = TWRAPF(ppb_opengles2_TexParameteriv), .TexSubImage2D = TWRAPF(ppb_opengles2_TexSubImage2D), .Uniform1f = TWRAPF(ppb_opengles2_Uniform1f), .Uniform1fv = TWRAPF(ppb_opengles2_Uniform1fv), .Uniform1i = TWRAPF(ppb_opengles2_Uniform1i), .Uniform1iv = TWRAPF(ppb_opengles2_Uniform1iv), .Uniform2f = TWRAPF(ppb_opengles2_Uniform2f), .Uniform2fv = TWRAPF(ppb_opengles2_Uniform2fv), .Uniform2i = TWRAPF(ppb_opengles2_Uniform2i), .Uniform2iv = TWRAPF(ppb_opengles2_Uniform2iv), .Uniform3f = TWRAPF(ppb_opengles2_Uniform3f), .Uniform3fv = TWRAPF(ppb_opengles2_Uniform3fv), .Uniform3i = TWRAPF(ppb_opengles2_Uniform3i), .Uniform3iv = TWRAPF(ppb_opengles2_Uniform3iv), .Uniform4f = TWRAPF(ppb_opengles2_Uniform4f), .Uniform4fv = TWRAPF(ppb_opengles2_Uniform4fv), .Uniform4i = TWRAPF(ppb_opengles2_Uniform4i), .Uniform4iv = TWRAPF(ppb_opengles2_Uniform4iv), .UniformMatrix2fv = TWRAPF(ppb_opengles2_UniformMatrix2fv), .UniformMatrix3fv = TWRAPF(ppb_opengles2_UniformMatrix3fv), .UniformMatrix4fv = TWRAPF(ppb_opengles2_UniformMatrix4fv), .UseProgram = TWRAPF(ppb_opengles2_UseProgram), .ValidateProgram = TWRAPF(ppb_opengles2_ValidateProgram), .VertexAttrib1f = TWRAPF(ppb_opengles2_VertexAttrib1f), .VertexAttrib1fv = TWRAPF(ppb_opengles2_VertexAttrib1fv), .VertexAttrib2f = TWRAPF(ppb_opengles2_VertexAttrib2f), .VertexAttrib2fv = TWRAPF(ppb_opengles2_VertexAttrib2fv), .VertexAttrib3f = TWRAPF(ppb_opengles2_VertexAttrib3f), .VertexAttrib3fv = TWRAPF(ppb_opengles2_VertexAttrib3fv), .VertexAttrib4f = TWRAPF(ppb_opengles2_VertexAttrib4f), .VertexAttrib4fv = TWRAPF(ppb_opengles2_VertexAttrib4fv), .VertexAttribPointer = TWRAPF(ppb_opengles2_VertexAttribPointer), .Viewport = TWRAPF(ppb_opengles2_Viewport), }; const struct PPB_OpenGLES2ChromiumEnableFeature ppb_opengles2_chromium_enable_feature_interface_1_0 = { .EnableFeatureCHROMIUM = TWRAPZ(ppb_opengles2_chromium_enable_feature_enable_feature_chromium), }; const struct PPB_OpenGLES2ChromiumMapSub ppb_opengles2_chromium_map_sub_interface_1_0 = { .MapBufferSubDataCHROMIUM = TWRAPZ(ppb_opengles2_chromium_map_sub_map_buffer_sub_data_chromium), .UnmapBufferSubDataCHROMIUM = TWRAPZ(ppb_opengles2_chromium_map_sub_unmap_buffer_sub_data_chromium), .MapTexSubImage2DCHROMIUM = TWRAPF(ppb_opengles2_chromium_map_sub_map_tex_sub_image_2d_chromium), .UnmapTexSubImage2DCHROMIUM = TWRAPF(ppb_opengles2_chromium_map_sub_unmap_tex_sub_image_2d_chromium), }; const struct PPB_OpenGLES2FramebufferBlit ppb_opengles2_framebuffer_blit_interface_1_0 = { .BlitFramebufferEXT = TWRAPZ(ppb_opengles2_framebuffer_blit_blit_framebuffer_ext), }; const struct PPB_OpenGLES2FramebufferMultisample ppb_opengles2_framebuffer_multisample_interface_1_0 = { .RenderbufferStorageMultisampleEXT = TWRAPZ(ppb_opengles2_framebuffer_multisample_renderbuffer_storage_multisample_ext), }; const struct PPB_OpenGLES2InstancedArrays ppb_opengles2_instanced_arrays_interface_1_0 = { .DrawArraysInstancedANGLE = TWRAPZ(ppb_opengles2_instanced_arrays_draw_arrays_instanced_angle), .DrawElementsInstancedANGLE =TWRAPZ(ppb_opengles2_instanced_arrays_draw_elements_instanced_angle), .VertexAttribDivisorANGLE = TWRAPZ(ppb_opengles2_instanced_arrays_vertex_attrib_divisor_angle), }; const struct PPB_OpenGLES2Query ppb_opengles2_query_interface_1_0 = { .GenQueriesEXT = TWRAPZ(ppb_opengles2_query_gen_queries_ext), .DeleteQueriesEXT = TWRAPZ(ppb_opengles2_query_delete_queries_ext), .IsQueryEXT = TWRAPZ(ppb_opengles2_query_is_query_ext), .BeginQueryEXT = TWRAPZ(ppb_opengles2_query_begin_query_ext), .EndQueryEXT = TWRAPZ(ppb_opengles2_query_end_query_ext), .GetQueryivEXT = TWRAPZ(ppb_opengles2_query_get_queryiv_ext), .GetQueryObjectuivEXT = TWRAPZ(ppb_opengles2_query_get_query_objectuiv_ext), }; static void __attribute__((constructor)) constructor_ppb_opengles2(void) { #if !HAVE_GLES2 shader_type_ht = g_hash_table_new(g_direct_hash, g_direct_equal); shader_source_ht = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free); #endif register_interface(PPB_OPENGLES2_CHROMIUMENABLEFEATURE_INTERFACE_1_0, &ppb_opengles2_chromium_enable_feature_interface_1_0); register_interface(PPB_OPENGLES2_CHROMIUMMAPSUB_INTERFACE_1_0, &ppb_opengles2_chromium_map_sub_interface_1_0); register_interface(PPB_OPENGLES2_FRAMEBUFFERBLIT_INTERFACE_1_0, &ppb_opengles2_framebuffer_blit_interface_1_0); register_interface(PPB_OPENGLES2_FRAMEBUFFERMULTISAMPLE_INTERFACE_1_0, &ppb_opengles2_framebuffer_multisample_interface_1_0); register_interface(PPB_OPENGLES2_INSTANCEDARRAYS_INTERFACE_1_0, &ppb_opengles2_instanced_arrays_interface_1_0); register_interface(PPB_OPENGLES2_INTERFACE_1_0, &ppb_opengles2_interface_1_0); register_interface(PPB_OPENGLES2_QUERY_INTERFACE_1_0, &ppb_opengles2_query_interface_1_0); } freshplayerplugin-0.3.9/src/ppb_opengles2.h000066400000000000000000000466761321746453100210160ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include void ppb_opengles2_ActiveTexture(PP_Resource context, GLenum texture); void ppb_opengles2_AttachShader(PP_Resource context, GLuint program, GLuint shader); void ppb_opengles2_BindAttribLocation(PP_Resource context, GLuint program, GLuint index, const char *name); void ppb_opengles2_BindBuffer(PP_Resource context, GLenum target, GLuint buffer); void ppb_opengles2_BindFramebuffer(PP_Resource context, GLenum target, GLuint framebuffer); void ppb_opengles2_BindRenderbuffer(PP_Resource context, GLenum target, GLuint renderbuffer); void ppb_opengles2_BindTexture(PP_Resource context, GLenum target, GLuint texture); void ppb_opengles2_BlendColor(PP_Resource context, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); void ppb_opengles2_BlendEquation(PP_Resource context, GLenum mode); void ppb_opengles2_BlendEquationSeparate(PP_Resource context, GLenum modeRGB, GLenum modeAlpha); void ppb_opengles2_BlendFunc(PP_Resource context, GLenum sfactor, GLenum dfactor); void ppb_opengles2_BlendFuncSeparate(PP_Resource context, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); void ppb_opengles2_BufferData(PP_Resource context, GLenum target, GLsizeiptr size, const void *data, GLenum usage); void ppb_opengles2_BufferSubData(PP_Resource context, GLenum target, GLintptr offset, GLsizeiptr size, const void *data); GLenum ppb_opengles2_CheckFramebufferStatus(PP_Resource context, GLenum target); void ppb_opengles2_Clear(PP_Resource context, GLbitfield mask); void ppb_opengles2_ClearColor(PP_Resource context, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); void ppb_opengles2_ClearDepthf(PP_Resource context, GLclampf depth); void ppb_opengles2_ClearStencil(PP_Resource context, GLint s); void ppb_opengles2_ColorMask(PP_Resource context, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); void ppb_opengles2_CompileShader(PP_Resource context, GLuint shader); void ppb_opengles2_CompressedTexImage2D(PP_Resource context, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); void ppb_opengles2_CompressedTexSubImage2D(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); void ppb_opengles2_CopyTexImage2D(PP_Resource context, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); void ppb_opengles2_CopyTexSubImage2D(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); GLuint ppb_opengles2_CreateProgram(PP_Resource context); GLuint ppb_opengles2_CreateShader(PP_Resource context, GLenum type); void ppb_opengles2_CullFace(PP_Resource context, GLenum mode); void ppb_opengles2_DeleteBuffers(PP_Resource context, GLsizei n, const GLuint *buffers); void ppb_opengles2_DeleteFramebuffers(PP_Resource context, GLsizei n, const GLuint *framebuffers); void ppb_opengles2_DeleteProgram(PP_Resource context, GLuint program); void ppb_opengles2_DeleteRenderbuffers(PP_Resource context, GLsizei n, const GLuint *renderbuffers); void ppb_opengles2_DeleteShader(PP_Resource context, GLuint shader); void ppb_opengles2_DeleteTextures(PP_Resource context, GLsizei n, const GLuint *textures); void ppb_opengles2_DepthFunc(PP_Resource context, GLenum func); void ppb_opengles2_DepthMask(PP_Resource context, GLboolean flag); void ppb_opengles2_DepthRangef(PP_Resource context, GLclampf zNear, GLclampf zFar); void ppb_opengles2_DetachShader(PP_Resource context, GLuint program, GLuint shader); void ppb_opengles2_Disable(PP_Resource context, GLenum cap); void ppb_opengles2_DisableVertexAttribArray(PP_Resource context, GLuint index); void ppb_opengles2_DrawArrays(PP_Resource context, GLenum mode, GLint first, GLsizei count); void ppb_opengles2_DrawElements(PP_Resource context, GLenum mode, GLsizei count, GLenum type, const void *indices); void ppb_opengles2_Enable(PP_Resource context, GLenum cap); void ppb_opengles2_EnableVertexAttribArray(PP_Resource context, GLuint index); void ppb_opengles2_Finish(PP_Resource context); void ppb_opengles2_Flush(PP_Resource context); void ppb_opengles2_FramebufferRenderbuffer(PP_Resource context, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); void ppb_opengles2_FramebufferTexture2D(PP_Resource context, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); void ppb_opengles2_FrontFace(PP_Resource context, GLenum mode); void ppb_opengles2_GenBuffers(PP_Resource context, GLsizei n, GLuint *buffers); void ppb_opengles2_GenerateMipmap(PP_Resource context, GLenum target); void ppb_opengles2_GenFramebuffers(PP_Resource context, GLsizei n, GLuint *framebuffers); void ppb_opengles2_GenRenderbuffers(PP_Resource context, GLsizei n, GLuint *renderbuffers); void ppb_opengles2_GenTextures(PP_Resource context, GLsizei n, GLuint *textures); void ppb_opengles2_GetActiveAttrib(PP_Resource context, GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name); void ppb_opengles2_GetActiveUniform(PP_Resource context, GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name); void ppb_opengles2_GetAttachedShaders(PP_Resource context, GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders); GLint ppb_opengles2_GetAttribLocation(PP_Resource context, GLuint program, const char *name); void ppb_opengles2_GetBooleanv(PP_Resource context, GLenum pname, GLboolean *params); void ppb_opengles2_GetBufferParameteriv(PP_Resource context, GLenum target, GLenum pname, GLint *params); GLenum ppb_opengles2_GetError(PP_Resource context); void ppb_opengles2_GetFloatv(PP_Resource context, GLenum pname, GLfloat *params); void ppb_opengles2_GetFramebufferAttachmentParameteriv(PP_Resource context, GLenum target, GLenum attachment, GLenum pname, GLint *params); void ppb_opengles2_GetIntegerv(PP_Resource context, GLenum pname, GLint *params); void ppb_opengles2_GetProgramiv(PP_Resource context, GLuint program, GLenum pname, GLint *params); void ppb_opengles2_GetProgramInfoLog(PP_Resource context, GLuint program, GLsizei bufsize, GLsizei *length, char *infolog); void ppb_opengles2_GetRenderbufferParameteriv(PP_Resource context, GLenum target, GLenum pname, GLint *params); void ppb_opengles2_GetShaderiv(PP_Resource context, GLuint shader, GLenum pname, GLint *params); void ppb_opengles2_GetShaderInfoLog(PP_Resource context, GLuint shader, GLsizei bufsize, GLsizei *length, char *infolog); void ppb_opengles2_GetShaderPrecisionFormat(PP_Resource context, GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); void ppb_opengles2_GetShaderSource(PP_Resource context, GLuint shader, GLsizei bufsize, GLsizei *length, char *source); const GLubyte * ppb_opengles2_GetString(PP_Resource context, GLenum name); void ppb_opengles2_GetTexParameterfv(PP_Resource context, GLenum target, GLenum pname, GLfloat *params); void ppb_opengles2_GetTexParameteriv(PP_Resource context, GLenum target, GLenum pname, GLint *params); void ppb_opengles2_GetUniformfv(PP_Resource context, GLuint program, GLint location, GLfloat *params); void ppb_opengles2_GetUniformiv(PP_Resource context, GLuint program, GLint location, GLint *params); GLint ppb_opengles2_GetUniformLocation(PP_Resource context, GLuint program, const char *name); void ppb_opengles2_GetVertexAttribfv(PP_Resource context, GLuint index, GLenum pname, GLfloat *params); void ppb_opengles2_GetVertexAttribiv(PP_Resource context, GLuint index, GLenum pname, GLint *params); void ppb_opengles2_GetVertexAttribPointerv(PP_Resource context, GLuint index, GLenum pname, void **pointer); void ppb_opengles2_Hint(PP_Resource context, GLenum target, GLenum mode); GLboolean ppb_opengles2_IsBuffer(PP_Resource context, GLuint buffer); GLboolean ppb_opengles2_IsEnabled(PP_Resource context, GLenum cap); GLboolean ppb_opengles2_IsFramebuffer(PP_Resource context, GLuint framebuffer); GLboolean ppb_opengles2_IsProgram(PP_Resource context, GLuint program); GLboolean ppb_opengles2_IsRenderbuffer(PP_Resource context, GLuint renderbuffer); GLboolean ppb_opengles2_IsShader(PP_Resource context, GLuint shader); GLboolean ppb_opengles2_IsTexture(PP_Resource context, GLuint texture); void ppb_opengles2_LineWidth(PP_Resource context, GLfloat width); void ppb_opengles2_LinkProgram(PP_Resource context, GLuint program); void ppb_opengles2_PixelStorei(PP_Resource context, GLenum pname, GLint param); void ppb_opengles2_PolygonOffset(PP_Resource context, GLfloat factor, GLfloat units); void ppb_opengles2_ReadPixels(PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); void ppb_opengles2_ReleaseShaderCompiler(PP_Resource context); void ppb_opengles2_RenderbufferStorage(PP_Resource context, GLenum target, GLenum internalformat, GLsizei width, GLsizei height); void ppb_opengles2_SampleCoverage(PP_Resource context, GLclampf value, GLboolean invert); void ppb_opengles2_Scissor(PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height); void ppb_opengles2_ShaderBinary(PP_Resource context, GLsizei n, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); void ppb_opengles2_ShaderSource(PP_Resource context, GLuint shader, GLsizei count, const char **str, const GLint *length); void ppb_opengles2_StencilFunc(PP_Resource context, GLenum func, GLint ref, GLuint mask); void ppb_opengles2_StencilFuncSeparate(PP_Resource context, GLenum face, GLenum func, GLint ref, GLuint mask); void ppb_opengles2_StencilMask(PP_Resource context, GLuint mask); void ppb_opengles2_StencilMaskSeparate(PP_Resource context, GLenum face, GLuint mask); void ppb_opengles2_StencilOp(PP_Resource context, GLenum fail, GLenum zfail, GLenum zpass); void ppb_opengles2_StencilOpSeparate(PP_Resource context, GLenum face, GLenum fail, GLenum zfail, GLenum zpass); void ppb_opengles2_TexImage2D(PP_Resource context, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); void ppb_opengles2_TexParameterf(PP_Resource context, GLenum target, GLenum pname, GLfloat param); void ppb_opengles2_TexParameterfv(PP_Resource context, GLenum target, GLenum pname, const GLfloat *params); void ppb_opengles2_TexParameteri(PP_Resource context, GLenum target, GLenum pname, GLint param); void ppb_opengles2_TexParameteriv(PP_Resource context, GLenum target, GLenum pname, const GLint *params); void ppb_opengles2_TexSubImage2D(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); void ppb_opengles2_Uniform1f(PP_Resource context, GLint location, GLfloat x); void ppb_opengles2_Uniform1fv(PP_Resource context, GLint location, GLsizei count, const GLfloat *v); void ppb_opengles2_Uniform1i(PP_Resource context, GLint location, GLint x); void ppb_opengles2_Uniform1iv(PP_Resource context, GLint location, GLsizei count, const GLint *v); void ppb_opengles2_Uniform2f(PP_Resource context, GLint location, GLfloat x, GLfloat y); void ppb_opengles2_Uniform2fv(PP_Resource context, GLint location, GLsizei count, const GLfloat *v); void ppb_opengles2_Uniform2i(PP_Resource context, GLint location, GLint x, GLint y); void ppb_opengles2_Uniform2iv(PP_Resource context, GLint location, GLsizei count, const GLint *v); void ppb_opengles2_Uniform3f(PP_Resource context, GLint location, GLfloat x, GLfloat y, GLfloat z); void ppb_opengles2_Uniform3fv(PP_Resource context, GLint location, GLsizei count, const GLfloat *v); void ppb_opengles2_Uniform3i(PP_Resource context, GLint location, GLint x, GLint y, GLint z); void ppb_opengles2_Uniform3iv(PP_Resource context, GLint location, GLsizei count, const GLint *v); void ppb_opengles2_Uniform4f(PP_Resource context, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); void ppb_opengles2_Uniform4fv(PP_Resource context, GLint location, GLsizei count, const GLfloat *v); void ppb_opengles2_Uniform4i(PP_Resource context, GLint location, GLint x, GLint y, GLint z, GLint w); void ppb_opengles2_Uniform4iv(PP_Resource context, GLint location, GLsizei count, const GLint *v); void ppb_opengles2_UniformMatrix2fv(PP_Resource context, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); void ppb_opengles2_UniformMatrix3fv(PP_Resource context, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); void ppb_opengles2_UniformMatrix4fv(PP_Resource context, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); void ppb_opengles2_UseProgram(PP_Resource context, GLuint program); void ppb_opengles2_ValidateProgram(PP_Resource context, GLuint program); void ppb_opengles2_VertexAttrib1f(PP_Resource context, GLuint indx, GLfloat x); void ppb_opengles2_VertexAttrib1fv(PP_Resource context, GLuint indx, const GLfloat *values); void ppb_opengles2_VertexAttrib2f(PP_Resource context, GLuint indx, GLfloat x, GLfloat y); void ppb_opengles2_VertexAttrib2fv(PP_Resource context, GLuint indx, const GLfloat *values); void ppb_opengles2_VertexAttrib3f(PP_Resource context, GLuint indx, GLfloat x, GLfloat y, GLfloat z); void ppb_opengles2_VertexAttrib3fv(PP_Resource context, GLuint indx, const GLfloat *values); void ppb_opengles2_VertexAttrib4f(PP_Resource context, GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); void ppb_opengles2_VertexAttrib4fv(PP_Resource context, GLuint indx, const GLfloat *values); void ppb_opengles2_VertexAttribPointer(PP_Resource context, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *ptr); void ppb_opengles2_Viewport(PP_Resource context, GLint x, GLint y, GLsizei width, GLsizei height); GLboolean ppb_opengles2_chromium_enable_feature_enable_feature_chromium(PP_Resource context, const char *feature); void * ppb_opengles2_chromium_map_sub_map_buffer_sub_data_chromium(PP_Resource context, GLuint target, GLintptr offset, GLsizeiptr size, GLenum access); void ppb_opengles2_chromium_map_sub_unmap_buffer_sub_data_chromium(PP_Resource context, const void *mem); void * ppb_opengles2_chromium_map_sub_map_tex_sub_image_2d_chromium(PP_Resource context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLenum access); void ppb_opengles2_chromium_map_sub_unmap_tex_sub_image_2d_chromium(PP_Resource context, const void *mem); void ppb_opengles2_framebuffer_blit_blit_framebuffer_ext(PP_Resource context, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); void ppb_opengles2_framebuffer_multisample_renderbuffer_storage_multisample_ext (PP_Resource context, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); void ppb_opengles2_instanced_arrays_draw_arrays_instanced_angle(PP_Resource context, GLenum mode, GLint first, GLsizei count, GLsizei primcount); void ppb_opengles2_instanced_arrays_draw_elements_instanced_angle(PP_Resource context, GLenum mode, GLsizei count, GLenum type, const void *indices,GLsizei primcount); void ppb_opengles2_instanced_arrays_vertex_attrib_divisor_angle(PP_Resource context, GLuint index, GLuint divisor); void ppb_opengles2_query_gen_queries_ext(PP_Resource context, GLsizei n, GLuint *queries); void ppb_opengles2_query_delete_queries_ext(PP_Resource context, GLsizei n, const GLuint *queries); GLboolean ppb_opengles2_query_is_query_ext(PP_Resource context, GLuint id); void ppb_opengles2_query_begin_query_ext(PP_Resource context, GLenum target, GLuint id); void ppb_opengles2_query_end_query_ext(PP_Resource context, GLenum target); void ppb_opengles2_query_get_queryiv_ext(PP_Resource context, GLenum target, GLenum pname,GLint *params); void ppb_opengles2_query_get_query_objectuiv_ext(PP_Resource context, GLuint id, GLenum pname, GLuint *params); freshplayerplugin-0.3.9/src/ppb_pdf.c000066400000000000000000000244401321746453100176450ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "config_priv.h" #include "pp_interface.h" #include "ppb_flash_font_file.h" #include "ppb_pdf.h" #include "reverse_constant.h" #include "trace_core.h" #include "trace_helpers.h" #include #include #include static GMappedFile *natives_blob = NULL; static GMappedFile *snapshot_blob = NULL; static void __attribute__((destructor)) destructor_ppb_pdf(void) { if (natives_blob) { g_mapped_file_unref(natives_blob); natives_blob = NULL; } if (snapshot_blob) { g_mapped_file_unref(snapshot_blob); snapshot_blob = NULL; } } PP_Resource ppb_pdf_get_font_file_with_fallback(PP_Instance instance, const struct PP_BrowserFont_Trusted_Description *description, PP_PrivateFontCharset charset) { return ppb_flash_font_file_create(instance, description, charset); } bool ppb_pdf_get_font_table_for_private_font_file(PP_Resource font_file, uint32_t table, void *output, uint32_t *output_length) { return ppb_flash_font_file_get_font_table(font_file, table, output, output_length); } void ppb_pdf_search_string(PP_Instance instance, const unsigned short *string, const unsigned short *term, bool case_sensitive, struct PP_PrivateFindResult **results, int *count) { } void ppb_pdf_did_start_loading(PP_Instance instance) { } void ppb_pdf_did_stop_loading(PP_Instance instance) { } void ppb_pdf_set_content_restriction(PP_Instance instance, int restrictions) { } void ppb_pdf_user_metrics_record_action(PP_Instance instance, struct PP_Var action) { } void ppb_pdf_has_unsupported_feature(PP_Instance instance) { } void ppb_pdf_save_as(PP_Instance instance) { } void ppb_pdf_print(PP_Instance instance) { } PP_Bool ppb_pdf_is_feature_enabled(PP_Instance instance, PP_PDFFeature feature) { return false; } void ppb_pdf_set_selected_text(PP_Instance instance, const char *selected_text) { } void ppb_pdf_set_link_under_cursor(PP_Instance instance, const char *url) { } void ppb_pdf_get_v8_external_snapshot_data(PP_Instance instance, const char **natives_data_out, int *natives_size_out, const char **snapshot_data_out, int *snapshot_size_out) { if (!natives_blob || !snapshot_blob) { gchar *tmp = g_strdup(fpp_config_get_plugin_path()); gchar *module_dir = dirname(tmp); gchar *natives_path = g_strdup_printf("%s/natives_blob.bin", module_dir); gchar *snapshot_path = g_strdup_printf("%s/snapshot_blob.bin", module_dir); natives_blob = g_mapped_file_new(natives_path, FALSE, NULL); snapshot_blob = g_mapped_file_new(snapshot_path, FALSE, NULL); g_free(tmp); g_free(natives_path); g_free(snapshot_path); } *natives_data_out = natives_blob ? g_mapped_file_get_contents(natives_blob) : NULL; *natives_size_out = natives_blob ? g_mapped_file_get_length(natives_blob) : 0; *snapshot_data_out = snapshot_blob ? g_mapped_file_get_contents(snapshot_blob) : NULL; *snapshot_size_out = snapshot_blob ? g_mapped_file_get_length(snapshot_blob) : 0; } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_pdf_get_font_file_with_fallback(PP_Instance instance, const struct PP_BrowserFont_Trusted_Description *description, PP_PrivateFontCharset charset) { gchar *s_face = trace_var_as_string(description->face); trace_info("[PPB] {full} %s instance=%d, description={.face=%s, .family=%u, .size=%u, " ".weight=%u, .italic=%u, .small_caps=%u, .letter_spacing=%d, .word_spacing=%d}, " "charset=%s(%u)\n", __func__+6, instance, s_face, description->family, description->size, description->weight, description->italic, description->small_caps, description->letter_spacing, description->word_spacing, reverse_private_font_charset(charset), charset); g_free(s_face); return ppb_pdf_get_font_file_with_fallback(instance, description, charset); } TRACE_WRAPPER bool trace_ppb_pdf_get_font_table_for_private_font_file(PP_Resource font_file, uint32_t table, void *output, uint32_t *output_length) { trace_info("[PPB] {full} %s font_file=%d, table=0x%08x\n", __func__+6, font_file, table); return ppb_pdf_get_font_table_for_private_font_file(font_file, table, output, output_length); } TRACE_WRAPPER void trace_ppb_pdf_search_string(PP_Instance instance, const unsigned short *string, const unsigned short *term, bool case_sensitive, struct PP_PrivateFindResult **results, int *count) { trace_info("[PPB] {zilch} %s instance=%d, string=%p, term=%p, case_sensitive=%u\n", __func__+6, instance, string, term, case_sensitive); ppb_pdf_search_string(instance, string, term, case_sensitive, results, count); } TRACE_WRAPPER void trace_ppb_pdf_did_start_loading(PP_Instance instance) { trace_info("[PPB] {zilch} %s instance=%d\n", __func__+6, instance); ppb_pdf_did_start_loading(instance); } TRACE_WRAPPER void trace_ppb_pdf_did_stop_loading(PP_Instance instance) { trace_info("[PPB] {zilch} %s instance=%d\n", __func__+6, instance); ppb_pdf_did_stop_loading(instance); } TRACE_WRAPPER void trace_ppb_pdf_set_content_restriction(PP_Instance instance, int restrictions) { trace_info("[PPB] {zilch} %s instance=%d, restrictions=%d\n", __func__+6, instance, restrictions); ppb_pdf_set_content_restriction(instance, restrictions); } TRACE_WRAPPER void trace_ppb_pdf_user_metrics_record_action(PP_Instance instance, struct PP_Var action) { gchar *s_action = trace_var_as_string(action); trace_info("[PPB] {zilch} %s instance=%d, action=%s\n", __func__+6, instance, s_action); g_free(s_action); ppb_pdf_user_metrics_record_action(instance, action); } TRACE_WRAPPER void trace_ppb_pdf_has_unsupported_feature(PP_Instance instance) { trace_info("[PPB] {zilch} %s instance=%d\n", __func__+6, instance); ppb_pdf_has_unsupported_feature(instance); } TRACE_WRAPPER void trace_ppb_pdf_save_as(PP_Instance instance) { trace_info("[PPB] {zilch} %s instance=%d\n", __func__+6, instance); ppb_pdf_save_as(instance); } TRACE_WRAPPER void trace_ppb_pdf_print(PP_Instance instance) { trace_info("[PPB] {zilch} %s instance=%d\n", __func__+6, instance); ppb_pdf_print(instance); } TRACE_WRAPPER PP_Bool trace_ppb_pdf_is_feature_enabled(PP_Instance instance, PP_PDFFeature feature) { trace_info("[PPB] {zilch} %s instance=%d, feature=%s(%u)\n", __func__+6, instance, reverse_pdf_feature(feature), feature); return ppb_pdf_is_feature_enabled(instance, feature); } TRACE_WRAPPER void trace_ppb_pdf_set_selected_text(PP_Instance instance, const char *selected_text) { trace_info("[PPB] {zilch} %s instance=%d, selected_text=%s\n", __func__+6, instance, selected_text); ppb_pdf_set_selected_text(instance, selected_text); } TRACE_WRAPPER void trace_ppb_pdf_set_link_under_cursor(PP_Instance instance, const char *url) { trace_info("[PPB] {zilch} %s instance=%d, url=%s\n", __func__+6, instance, url); ppb_pdf_set_link_under_cursor(instance, url); } TRACE_WRAPPER void trace_ppb_pdf_get_v8_external_snapshot_data(PP_Instance instance, const char **natives_data_out, int *natives_size_out, const char **snapshot_data_out, int *snapshot_size_out) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); ppb_pdf_get_v8_external_snapshot_data(instance, natives_data_out, natives_size_out, snapshot_data_out, snapshot_size_out); } const struct PPB_PDF ppb_pdf_interface = { .GetFontFileWithFallback = TWRAPF(ppb_pdf_get_font_file_with_fallback), .GetFontTableForPrivateFontFile = TWRAPF(ppb_pdf_get_font_table_for_private_font_file), .SearchString = TWRAPZ(ppb_pdf_search_string), .DidStartLoading = TWRAPZ(ppb_pdf_did_start_loading), .DidStopLoading = TWRAPZ(ppb_pdf_did_stop_loading), .SetContentRestriction = TWRAPZ(ppb_pdf_set_content_restriction), .UserMetricsRecordAction = TWRAPZ(ppb_pdf_user_metrics_record_action), .HasUnsupportedFeature = TWRAPZ(ppb_pdf_has_unsupported_feature), .SaveAs = TWRAPZ(ppb_pdf_save_as), .Print = TWRAPZ(ppb_pdf_print), .IsFeatureEnabled = TWRAPZ(ppb_pdf_is_feature_enabled), .SetSelectedText = TWRAPZ(ppb_pdf_set_selected_text), .SetLinkUnderCursor = TWRAPZ(ppb_pdf_set_link_under_cursor), .GetV8ExternalSnapshotData = TWRAPF(ppb_pdf_get_v8_external_snapshot_data), }; static void __attribute__((constructor)) constructor_ppb_pdf(void) { register_interface(PPB_PDF_INTERFACE, &ppb_pdf_interface); } freshplayerplugin-0.3.9/src/ppb_pdf.h000066400000000000000000000056021321746453100176510ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include #include PP_Resource ppb_pdf_get_font_file_with_fallback(PP_Instance instance, const struct PP_BrowserFont_Trusted_Description *description, PP_PrivateFontCharset charset); bool ppb_pdf_get_font_table_for_private_font_file(PP_Resource font_file, uint32_t table, void *output, uint32_t *output_length); void ppb_pdf_search_string(PP_Instance instance, const unsigned short *string, const unsigned short *term, bool case_sensitive, struct PP_PrivateFindResult **results, int *count); void ppb_pdf_did_start_loading(PP_Instance instance); void ppb_pdf_did_stop_loading(PP_Instance instance); void ppb_pdf_set_content_restriction(PP_Instance instance, int restrictions); void ppb_pdf_histogram_p_d_f_page_count(PP_Instance instance, int count); void ppb_pdf_user_metrics_record_action(PP_Instance instance, struct PP_Var action); void ppb_pdf_has_unsupported_feature(PP_Instance instance); void ppb_pdf_save_as(PP_Instance instance); void ppb_pdf_print(PP_Instance instance); PP_Bool ppb_pdf_is_feature_enabled(PP_Instance instance, PP_PDFFeature feature); void ppb_pdf_set_selected_text(PP_Instance instance, const char *selected_text); void ppb_pdf_set_link_under_cursor(PP_Instance instance, const char *url); void ppb_pdf_get_v8_external_snapshot_data(PP_Instance instance, const char **natives_data_out, int *natives_size_out, const char **snapshot_data_out, int *snapshot_size_out); freshplayerplugin-0.3.9/src/ppb_printing.c000066400000000000000000000063061321746453100207270ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "pp_resource.h" #include "ppb_printing.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" struct pp_printing_s { COMMON_STRUCTURE_FIELDS }; STATIC_ASSERT(sizeof(struct pp_printing_s) <= LARGEST_RESOURCE_SIZE); PP_Resource ppb_printing_create(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource printing = pp_resource_allocate(PP_RESOURCE_PRINTING, pp_i); return printing; } static void ppb_printing_destroy(void *ptr) { } int32_t ppb_printing_get_default_print_settings(PP_Resource resource, struct PP_PrintSettings_Dev *print_settings, struct PP_CompletionCallback callback) { return 0; } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_printing_create(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_printing_create(instance); } TRACE_WRAPPER int32_t trace_ppb_printing_get_default_print_settings(PP_Resource resource, struct PP_PrintSettings_Dev *print_settings, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s resource=%d, callback={.func=%p, .user_data=%p, .flags=%d}\n", __func__+6, resource, callback.func, callback.user_data, callback.flags); return ppb_printing_get_default_print_settings(resource, print_settings, callback); } const struct PPB_Printing_Dev_0_7 ppb_printing_dev_interface_0_7 = { .Create = TWRAPF(ppb_printing_create), .GetDefaultPrintSettings = TWRAPZ(ppb_printing_get_default_print_settings), }; static void __attribute__((constructor)) constructor_ppb_printing(void) { register_interface(PPB_PRINTING_DEV_INTERFACE_0_7, &ppb_printing_dev_interface_0_7); register_resource(PP_RESOURCE_PRINTING, ppb_printing_destroy); } freshplayerplugin-0.3.9/src/ppb_printing.h000066400000000000000000000027601321746453100207340ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include PP_Resource ppb_printing_create(PP_Instance instance); int32_t ppb_printing_get_default_print_settings(PP_Resource resource, struct PP_PrintSettings_Dev *print_settings, struct PP_CompletionCallback callback); freshplayerplugin-0.3.9/src/ppb_tcp_socket.c000066400000000000000000000373161321746453100212400ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "async_network.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_message_loop.h" #include "ppb_tcp_socket.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "utils.h" #include #include STATIC_ASSERT(sizeof(struct pp_tcp_socket_s) <= LARGEST_RESOURCE_SIZE); PP_Resource ppb_tcp_socket_create(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource tcp_socket = pp_resource_allocate(PP_RESOURCE_TCP_SOCKET, pp_i); struct pp_tcp_socket_s *ts = pp_resource_acquire(tcp_socket, PP_RESOURCE_TCP_SOCKET); if (!ts) { trace_error("%s, resource allocation failure\n", __func__); return 0; } ts->sock = socket(AF_INET, SOCK_STREAM, 0); pp_resource_release(tcp_socket); return tcp_socket; } static void ppb_tcp_socket_destroy(void *ptr) { struct pp_tcp_socket_s *ts = ptr; if (!ts->destroyed) { struct async_network_task_s *task = async_network_task_create(); ts->destroyed = 1; ts->is_connected = 0; task->type = ASYNC_NETWORK_DISCONNECT; task->resource = ts->self_id; task->sock = ts->sock; async_network_task_push(task); } } PP_Bool ppb_tcp_socket_is_tcp_socket(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_TCP_SOCKET; } int32_t ppb_tcp_socket_connect(PP_Resource tcp_socket, const char *host, uint16_t port, struct PP_CompletionCallback callback) { struct pp_tcp_socket_s *ts = pp_resource_acquire(tcp_socket, PP_RESOURCE_TCP_SOCKET); if (!ts) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } struct async_network_task_s *task = async_network_task_create(); task->type = ASYNC_NETWORK_TCP_CONNECT; task->resource = tcp_socket; task->sock = ts->sock; task->host = nullsafe_strdup(host); task->port = port; task->callback = callback; task->callback_ml = ppb_message_loop_get_current(); pp_resource_release(tcp_socket); async_network_task_push(task); return PP_OK_COMPLETIONPENDING; } int32_t ppb_tcp_socket_connect_with_net_address(PP_Resource tcp_socket, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback) { struct pp_tcp_socket_s *ts = pp_resource_acquire(tcp_socket, PP_RESOURCE_TCP_SOCKET); if (!ts) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } struct async_network_task_s *task = async_network_task_create(); task->type = ASYNC_NETWORK_TCP_CONNECT_WITH_NETADDRESS; task->resource = tcp_socket; task->sock = ts->sock; task->netaddr = *addr; task->callback = callback; task->callback_ml = ppb_message_loop_get_current(); pp_resource_release(tcp_socket); async_network_task_push(task); return PP_OK_COMPLETIONPENDING; } PP_Bool ppb_tcp_socket_get_local_address(PP_Resource tcp_socket, struct PP_NetAddress_Private *local_addr) { struct pp_tcp_socket_s *ts = pp_resource_acquire(tcp_socket, PP_RESOURCE_TCP_SOCKET); if (!ts) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } if (!ts->is_connected) { trace_warning("%s, not connected\n", __func__); pp_resource_release(tcp_socket); return PP_FALSE; } socklen_t len = sizeof(local_addr->data); int ret = getsockname(ts->sock, (struct sockaddr *)local_addr->data, &len); local_addr->size = len; pp_resource_release(tcp_socket); return ret == 0 ? PP_TRUE : PP_FALSE; } PP_Bool ppb_tcp_socket_get_remote_address(PP_Resource tcp_socket, struct PP_NetAddress_Private *remote_addr) { struct pp_tcp_socket_s *ts = pp_resource_acquire(tcp_socket, PP_RESOURCE_TCP_SOCKET); if (!ts) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } if (!ts->is_connected) { trace_warning("%s, not connected\n", __func__); pp_resource_release(tcp_socket); return PP_FALSE; } socklen_t len = sizeof(remote_addr->data); int ret = getpeername(ts->sock, (struct sockaddr *)remote_addr->data, &len); remote_addr->size = len; pp_resource_release(tcp_socket); return ret == 0 ? PP_TRUE : PP_FALSE; } int32_t ppb_tcp_socket_ssl_handshake(PP_Resource tcp_socket, const char *server_name, uint16_t server_port, struct PP_CompletionCallback callback) { return -1; } PP_Resource ppb_tcp_socket_get_server_certificate(PP_Resource tcp_socket) { return 0; } PP_Bool ppb_tcp_socket_add_chain_building_certificate(PP_Resource tcp_socket, PP_Resource certificate, PP_Bool is_trusted) { return PP_FALSE; } int32_t ppb_tcp_socket_read(PP_Resource tcp_socket, char *buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback) { if (bytes_to_read <= 0) { trace_error("%s, bytes_to_read <= 0\n", __func__); return PP_ERROR_BADARGUMENT; } struct pp_tcp_socket_s *ts = pp_resource_acquire(tcp_socket, PP_RESOURCE_TCP_SOCKET); if (!ts) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } if (!ts->is_connected) { trace_warning("%s, not connected\n", __func__); pp_resource_release(tcp_socket); return PP_ERROR_FAILED; } if (ts->seen_eof) { trace_warning("%s, seen eof\n", __func__); pp_resource_release(tcp_socket); return PP_ERROR_FAILED; } if (bytes_to_read > 1024 * 1024) bytes_to_read = 1024 * 1024; struct async_network_task_s *task = async_network_task_create(); task->type = ASYNC_NETWORK_TCP_READ; task->resource = tcp_socket; task->buffer = buffer; task->bufsize = bytes_to_read; task->callback = callback; task->callback_ml = ppb_message_loop_get_current(); pp_resource_release(tcp_socket); async_network_task_push(task); return PP_OK_COMPLETIONPENDING; } int32_t ppb_tcp_socket_write(PP_Resource tcp_socket, const char *buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback) { if (bytes_to_write <= 0) { trace_error("%s, bytes_to_write <= 0\n", __func__); return PP_ERROR_BADARGUMENT; } struct pp_tcp_socket_s *ts = pp_resource_acquire(tcp_socket, PP_RESOURCE_TCP_SOCKET); if (!ts) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } if (!ts->is_connected) { trace_warning("%s, not connected\n", __func__); pp_resource_release(tcp_socket); return PP_ERROR_FAILED; } if (bytes_to_write > 1024 * 1024) bytes_to_write = 1024 * 1024; struct async_network_task_s *task = async_network_task_create(); task->type = ASYNC_NETWORK_TCP_WRITE; task->resource = tcp_socket; task->buffer = (char *)buffer; task->bufsize = bytes_to_write; task->callback = callback; task->callback_ml = ppb_message_loop_get_current(); pp_resource_release(tcp_socket); async_network_task_push(task); return PP_OK_COMPLETIONPENDING; } void ppb_tcp_socket_disconnect(PP_Resource tcp_socket) { struct pp_tcp_socket_s *ts = pp_resource_acquire(tcp_socket, PP_RESOURCE_TCP_SOCKET); if (!ts) { trace_error("%s, bad resource\n", __func__); return; } ppb_tcp_socket_destroy(ts); pp_resource_release(tcp_socket); } int32_t ppb_tcp_socket_set_option(PP_Resource tcp_socket, PP_TCPSocketOption_Private name, struct PP_Var value, struct PP_CompletionCallback callback) { return -1; } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_tcp_socket_create(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_tcp_socket_create(instance); } TRACE_WRAPPER PP_Bool trace_ppb_tcp_socket_is_tcp_socket(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_tcp_socket_is_tcp_socket(resource); } TRACE_WRAPPER int32_t trace_ppb_tcp_socket_connect(PP_Resource tcp_socket, const char *host, uint16_t port, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s tcp_socket=%d, host=%s, port=%u, callback={.func=%p, " ".user_data=%p, flags=%u}\n", __func__+6, tcp_socket, host, port, callback.func, callback.user_data, callback.flags); return ppb_tcp_socket_connect(tcp_socket, host, port, callback); } TRACE_WRAPPER int32_t trace_ppb_tcp_socket_connect_with_net_address(PP_Resource tcp_socket, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s tcp_socket=%d, addr={%p}, callback={.func=%p, " ".user_data=%p, .flags=%u}\n", __func__+6, tcp_socket, addr, callback.func, callback.user_data, callback.flags); return ppb_tcp_socket_connect_with_net_address(tcp_socket, addr, callback); } TRACE_WRAPPER PP_Bool trace_ppb_tcp_socket_get_local_address(PP_Resource tcp_socket, struct PP_NetAddress_Private *local_addr) { trace_info("[PPB] {full} %s tcp_socket=%d\n", __func__+6, tcp_socket); return ppb_tcp_socket_get_local_address(tcp_socket, local_addr); } TRACE_WRAPPER PP_Bool trace_ppb_tcp_socket_get_remote_address(PP_Resource tcp_socket, struct PP_NetAddress_Private *remote_addr) { trace_info("[PPB] {full} %s tcp_socket=%d\n", __func__+6, tcp_socket); return ppb_tcp_socket_get_remote_address(tcp_socket, remote_addr); } TRACE_WRAPPER int32_t trace_ppb_tcp_socket_ssl_handshake(PP_Resource tcp_socket, const char *server_name, uint16_t server_port, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s\n", __func__+6); return ppb_tcp_socket_ssl_handshake(tcp_socket, server_name, server_port, callback); } TRACE_WRAPPER PP_Resource trace_ppb_tcp_socket_get_server_certificate(PP_Resource tcp_socket) { trace_info("[PPB] {zilch} %s\n", __func__+6); return ppb_tcp_socket_get_server_certificate(tcp_socket); } TRACE_WRAPPER PP_Bool trace_ppb_tcp_socket_add_chain_building_certificate(PP_Resource tcp_socket, PP_Resource certificate, PP_Bool is_trusted) { trace_info("[PPB] {zilch} %s\n", __func__+6); return ppb_tcp_socket_add_chain_building_certificate(tcp_socket, certificate, is_trusted); } TRACE_WRAPPER int32_t trace_ppb_tcp_socket_read(PP_Resource tcp_socket, char *buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s tcp_socket=%d, bytes_to_read=%d, callback={.func=%p, " ".user_data=%p, .flags=%d}\n", __func__+6, tcp_socket, bytes_to_read, callback.func, callback.user_data, callback.flags); return ppb_tcp_socket_read(tcp_socket, buffer, bytes_to_read, callback); } TRACE_WRAPPER int32_t trace_ppb_tcp_socket_write(PP_Resource tcp_socket, const char *buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s tcp_socket=%d, bytes_to_write=%d, callback={.func=%p, " ".user_data=%p, .flags=%d}\n", __func__+6, tcp_socket, bytes_to_write, callback.func, callback.user_data, callback.flags); return ppb_tcp_socket_write(tcp_socket, buffer, bytes_to_write, callback); } TRACE_WRAPPER void trace_ppb_tcp_socket_disconnect(PP_Resource tcp_socket) { trace_info("[PPB] {full} %s tcp_socket=%d\n", __func__+6, tcp_socket); ppb_tcp_socket_disconnect(tcp_socket); } TRACE_WRAPPER int32_t trace_ppb_tcp_socket_set_option(PP_Resource tcp_socket, PP_TCPSocketOption_Private name, struct PP_Var value, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s\n", __func__+6); return ppb_tcp_socket_set_option(tcp_socket, name, value, callback); } const struct PPB_TCPSocket_Private_0_5 ppb_tcp_socket_private_interface_0_5 = { .Create = TWRAPF(ppb_tcp_socket_create), .IsTCPSocket = TWRAPF(ppb_tcp_socket_is_tcp_socket), .Connect = TWRAPF(ppb_tcp_socket_connect), .ConnectWithNetAddress = TWRAPF(ppb_tcp_socket_connect_with_net_address), .GetLocalAddress = TWRAPF(ppb_tcp_socket_get_local_address), .GetRemoteAddress = TWRAPF(ppb_tcp_socket_get_remote_address), .SSLHandshake = TWRAPZ(ppb_tcp_socket_ssl_handshake), .GetServerCertificate = TWRAPZ(ppb_tcp_socket_get_server_certificate), .AddChainBuildingCertificate = TWRAPZ(ppb_tcp_socket_add_chain_building_certificate), .Read = TWRAPF(ppb_tcp_socket_read), .Write = TWRAPF(ppb_tcp_socket_write), .Disconnect = TWRAPF(ppb_tcp_socket_disconnect), .SetOption = TWRAPZ(ppb_tcp_socket_set_option), }; const struct PPB_TCPSocket_Private_0_4 ppb_tcp_socket_private_interface_0_4 = { .Create = TWRAPF(ppb_tcp_socket_create), .IsTCPSocket = TWRAPF(ppb_tcp_socket_is_tcp_socket), .Connect = TWRAPF(ppb_tcp_socket_connect), .ConnectWithNetAddress = TWRAPF(ppb_tcp_socket_connect_with_net_address), .GetLocalAddress = TWRAPF(ppb_tcp_socket_get_local_address), .GetRemoteAddress = TWRAPF(ppb_tcp_socket_get_remote_address), .SSLHandshake = TWRAPZ(ppb_tcp_socket_ssl_handshake), .GetServerCertificate = TWRAPZ(ppb_tcp_socket_get_server_certificate), .AddChainBuildingCertificate = TWRAPZ(ppb_tcp_socket_add_chain_building_certificate), .Read = TWRAPF(ppb_tcp_socket_read), .Write = TWRAPF(ppb_tcp_socket_write), .Disconnect = TWRAPF(ppb_tcp_socket_disconnect), }; static void __attribute__((constructor)) constructor_ppb_tcp_socket(void) { register_interface(PPB_TCPSOCKET_PRIVATE_INTERFACE_0_4, &ppb_tcp_socket_private_interface_0_4); register_interface(PPB_TCPSOCKET_PRIVATE_INTERFACE_0_5, &ppb_tcp_socket_private_interface_0_5); register_resource(PP_RESOURCE_TCP_SOCKET, ppb_tcp_socket_destroy); } freshplayerplugin-0.3.9/src/ppb_tcp_socket.h000066400000000000000000000062041321746453100212350ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include "pp_resource.h" #include struct pp_tcp_socket_s { COMMON_STRUCTURE_FIELDS int sock; unsigned int is_connected; unsigned int destroyed; unsigned int seen_eof; }; PP_Resource ppb_tcp_socket_create(PP_Instance instance); PP_Bool ppb_tcp_socket_is_tcp_socket(PP_Resource resource); int32_t ppb_tcp_socket_connect(PP_Resource tcp_socket, const char *host, uint16_t port, struct PP_CompletionCallback callback); int32_t ppb_tcp_socket_connect_with_net_address(PP_Resource tcp_socket, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback); PP_Bool ppb_tcp_socket_get_local_address(PP_Resource tcp_socket, struct PP_NetAddress_Private *local_addr); PP_Bool ppb_tcp_socket_get_remote_address(PP_Resource tcp_socket, struct PP_NetAddress_Private *remote_addr); int32_t ppb_tcp_socket_ssl_handshake(PP_Resource tcp_socket, const char *server_name, uint16_t server_port, struct PP_CompletionCallback callback); PP_Resource ppb_tcp_socket_get_server_certificate(PP_Resource tcp_socket); PP_Bool ppb_tcp_socket_add_chain_building_certificate(PP_Resource tcp_socket, PP_Resource certificate, PP_Bool is_trusted); int32_t ppb_tcp_socket_read(PP_Resource tcp_socket, char *buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback); int32_t ppb_tcp_socket_write(PP_Resource tcp_socket, const char *buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback); void ppb_tcp_socket_disconnect(PP_Resource tcp_socket); int32_t ppb_tcp_socket_set_option(PP_Resource tcp_socket, PP_TCPSocketOption_Private name, struct PP_Var value, struct PP_CompletionCallback callback); freshplayerplugin-0.3.9/src/ppb_text_input.c000066400000000000000000000214271321746453100213010ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "gtk_wrapper.h" #include "pp_interface.h" #include "ppb_core.h" #include "ppb_instance.h" #include "ppb_text_input.h" #include "reverse_constant.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include "utils.h" #include #include #include #include #include #include struct set_text_input_type_param_s { PP_Instance instance; PP_TextInput_Type_Dev type; }; static void set_text_input_type_ptac(void *param) { struct set_text_input_type_param_s *p = param; struct pp_instance_s *pp_i = tables_get_pp_instance(p->instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return; } if (pp_i->im_context) gw_gtk_im_context_focus_out(pp_i->im_context); switch (p->type) { case PP_TEXTINPUT_TYPE_DEV_NONE: case PP_TEXTINPUT_TYPE_DEV_PASSWORD: pp_i->im_context = NULL; break; case PP_TEXTINPUT_TYPE_DEV_TEXT: pp_i->im_context = pp_i->im_context_multi; break; default: pp_i->im_context = pp_i->im_context_simple; break; } pp_i->textinput_type = p->type; if (pp_i->im_context) gw_gtk_im_context_focus_in(pp_i->im_context); g_slice_free1(sizeof(*p), p); } void ppb_text_input_interface_set_text_input_type(PP_Instance instance, PP_TextInput_Type_Dev type) { struct set_text_input_type_param_s *p = g_slice_alloc0(sizeof(*p)); p->instance = instance; p->type = type; ppb_core_call_on_browser_thread(instance, set_text_input_type_ptac, p); } struct update_caret_position_param_s { PP_Instance instance; GdkRectangle caret; }; static void update_caret_position_ptac(void *param) { struct update_caret_position_param_s *p = param; struct pp_instance_s *pp_i = tables_get_pp_instance(p->instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return; } p->caret.x += pp_i->offset_x; p->caret.y += pp_i->offset_y; if (pp_i->im_context) gw_gtk_im_context_set_cursor_location(pp_i->im_context, &p->caret); g_slice_free1(sizeof(*p), p); } void ppb_text_input_interface_update_caret_position(PP_Instance instance, const struct PP_Rect *caret, const struct PP_Rect *bounding_box) { if (!caret) return; struct update_caret_position_param_s *p = g_slice_alloc0(sizeof(*p)); p->instance = instance; p->caret.x = caret->point.x; p->caret.y = caret->point.y; p->caret.width = caret->size.width; p->caret.height = caret->size.height; ppb_core_call_on_browser_thread(instance, update_caret_position_ptac, p); } static void cancel_composition_text_ptac(void *param) { PP_Instance instance = GPOINTER_TO_SIZE(param); struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return; } if (pp_i->im_context) gw_gtk_im_context_reset(pp_i->im_context); } void ppb_text_input_interface_cancel_composition_text(PP_Instance instance) { ppb_core_call_on_browser_thread(instance, cancel_composition_text_ptac, GSIZE_TO_POINTER(instance)); } struct update_surrounding_text_param_s { PP_Instance instance; char *text; uint32_t caret; }; static void update_surrounding_text_ptac(void *param) { struct update_surrounding_text_param_s *p = param; struct pp_instance_s *pp_i = tables_get_pp_instance(p->instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); goto done; } if (pp_i->im_context) { const size_t len = p->text ? strlen(p->text) : 0; gw_gtk_im_context_set_surrounding(pp_i->im_context, p->text, len, p->caret); } done: g_free(p->text); g_slice_free1(sizeof(*p), p); } void ppb_text_input_interface_update_surrounding_text(PP_Instance instance, const char *text, uint32_t caret, uint32_t anchor) { struct update_surrounding_text_param_s *p = g_slice_alloc0(sizeof(*p)); p->instance = instance; p->text = g_strdup(text); p->caret = caret; ppb_core_call_on_browser_thread(instance, update_surrounding_text_ptac, p); return; } static void selection_changed_comt(void *user_data, int32_t result) { PP_Instance instance = GPOINTER_TO_SIZE(user_data); struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return; } if (!pp_i->ppp_text_input_dev) pp_i->ppp_text_input_dev = ppp_get_interface(PPP_TEXTINPUT_DEV_INTERFACE_0_1); if (pp_i->ppp_text_input_dev) pp_i->ppp_text_input_dev->RequestSurroundingText(pp_i->id, 100); } void ppb_text_input_interface_selection_changed(PP_Instance instance) { ppb_core_call_on_main_thread2(0, PP_MakeCCB(selection_changed_comt, GSIZE_TO_POINTER(instance)), PP_OK, __func__); } // trace wrappers TRACE_WRAPPER void trace_ppb_text_input_interface_set_text_input_type(PP_Instance instance, PP_TextInput_Type_Dev type) { trace_info("[PPB] {full} %s instance=%d, type=%s\n", __func__+6, instance, reverse_pp_text_input_type(type)); ppb_text_input_interface_set_text_input_type(instance, type); } TRACE_WRAPPER void trace_ppb_text_input_interface_update_caret_position(PP_Instance instance, const struct PP_Rect *caret, const struct PP_Rect *bounding_box) { char *caret_str = trace_rect_as_string(caret); char *bounding_box_str = trace_rect_as_string(bounding_box); trace_info("[PPB] {full} %s instance=%d, caret=%s, bounding_box=%s\n", __func__+6, instance, caret_str, bounding_box_str); g_free(caret_str); g_free(bounding_box_str); ppb_text_input_interface_update_caret_position(instance, caret, bounding_box); } TRACE_WRAPPER void trace_ppb_text_input_interface_cancel_composition_text(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); ppb_text_input_interface_cancel_composition_text(instance); } TRACE_WRAPPER void trace_ppb_text_input_interface_update_surrounding_text(PP_Instance instance, const char *text, uint32_t caret, uint32_t anchor) { trace_info("[PPB] {full} %s instance=%d, text=%s, caret=%u, anchor=%u\n", __func__+6, instance, text, caret, anchor); ppb_text_input_interface_update_surrounding_text(instance, text, caret, anchor); } TRACE_WRAPPER void trace_ppb_text_input_interface_selection_changed(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); ppb_text_input_interface_selection_changed(instance); } const struct PPB_TextInput_Dev_0_2 ppb_text_input_dev_interface_0_2 = { .SetTextInputType = TWRAPF(ppb_text_input_interface_set_text_input_type), .UpdateCaretPosition = TWRAPF(ppb_text_input_interface_update_caret_position), .CancelCompositionText = TWRAPF(ppb_text_input_interface_cancel_composition_text), .UpdateSurroundingText = TWRAPF(ppb_text_input_interface_update_surrounding_text), .SelectionChanged = TWRAPF(ppb_text_input_interface_selection_changed), }; static void __attribute__((constructor)) constructor_ppb_text_input(void) { register_interface(PPB_TEXTINPUT_DEV_INTERFACE_0_2, &ppb_text_input_dev_interface_0_2); } freshplayerplugin-0.3.9/src/ppb_text_input.h000066400000000000000000000034701321746453100213040ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include void ppb_text_input_interface_set_text_input_type(PP_Instance instance, PP_TextInput_Type_Dev type); void ppb_text_input_interface_update_caret_position(PP_Instance instance, const struct PP_Rect *caret, const struct PP_Rect *bounding_box); void ppb_text_input_interface_cancel_composition_text(PP_Instance instance); void ppb_text_input_interface_update_surrounding_text(PP_Instance instance, const char *text, uint32_t caret, uint32_t anchor); void ppb_text_input_interface_selection_changed(PP_Instance instance); freshplayerplugin-0.3.9/src/ppb_text_input_controller.c000066400000000000000000000067451321746453100235520ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "ppb_text_input_controller.h" #include "trace_core.h" void ppb_text_input_controller_set_text_input_type(PP_Instance instance, PP_TextInput_Type type) { } void ppb_text_input_controller_update_caret_position(PP_Instance instance, const struct PP_Rect *caret) { } void ppb_text_input_controller_cancel_composition_text(PP_Instance instance) { } void ppb_text_input_controller_update_surrounding_text(PP_Instance instance, struct PP_Var text, uint32_t caret, uint32_t anchor) { } // trace wrappers TRACE_WRAPPER void trace_ppb_text_input_controller_set_text_input_type(PP_Instance instance, PP_TextInput_Type type) { trace_info("[PPB] {zilch} %s\n", __func__+6); return ppb_text_input_controller_set_text_input_type(instance, type); } TRACE_WRAPPER void trace_ppb_text_input_controller_update_caret_position(PP_Instance instance, const struct PP_Rect *caret) { trace_info("[PPB] {zilch} %s\n", __func__+6); return ppb_text_input_controller_update_caret_position(instance, caret); } TRACE_WRAPPER void trace_ppb_text_input_controller_cancel_composition_text(PP_Instance instance) { trace_info("[PPB] {zilch} %s\n", __func__+6); return ppb_text_input_controller_cancel_composition_text(instance); } TRACE_WRAPPER void trace_ppb_text_input_controller_update_surrounding_text(PP_Instance instance, struct PP_Var text, uint32_t caret, uint32_t anchor) { trace_info("[PPB] {zilch} %s\n", __func__+6); return ppb_text_input_controller_update_surrounding_text(instance, text, caret, anchor); } const struct PPB_TextInputController_1_0 ppb_text_input_controller_interface_1_0 = { .SetTextInputType = TWRAPZ(ppb_text_input_controller_set_text_input_type), .UpdateCaretPosition = TWRAPZ(ppb_text_input_controller_update_caret_position), .CancelCompositionText = TWRAPZ(ppb_text_input_controller_cancel_composition_text), .UpdateSurroundingText = TWRAPZ(ppb_text_input_controller_update_surrounding_text), }; static void __attribute__((constructor)) constructor_ppb_text_input_controller(void) { register_interface(PPB_TEXTINPUTCONTROLLER_INTERFACE_1_0, &ppb_text_input_controller_interface_1_0); } freshplayerplugin-0.3.9/src/ppb_text_input_controller.h000066400000000000000000000032431321746453100235450ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include void ppb_text_input_controller_set_text_input_type(PP_Instance instance, PP_TextInput_Type type); void ppb_text_input_controller_update_caret_position(PP_Instance instance, const struct PP_Rect *caret); void ppb_text_input_controller_cancel_composition_text(PP_Instance instance); void ppb_text_input_controller_update_surrounding_text(PP_Instance instance, struct PP_Var text, uint32_t caret, uint32_t anchor); freshplayerplugin-0.3.9/src/ppb_udp_socket.c000066400000000000000000000477561321746453100212530ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "async_network.h" #include "pp_interface.h" #include "ppb_core.h" #include "ppb_message_loop.h" #include "ppb_net_address.h" #include "ppb_udp_socket.h" #include "reverse_constant.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include #include #include #include STATIC_ASSERT(sizeof(struct pp_udp_socket_s) <= LARGEST_RESOURCE_SIZE); PP_Resource ppb_udp_socket_create(PP_Instance instance_id) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance_id); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource udp_socket = pp_resource_allocate(PP_RESOURCE_UDP_SOCKET, pp_i); struct pp_udp_socket_s *us = pp_resource_acquire(udp_socket, PP_RESOURCE_UDP_SOCKET); if (!us) { trace_error("%s, resource allocation failure\n", __func__); return 0; } us->sock = socket(AF_INET, SOCK_DGRAM, 0); pp_resource_release(udp_socket); return udp_socket; } static void ppb_udp_socket_destroy(void *p) { struct pp_udp_socket_s *us = p; if (!us->destroyed) { struct async_network_task_s *task = async_network_task_create(); us->destroyed = 1; task->type = ASYNC_NETWORK_DISCONNECT; task->resource = us->self_id; task->sock = us->sock; async_network_task_push(task); } } PP_Bool ppb_udp_socket_is_udp_socket(PP_Resource resource_id) { return pp_resource_get_type(resource_id) == PP_RESOURCE_UDP_SOCKET; } int32_t ppb_udp_socket_join_group(PP_Resource udp_socket, PP_Resource group, struct PP_CompletionCallback callback) { // TODO: impl return PP_ERROR_FAILED; } int32_t ppb_udp_socket_leave_group(PP_Resource udp_socket, PP_Resource group, struct PP_CompletionCallback callback) { // TODO: impl return PP_ERROR_FAILED; } int32_t ppb_udp_socket_set_option(PP_Resource udp_socket, PP_UDPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback) { // TODO: impl return PP_ERROR_FAILED; } int32_t ppb_udp_socket_set_socket_feature(PP_Resource udp_socket, PP_UDPSocketFeature_Private name, struct PP_Var value) { return -1; } int32_t ppb_udp_socket_bind(PP_Resource udp_socket, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback) { struct pp_udp_socket_s *us = pp_resource_acquire(udp_socket, PP_RESOURCE_UDP_SOCKET); if (!us) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } memcpy(&us->addr, addr, sizeof(struct PP_NetAddress_Private)); if (bind(us->sock, (struct sockaddr *)addr->data, addr->size) != 0) { trace_warning("%s, bind failed\n", __func__); pp_resource_release(udp_socket); return PP_ERROR_FAILED; } us->bound = 1; pp_resource_release(udp_socket); ppb_message_loop_post_work_with_result(ppb_message_loop_get_current(), callback, 0, PP_OK, 0, __func__); return PP_OK_COMPLETIONPENDING; } int32_t ppb_udp_socket_bind_1_0(PP_Resource udp_socket, PP_Resource addr, struct PP_CompletionCallback callback) { struct pp_net_address_s *na = pp_resource_acquire(addr, PP_RESOURCE_NET_ADDRESS); if (!na) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } int32_t ret = ppb_udp_socket_bind(udp_socket, &na->addr, callback); pp_resource_release(addr); return ret; } PP_Bool ppb_udp_socket_get_bound_address(PP_Resource udp_socket, struct PP_NetAddress_Private *addr) { struct pp_udp_socket_s *us = pp_resource_acquire(udp_socket, PP_RESOURCE_UDP_SOCKET); if (!us) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } if (!us->bound) { // not bound socket have no address pp_resource_release(udp_socket); return PP_FALSE; } memcpy(addr, &us->addr, sizeof(struct PP_NetAddress_Private)); pp_resource_release(udp_socket); return PP_TRUE; } PP_Resource ppb_udp_socket_get_bound_address_1_0(PP_Resource udp_socket) { PP_Resource net_address = 0; struct pp_udp_socket_s *us = pp_resource_acquire(udp_socket, PP_RESOURCE_UDP_SOCKET); if (!us) { trace_error("%s, bad resource\n", __func__); goto err_1; } if (!us->bound) { // not bound socket have no address goto err_2; } net_address = pp_resource_allocate(PP_RESOURCE_NET_ADDRESS, us->instance); struct pp_net_address_s *na = pp_resource_acquire(net_address, PP_RESOURCE_NET_ADDRESS); if (!na) { trace_error("%s, resource allocation failed\n", __func__); net_address = 0; goto err_2; } memcpy(&na->addr, &us->addr, sizeof(struct PP_NetAddress_Private)); pp_resource_release(net_address); err_2: pp_resource_release(udp_socket); err_1: return net_address; } int32_t ppb_udp_socket_recv_from(PP_Resource udp_socket, char *buffer, int32_t num_bytes, struct PP_CompletionCallback callback) { struct pp_udp_socket_s *us = pp_resource_acquire(udp_socket, PP_RESOURCE_UDP_SOCKET); if (!us) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } struct async_network_task_s *task = async_network_task_create(); task->type = ASYNC_NETWORK_UDP_RECV; task->resource = udp_socket; task->buffer = buffer; task->bufsize = num_bytes; task->callback = callback; task->callback_ml = ppb_message_loop_get_current(); task->addr_from = &us->addr_from; pp_resource_release(udp_socket); async_network_task_push(task); return PP_OK_COMPLETIONPENDING; } int32_t ppb_udp_socket_recv_from_1_0(PP_Resource udp_socket, char *buffer, int32_t num_bytes, PP_Resource *addr, struct PP_CompletionCallback callback) { int ret; struct pp_udp_socket_s *us = pp_resource_acquire(udp_socket, PP_RESOURCE_UDP_SOCKET); if (!us) { trace_error("%s, bad resource\n", __func__); ret = PP_ERROR_BADRESOURCE; goto err_1; } PP_Resource net_address = pp_resource_allocate(PP_RESOURCE_NET_ADDRESS, us->instance); struct pp_net_address_s *na = pp_resource_acquire(net_address, PP_RESOURCE_NET_ADDRESS); if (!na) { trace_error("%s, resource allocation failed\n", __func__); ret = PP_ERROR_NOMEMORY; goto err_2; } struct async_network_task_s *task = async_network_task_create(); task->type = ASYNC_NETWORK_UDP_RECV; task->resource = udp_socket; task->buffer = buffer; task->bufsize = num_bytes; task->callback = callback; task->callback_ml = ppb_message_loop_get_current(); task->addr_from = &na->addr; task->addr_from_resource = net_address; ppb_core_add_ref_resource(net_address); pp_resource_release(net_address); pp_resource_release(udp_socket); async_network_task_push(task); *addr = net_address; return PP_OK_COMPLETIONPENDING; err_2: pp_resource_release(udp_socket); err_1: return ret; } PP_Bool ppb_udp_socket_get_recv_from_address(PP_Resource udp_socket, struct PP_NetAddress_Private *addr) { struct pp_udp_socket_s *us = pp_resource_acquire(udp_socket, PP_RESOURCE_UDP_SOCKET); if (!us) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } if (!us->addr_from.size) { // size should be larger than zero, otherwise there is no address pp_resource_release(udp_socket); return PP_FALSE; } memcpy(addr, &us->addr_from, sizeof(struct PP_NetAddress_Private)); pp_resource_release(udp_socket); return PP_TRUE; } int32_t ppb_udp_socket_send_to(PP_Resource udp_socket, const char *buffer, int32_t num_bytes, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback) { struct pp_udp_socket_s *us = pp_resource_acquire(udp_socket, PP_RESOURCE_UDP_SOCKET); if (!us) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } num_bytes = MIN(num_bytes, 128 * 1024); struct async_network_task_s *task = async_network_task_create(); task->type = ASYNC_NETWORK_UDP_SEND; task->resource = udp_socket; task->buffer = (char *)buffer; task->bufsize = num_bytes; task->callback = callback; task->callback_ml = ppb_message_loop_get_current(); memcpy(&task->netaddr, addr, sizeof(*addr)); pp_resource_release(udp_socket); async_network_task_push(task); return PP_OK_COMPLETIONPENDING; } int32_t ppb_udp_socket_send_to_1_0(PP_Resource udp_socket, const char *buffer, int32_t num_bytes, PP_Resource addr, struct PP_CompletionCallback callback) { struct pp_net_address_s *na = pp_resource_acquire(addr, PP_RESOURCE_NET_ADDRESS); if (!na) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } int32_t ret = ppb_udp_socket_send_to(udp_socket, buffer, num_bytes, &na->addr, callback); pp_resource_release(addr); return ret; } void ppb_udp_socket_close(PP_Resource udp_socket) { struct pp_udp_socket_s *us = pp_resource_acquire(udp_socket, PP_RESOURCE_UDP_SOCKET); if (!us) { trace_error("%s, bad resource\n", __func__); return; } ppb_udp_socket_destroy(us); pp_resource_release(udp_socket); } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_udp_socket_create(PP_Instance instance_id) { trace_info("[PPB] {full} %s instance_id=%d\n", __func__+6, instance_id); return ppb_udp_socket_create(instance_id); } TRACE_WRAPPER PP_Bool trace_ppb_udp_socket_is_udp_socket(PP_Resource resource_id) { trace_info("[PPB] {full} %s resource_id=%d\n", __func__+6, resource_id); return ppb_udp_socket_is_udp_socket(resource_id); } TRACE_WRAPPER int32_t trace_ppb_udp_socket_join_group(PP_Resource udp_socket, PP_Resource group, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s udp_socket=%d, group=%d, callback={.func=%p, .user_data=%p, " ".flags=%u}\n", __func__+6, udp_socket, group, callback.func, callback.user_data, callback.flags); return ppb_udp_socket_join_group(udp_socket, group, callback); } TRACE_WRAPPER int32_t trace_ppb_udp_socket_leave_group(PP_Resource udp_socket, PP_Resource group, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s udp_socket=%d, group=%d, callback={.func=%p, .user_data=%p, " ".flags=%u}\n", __func__+6, udp_socket, group, callback.func, callback.user_data, callback.flags); return ppb_udp_socket_leave_group(udp_socket, group, callback); } TRACE_WRAPPER int32_t trace_ppb_udp_socket_set_option(PP_Resource udp_socket, PP_UDPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback) { gchar *s_value = trace_var_as_string(value); trace_info("[PPB] {zilch} %s udp_socket=%d, name=%d, value=%s, vallback={.func=%p, " ".user_data=%p, .flags=%u}\n", __func__+6, udp_socket, name, s_value, callback.func, callback.user_data, callback.flags); g_free(s_value); return ppb_udp_socket_set_option(udp_socket, name, value, callback); } TRACE_WRAPPER int32_t trace_ppb_udp_socket_set_socket_feature(PP_Resource udp_socket, PP_UDPSocketFeature_Private name, struct PP_Var value) { gchar *s_value = trace_var_as_string(value); trace_info("[PPB] {zilch} %s udp_socket=%d, name=%s(%u), value=%s\n", __func__+6, udp_socket, reverse_udp_socket_feature(name), name, s_value); g_free(s_value); return ppb_udp_socket_set_socket_feature(udp_socket, name, value); } TRACE_WRAPPER int32_t trace_ppb_udp_socket_bind(PP_Resource udp_socket, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s udp_socket=%d, addr=%p, callback={.func=%p, .user_data=%p, " ".flags=%u}\n", __func__+6, udp_socket, addr, callback.func, callback.user_data, callback.flags); return ppb_udp_socket_bind(udp_socket, addr, callback); } TRACE_WRAPPER int32_t trace_ppb_udp_socket_bind_1_0(PP_Resource udp_socket, PP_Resource addr, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s udp_socket=%d, addr=%d, callback={.func=%p, .user_data=%p, " ".flags=%u}\n", __func__+6, udp_socket, addr, callback.func, callback.user_data, callback.flags); return ppb_udp_socket_bind_1_0(udp_socket, addr, callback); } TRACE_WRAPPER PP_Bool trace_ppb_udp_socket_get_bound_address(PP_Resource udp_socket, struct PP_NetAddress_Private *addr) { trace_info("[PPB] {full} %s udp_socket=%d, addr=%p\n", __func__+6, udp_socket, addr); return ppb_udp_socket_get_bound_address(udp_socket, addr); } TRACE_WRAPPER PP_Resource trace_ppb_udp_socket_get_bound_address_1_0(PP_Resource udp_socket) { trace_info("[PPB] {full} %s udp_socket=%d\n", __func__+6, udp_socket); return ppb_udp_socket_get_bound_address_1_0(udp_socket); } TRACE_WRAPPER int32_t trace_ppb_udp_socket_recv_from(PP_Resource udp_socket, char *buffer, int32_t num_bytes, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s udp_socket=%d, buffer=%p, num_bytes=%d, callback={.func=%p, " ".user_data=%p, .flags=%u}\n", __func__+6, udp_socket, buffer, num_bytes, callback.func, callback.user_data, callback.flags); return ppb_udp_socket_recv_from(udp_socket, buffer, num_bytes, callback); } TRACE_WRAPPER int32_t trace_ppb_udp_socket_recv_from_1_0(PP_Resource udp_socket, char *buffer, int32_t num_bytes, PP_Resource *addr, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s udp_socket=%d, buffer=%p, num_bytes=%d, callback={.func=%p, " ".user_data=%p, .flags=%u}\n", __func__+6, udp_socket, buffer, num_bytes, callback.func, callback.user_data, callback.flags); return ppb_udp_socket_recv_from_1_0(udp_socket, buffer, num_bytes, addr, callback); } TRACE_WRAPPER PP_Bool trace_ppb_udp_socket_get_recv_from_address(PP_Resource udp_socket, struct PP_NetAddress_Private *addr) { trace_info("[PPB] {full} %s udp_socket=%d, addr=%p\n", __func__+6, udp_socket, addr); return ppb_udp_socket_get_recv_from_address(udp_socket, addr); } TRACE_WRAPPER int32_t trace_ppb_udp_socket_send_to(PP_Resource udp_socket, const char *buffer, int32_t num_bytes, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s udp_socket=%d, buffer=%p, num_bytes=%d, addr=%p, callback={" ".func=%p, .user_data=%p, .flags=%u}\n", __func__+6, udp_socket, buffer, num_bytes, addr, callback.func, callback.user_data, callback.flags); return ppb_udp_socket_send_to(udp_socket, buffer, num_bytes, addr, callback); } TRACE_WRAPPER int32_t trace_ppb_udp_socket_send_to_1_0(PP_Resource udp_socket, const char *buffer, int32_t num_bytes, PP_Resource addr, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s udp_socket=%d, buffer=%p, num_bytes=%d, addr=%d, callback={" ".func=%p, .user_data=%p, .flags=%u}\n", __func__+6, udp_socket, buffer, num_bytes, addr, callback.func, callback.user_data, callback.flags); return ppb_udp_socket_send_to_1_0(udp_socket, buffer, num_bytes, addr, callback); } TRACE_WRAPPER void trace_ppb_udp_socket_close(PP_Resource udp_socket) { trace_info("[PPB] {full} %s udp_socket=%d\n", __func__+6, udp_socket); return ppb_udp_socket_close(udp_socket); } const struct PPB_UDPSocket_Private_0_4 ppb_udp_socket_private_interface_0_4 = { .Create = TWRAPF(ppb_udp_socket_create), .IsUDPSocket = TWRAPF(ppb_udp_socket_is_udp_socket), .SetSocketFeature = TWRAPZ(ppb_udp_socket_set_socket_feature), .Bind = TWRAPF(ppb_udp_socket_bind), .GetBoundAddress = TWRAPF(ppb_udp_socket_get_bound_address), .RecvFrom = TWRAPF(ppb_udp_socket_recv_from), .GetRecvFromAddress = TWRAPF(ppb_udp_socket_get_recv_from_address), .SendTo = TWRAPF(ppb_udp_socket_send_to), .Close = TWRAPF(ppb_udp_socket_close), }; const struct PPB_UDPSocket_1_2 ppb_udp_socket_interface_1_2 = { .Create = TWRAPF(ppb_udp_socket_create), .IsUDPSocket = TWRAPF(ppb_udp_socket_is_udp_socket), .Bind = TWRAPF(ppb_udp_socket_bind_1_0), .GetBoundAddress = TWRAPF(ppb_udp_socket_get_bound_address_1_0), .RecvFrom = TWRAPF(ppb_udp_socket_recv_from_1_0), .SendTo = TWRAPF(ppb_udp_socket_send_to_1_0), .Close = TWRAPF(ppb_udp_socket_close), .SetOption = TWRAPZ(ppb_udp_socket_set_option), .JoinGroup = TWRAPZ(ppb_udp_socket_join_group), .LeaveGroup = TWRAPZ(ppb_udp_socket_leave_group), }; const struct PPB_UDPSocket_1_1 ppb_udp_socket_interface_1_1 = { .Create = TWRAPF(ppb_udp_socket_create), .IsUDPSocket = TWRAPF(ppb_udp_socket_is_udp_socket), .Bind = TWRAPF(ppb_udp_socket_bind_1_0), .GetBoundAddress = TWRAPF(ppb_udp_socket_get_bound_address_1_0), .RecvFrom = TWRAPF(ppb_udp_socket_recv_from_1_0), .SendTo = TWRAPF(ppb_udp_socket_send_to_1_0), .Close = TWRAPF(ppb_udp_socket_close), .SetOption = TWRAPZ(ppb_udp_socket_set_option), }; const struct PPB_UDPSocket_1_0 ppb_udp_socket_interface_1_0 = { .Create = TWRAPF(ppb_udp_socket_create), .IsUDPSocket = TWRAPF(ppb_udp_socket_is_udp_socket), .Bind = TWRAPF(ppb_udp_socket_bind_1_0), .GetBoundAddress = TWRAPF(ppb_udp_socket_get_bound_address_1_0), .RecvFrom = TWRAPF(ppb_udp_socket_recv_from_1_0), .SendTo = TWRAPF(ppb_udp_socket_send_to_1_0), .Close = TWRAPF(ppb_udp_socket_close), .SetOption = TWRAPZ(ppb_udp_socket_set_option), }; static void __attribute__((constructor)) constructor_ppb_udp_socket(void) { register_interface(PPB_UDPSOCKET_PRIVATE_INTERFACE_0_4, &ppb_udp_socket_private_interface_0_4); register_interface(PPB_UDPSOCKET_INTERFACE_1_0, &ppb_udp_socket_interface_1_0); register_interface(PPB_UDPSOCKET_INTERFACE_1_1, &ppb_udp_socket_interface_1_1); register_interface(PPB_UDPSOCKET_INTERFACE_1_2, &ppb_udp_socket_interface_1_2); register_resource(PP_RESOURCE_UDP_SOCKET, ppb_udp_socket_destroy); } freshplayerplugin-0.3.9/src/ppb_udp_socket.h000066400000000000000000000073051321746453100212420ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include "pp_resource.h" #include #include struct pp_udp_socket_s { COMMON_STRUCTURE_FIELDS int sock; int bound; int seen_eof; int destroyed; struct PP_NetAddress_Private addr; struct PP_NetAddress_Private addr_from; }; PP_Resource ppb_udp_socket_create(PP_Instance instance_id); PP_Bool ppb_udp_socket_is_udp_socket(PP_Resource resource_id); int32_t ppb_udp_socket_join_group(PP_Resource udp_socket, PP_Resource group, struct PP_CompletionCallback callback); int32_t ppb_udp_socket_leave_group(PP_Resource udp_socket, PP_Resource group, struct PP_CompletionCallback callback); int32_t ppb_udp_socket_set_option(PP_Resource udp_socket, PP_UDPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback); int32_t ppb_udp_socket_set_socket_feature(PP_Resource udp_socket, PP_UDPSocketFeature_Private name, struct PP_Var value); int32_t ppb_udp_socket_bind(PP_Resource udp_socket, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback); int32_t ppb_udp_socket_bind_1_0(PP_Resource udp_socket, PP_Resource addr, struct PP_CompletionCallback callback); PP_Bool ppb_udp_socket_get_bound_address(PP_Resource udp_socket, struct PP_NetAddress_Private *addr); PP_Resource ppb_udp_socket_get_bound_address_1_0(PP_Resource udp_socket); int32_t ppb_udp_socket_recv_from(PP_Resource udp_socket, char *buffer, int32_t num_bytes, struct PP_CompletionCallback callback); int32_t ppb_udp_socket_recv_from_1_0(PP_Resource udp_socket, char *buffer, int32_t num_bytes, PP_Resource *addr, struct PP_CompletionCallback callback); PP_Bool ppb_udp_socket_get_recv_from_address(PP_Resource udp_socket, struct PP_NetAddress_Private *addr); int32_t ppb_udp_socket_send_to(PP_Resource udp_socket, const char *buffer, int32_t num_bytes, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback); int32_t ppb_udp_socket_send_to_1_0(PP_Resource udp_socket, const char *buffer, int32_t num_bytes, PP_Resource addr, struct PP_CompletionCallback callback); void ppb_udp_socket_close(PP_Resource udp_socket); freshplayerplugin-0.3.9/src/ppb_uma.c000066400000000000000000000072051321746453100176560ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "ppb_uma.h" #include "trace_core.h" void ppb_uma_histogram_custom_times(PP_Instance instance, struct PP_Var name, int64_t sample, int64_t min, int64_t max, uint32_t bucket_count) { } void ppb_uma_histogram_custom_counts(PP_Instance instance, struct PP_Var name, int32_t sample, int32_t min, int32_t max, uint32_t bucket_count) { } void ppb_uma_histogram_enumeration(PP_Instance instance, struct PP_Var name, int32_t sample, int32_t boundary_value) { } int32_t ppb_uma_is_crash_reporting_enabled(PP_Instance instance, struct PP_CompletionCallback callback) { return PP_TRUE; } // trace wrappers TRACE_WRAPPER void trace_ppb_uma_histogram_custom_times(PP_Instance instance, struct PP_Var name, int64_t sample, int64_t min, int64_t max, uint32_t bucket_count) { trace_info("[PPB] {zilch} %s\n", __func__+6); return ppb_uma_histogram_custom_times(instance, name, sample, min, max, bucket_count); } TRACE_WRAPPER void trace_ppb_uma_histogram_custom_counts(PP_Instance instance, struct PP_Var name, int32_t sample, int32_t min, int32_t max, uint32_t bucket_count) { trace_info("[PPB] {zilch} %s\n", __func__+6); return ppb_uma_histogram_custom_counts(instance, name, sample, min, max, bucket_count); } TRACE_WRAPPER void trace_ppb_uma_histogram_enumeration(PP_Instance instance, struct PP_Var name, int32_t sample, int32_t boundary_value) { trace_info("[PPB] {zilch} %s\n", __func__+6); return ppb_uma_histogram_enumeration(instance, name, sample, boundary_value); } TRACE_WRAPPER int32_t trace_ppb_uma_is_crash_reporting_enabled(PP_Instance instance, struct PP_CompletionCallback callback) { trace_info("[PPB] {zilch} %s\n", __func__+6); return ppb_uma_is_crash_reporting_enabled(instance, callback); } const struct PPB_UMA_Private_0_3 ppb_uma_private_interface_0_3 = { .HistogramCustomTimes = TWRAPZ(ppb_uma_histogram_custom_times), .HistogramCustomCounts = TWRAPZ(ppb_uma_histogram_custom_counts), .HistogramEnumeration = TWRAPZ(ppb_uma_histogram_enumeration), .IsCrashReportingEnabled = TWRAPZ(ppb_uma_is_crash_reporting_enabled), }; static void __attribute__((constructor)) constructor_ppb_uma(void) { register_interface(PPB_UMA_PRIVATE_INTERFACE_0_3, &ppb_uma_private_interface_0_3); } freshplayerplugin-0.3.9/src/ppb_uma.h000066400000000000000000000034601321746453100176620ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include void ppb_uma_histogram_custom_times(PP_Instance instance, struct PP_Var name, int64_t sample, int64_t min, int64_t max, uint32_t bucket_count); void ppb_uma_histogram_custom_counts(PP_Instance instance, struct PP_Var name, int32_t sample, int32_t min, int32_t max, uint32_t bucket_count); void ppb_uma_histogram_enumeration(PP_Instance instance, struct PP_Var name, int32_t sample, int32_t boundary_value); int32_t ppb_uma_is_crash_reporting_enabled(PP_Instance instance, struct PP_CompletionCallback callback); freshplayerplugin-0.3.9/src/ppb_url_loader.c000066400000000000000000000623101321746453100212220ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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. */ #define _XOPEN_SOURCE 600 #include "config.h" #include "eintr_retry.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_core.h" #include "ppb_instance.h" #include "ppb_message_loop.h" #include "ppb_url_loader.h" #include "ppb_url_request_info.h" #include "ppb_url_response_info.h" #include "ppb_url_util.h" #include "ppb_var.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "utils.h" #include #include #include #include #include #include #include #include STATIC_ASSERT(sizeof(struct pp_url_loader_s) <= LARGEST_RESOURCE_SIZE); PP_Resource ppb_url_loader_create(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource url_loader = pp_resource_allocate(PP_RESOURCE_URL_LOADER, pp_i); struct pp_url_loader_s *ul = pp_resource_acquire(url_loader, PP_RESOURCE_URL_LOADER); if (!ul) { trace_error("%s, resource allocation failure\n", __func__); return 0; } // all fields are zeroed by default ul->response_size = -1; ul->method = PP_METHOD_GET; ul->fd = -1; pp_resource_release(url_loader); return url_loader; } static void ppb_url_loader_destroy(void *p) { if (!p) return; struct pp_url_loader_s *ul = p; if (ul->fd >= 0) { close(ul->fd); ul->fd = -1; } free_and_nullify(ul->headers); free_and_nullify(ul->url); free_and_nullify(ul->status_line); free_and_nullify(ul->request_headers); free_and_nullify(ul->custom_referrer_url); free_and_nullify(ul->custom_content_transfer_encoding); free_and_nullify(ul->custom_user_agent); free_and_nullify(ul->target); post_data_free(ul->post_data); ul->post_data = NULL; while (ul->read_tasks) { GList *llink = g_list_first(ul->read_tasks); struct url_loader_read_task_s *rt = llink->data; ul->read_tasks = g_list_delete_link(ul->read_tasks, llink); g_slice_free1(sizeof(*rt), rt); } } PP_Bool ppb_url_loader_is_url_loader(PP_Resource resource) { return PP_RESOURCE_URL_LOADER == pp_resource_get_type(resource); } struct url_loader_open_param_s { const char *url; PP_Resource loader; PP_Instance instance_id; enum pp_request_method_e method; const char *request_headers; const char *custom_referrer_url; const char *custom_content_transfer_encoding; const char *custom_user_agent; const char *target; GArray *post_data; size_t post_len; PP_Resource m_loop; int depth; int retval; }; static void url_loader_open_ptac(void *user_data) { struct url_loader_open_param_s *p = user_data; struct pp_instance_s *pp_i = tables_get_pp_instance(p->instance_id); if (!pp_i) { p->retval = NPERR_INVALID_INSTANCE_ERROR; goto quit; } if (p->method == PP_METHOD_POST) { // POST request int need_newline = 0; GString *buf = g_string_new(NULL); if (!buf) { p->retval = NPERR_GENERIC_ERROR; goto quit; } if (p->request_headers) { g_string_append_printf(buf, "%s\r\n", p->request_headers); need_newline = 1; } if (p->custom_referrer_url) { // the header name should be "referer", that's how it's spelled in HTTP spec g_string_append_printf(buf, "Referer: %s\r\n", p->custom_referrer_url); need_newline = 1; } if (p->custom_content_transfer_encoding) { g_string_append_printf(buf, "Content-Transfer-Encoding: %s\r\n", p->custom_content_transfer_encoding); need_newline = 1; } if (p->custom_user_agent) { g_string_append_printf(buf, "User-Agent: %s\r\n", p->custom_user_agent); need_newline = 1; } if (p->post_data) { size_t post_len = post_data_get_all_item_length(p->post_data); if (post_len == (size_t)-1) { // PP_ERROR_FILECHANGED? goto err; } if (post_len > 0) { g_string_append_printf(buf, "Content-Length: %"PRIu64"\r\n", (uint64_t)post_len); need_newline = 1; } } if (need_newline) g_string_append(buf, "\r\n"); if (p->post_data) { for (guint k = 0; k < p->post_data->len; k ++) post_data_write_to_gstring(p->post_data, k, buf); } if (p->target) { p->retval = npn.posturl(pp_i->npp, p->url, p->target, buf->len, buf->str, false); if (p->retval != NPERR_NO_ERROR) trace_error("%s, NPN_PostURL returned %d\n", __func__, p->retval); } else { p->retval = npn.posturlnotify(pp_i->npp, p->url, NULL, buf->len, buf->str, false, (void*)(size_t)p->loader); if (p->retval != NPERR_NO_ERROR) trace_error("%s, NPN_PostURLNotify returned %d\n", __func__, p->retval); } err: g_string_free(buf, TRUE); } else { // GET request if (p->target) { p->retval = npn.geturl(pp_i->npp, p->url, p->target); if (p->retval != NPERR_NO_ERROR) trace_warning("%s, NPN_GetUrl returned %d\n", __func__, p->retval); } else { p->retval = npn.geturlnotify(pp_i->npp, p->url, NULL, (void*)(size_t)p->loader); if (p->retval != NPERR_NO_ERROR) trace_warning("%s, NPN_GetUrlNotify returned %d\n", __func__, p->retval); } } quit: ppb_core_release_resource(p->loader); ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void url_loader_open_comt(void *user_data, int32_t result) { struct url_loader_open_param_s *p = user_data; ppb_core_call_on_browser_thread(0, url_loader_open_ptac, p); } int open_temporary_file(void) { char *tmpfname; // TODO: make temp path configurable tmpfname = g_strdup_printf("/tmp/FreshStreamXXXXXX"); int fd = mkstemp(tmpfname); unlink(tmpfname); g_free(tmpfname); return fd; } /// trim new line characters from the end of the string char * trim_nl(char *s) { if (!s) return NULL; size_t len = strlen(s); while (len > 0 && (s[len - 1] == '\n' || s[len - 1] == '\r')) { s[len - 1] = 0; len --; } return s; } int32_t ppb_url_loader_open(PP_Resource loader, PP_Resource request_info, struct PP_CompletionCallback callback) { return ppb_url_loader_open_target(loader, request_info, callback, NULL); } int32_t ppb_url_loader_open_target(PP_Resource loader, PP_Resource request_info, struct PP_CompletionCallback callback, const char *target) { struct pp_url_loader_s *ul = pp_resource_acquire(loader, PP_RESOURCE_URL_LOADER); if (!ul) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } struct pp_url_request_info_s *ri = pp_resource_acquire(request_info, PP_RESOURCE_URL_REQUEST_INFO); if (!ri) { trace_error("%s, bad resource\n", __func__); pp_resource_release(loader); return PP_ERROR_BADRESOURCE; } struct PP_Var full_url; if (ri->is_immediate_javascript) { full_url = ppb_var_var_from_utf8_z(ri->url); } else { struct PP_Var rel_url = ppb_var_var_from_utf8_z(ri->url); full_url = ppb_url_util_resolve_relative_to_document(ul->instance->id, rel_url, NULL); ppb_var_release(rel_url); } ul->url = nullsafe_strdup(ppb_var_var_to_utf8(full_url, NULL)); ul->method = ri->method; ul->read_pos = 0; ul->request_headers = nullsafe_strdup(ri->headers); ul->follow_redirects = ri->follow_redirects; ul->stream_to_file = ri->stream_to_file; ul->record_download_progress = ri->record_download_progress; ul->record_upload_progress = ri->record_upload_progress; ul->custom_referrer_url = nullsafe_strdup(ri->custom_referrer_url); ul->allow_cross_origin_requests = ri->allow_cross_origin_requests; ul->allow_credentials = ri->allow_credentials; ul->custom_content_transfer_encoding = nullsafe_strdup(ri->custom_content_transfer_encoding); ul->custom_user_agent = nullsafe_strdup(ri->custom_user_agent); ul->target = nullsafe_strdup(target); #define TRIM_NEWLINE(s) s = trim_nl(s) TRIM_NEWLINE(ul->request_headers); TRIM_NEWLINE(ul->custom_referrer_url); TRIM_NEWLINE(ul->custom_content_transfer_encoding); TRIM_NEWLINE(ul->custom_user_agent); post_data_free(ul->post_data); ul->post_data = post_data_duplicate(ri->post_data); ul->fd = open_temporary_file(); ul->ccb = callback; ul->ccb_ml = ppb_message_loop_get_current(); ppb_var_release(full_url); pp_resource_release(request_info); if (config.quirks.connect_first_loader_to_unrequested_stream) { if (ul->instance->content_url_loader == 0) { ul->instance->content_url_loader = loader; pp_resource_release(loader); return PP_OK_COMPLETIONPENDING; } } struct url_loader_open_param_s *p = g_slice_alloc(sizeof(*p)); p->url = ul->url; p->loader = loader; p->instance_id = ul->instance->id; p->method = ul->method; p->request_headers = ul->request_headers; p->custom_referrer_url = ul->custom_referrer_url; p->custom_content_transfer_encoding = ul->custom_content_transfer_encoding; p->custom_user_agent = ul->custom_user_agent; p->target = ul->target; p->post_data = ul->post_data; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_core_add_ref_resource(loader); // add ref to ensure data in ul remain accessible pp_resource_release(loader); ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(url_loader_open_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); int retval = p->retval; g_slice_free1(sizeof(*p), p); if (retval != NPERR_NO_ERROR) return PP_ERROR_FAILED; if (callback.func == NULL) { // TODO: remove busy loop int done = 0; while (!done) { ul = pp_resource_acquire(loader, PP_RESOURCE_URL_LOADER); if (ul) { done = ul->finished_loading; pp_resource_release(loader); } else { break; } printf("waitin'\n"); usleep(10000); } return PP_OK; } return PP_OK_COMPLETIONPENDING; } int32_t ppb_url_loader_follow_redirect(PP_Resource loader, struct PP_CompletionCallback callback) { struct pp_url_loader_s *ul = pp_resource_acquire(loader, PP_RESOURCE_URL_LOADER); if (!ul) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } char *new_url = nullsafe_strdup(ul->redirect_url); free_and_nullify(ul->url); free_and_nullify(ul->redirect_url); free_and_nullify(ul->status_line); free_and_nullify(ul->headers); free_and_nullify(ul->request_headers); post_data_free(ul->post_data); ul->post_data = NULL; if (ul->fd >= 0) { close(ul->fd); ul->fd = -1; } // abort further handling of the NPStream if (ul->np_stream) { ul->np_stream->pdata = NULL; ul->np_stream = NULL; } ul->fd = open_temporary_file(); ul->url = new_url; ul->read_pos = 0; ul->method = PP_METHOD_GET; ul->ccb = callback; ul->ccb_ml = ppb_message_loop_get_current(); struct url_loader_open_param_s *p = g_slice_alloc(sizeof(*p)); p->url = ul->url; p->loader = loader; p->instance_id = ul->instance->id; p->method = ul->method; p->request_headers = ul->request_headers; p->custom_referrer_url = ul->custom_referrer_url; p->custom_content_transfer_encoding = ul->custom_content_transfer_encoding; p->custom_user_agent = ul->custom_user_agent; p->target = NULL; p->post_len = 0; p->post_data = NULL; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_core_add_ref_resource(loader); // add ref to ensure data in ul remain accessible pp_resource_release(loader); ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(url_loader_open_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); int retval = p->retval; g_slice_free1(sizeof(*p), p); if (retval != NPERR_NO_ERROR) return PP_ERROR_FAILED; if (callback.func == NULL) { // TODO: remove busy loop int done = 0; while (!done) { ul = pp_resource_acquire(loader, PP_RESOURCE_URL_LOADER); if (ul) { done = ul->finished_loading; pp_resource_release(loader); } else { break; } printf("waitin'\n"); usleep(10000); } return PP_OK; } return PP_OK_COMPLETIONPENDING; } PP_Bool ppb_url_loader_get_upload_progress(PP_Resource loader, int64_t *bytes_sent, int64_t *total_bytes_to_be_sent) { // TODO: how to get upload progress // Apparently there is no way to determine upload progress using NPAPI. // However, one can try to create anonymous fifo and push data to it. // How particularly browser handles file is still to be discovered. Note, // each browser can do it differently. return PP_FALSE; } PP_Bool ppb_url_loader_get_download_progress(PP_Resource loader, int64_t *bytes_received, int64_t *total_bytes_to_be_received) { struct pp_url_loader_s *ul = pp_resource_acquire(loader, PP_RESOURCE_URL_LOADER); if (!ul) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } *total_bytes_to_be_received = ul->response_size; *bytes_received = 0; if (ul->fd >= 0) { struct stat sb; if (fstat(ul->fd, &sb) != 0) { pp_resource_release(loader); *bytes_received = -1; return PP_FALSE; } *bytes_received = sb.st_size; } pp_resource_release(loader); return PP_TRUE; } PP_Resource ppb_url_loader_get_response_info(PP_Resource loader) { struct pp_url_loader_s *ul = pp_resource_acquire(loader, PP_RESOURCE_URL_LOADER); if (!ul) { trace_error("%s, bad resource\n", __func__); return 0; } PP_Resource response_info = pp_resource_allocate(PP_RESOURCE_URL_RESPONSE_INFO, ul->instance); struct pp_url_response_info_s *ri = pp_resource_acquire(response_info, PP_RESOURCE_URL_RESPONSE_INFO); if (!ri) { trace_error("%s, resource allocation failure\n", __func__); pp_resource_release(loader); return 0; } pp_resource_ref(loader); ri->url_loader_id = loader; ri->url_loader = ul; pp_resource_release(response_info); pp_resource_release(loader); return response_info; } int32_t ppb_url_loader_read_response_body(PP_Resource loader, void *buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback) { struct url_loader_read_task_s *rt; int32_t read_bytes = PP_ERROR_FAILED; struct pp_url_loader_s *ul = pp_resource_acquire(loader, PP_RESOURCE_URL_LOADER); if (!ul) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } if (ul->fd == -1) { trace_error("%s, fd==-1\n", __func__); pp_resource_release(loader); return PP_ERROR_FAILED; } if (ul->read_tasks) { // schedule task instead of immediate reading if there is another task // in the queue already goto schedule_read_task; } read_bytes = -1; off_t ofs = lseek(ul->fd, ul->read_pos, SEEK_SET); if (ofs != (off_t)-1) read_bytes = RETRY_ON_EINTR(read(ul->fd, buffer, bytes_to_read)); if (read_bytes < 0) read_bytes = PP_ERROR_FAILED; else ul->read_pos += read_bytes; if (read_bytes == 0 && !ul->finished_loading) { // no data ready, schedule read task goto schedule_read_task; } pp_resource_release(loader); if (callback.flags & PP_COMPLETIONCALLBACK_FLAG_OPTIONAL) return read_bytes; ppb_message_loop_post_work_with_result(ppb_message_loop_get_current(), callback, 0, read_bytes, 0, __func__); return PP_OK_COMPLETIONPENDING; schedule_read_task: rt = g_slice_alloc(sizeof(*rt)); rt->url_loader = loader; rt->buffer = buffer; rt->bytes_to_read = bytes_to_read; rt->ccb = callback; rt->ccb_ml = ppb_message_loop_get_current(); ul->read_tasks = g_list_append(ul->read_tasks, rt); pp_resource_release(loader); return PP_OK_COMPLETIONPENDING; } int32_t ppb_url_loader_finish_streaming_to_file(PP_Resource loader, struct PP_CompletionCallback callback) { struct pp_url_loader_s *ul = pp_resource_acquire(loader, PP_RESOURCE_URL_LOADER); if (!ul) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } if (!ul->stream_to_file) { trace_error("%s, not streaming to file\n", __func__); pp_resource_release(loader); return PP_ERROR_FAILED; } ul->stream_to_file_ccb = callback; ul->stream_to_file_ccb_ml = ppb_message_loop_get_current(); // TODO: handle callback.func == NULL case pp_resource_release(loader); return PP_OK_COMPLETIONPENDING; } void ppb_url_loader_close(PP_Resource loader) { struct pp_url_loader_s *ul = pp_resource_acquire(loader, PP_RESOURCE_URL_LOADER); if (!ul) { trace_error("%s, bad resource\n", __func__); return; } if (ul->fd >= 0) { close(ul->fd); ul->fd = -1; } free_and_nullify(ul->headers); free_and_nullify(ul->url); pp_resource_release(loader); return; } void ppb_url_loader_grant_universal_access(PP_Resource loader) { trace_info_f(" no-op implementation, all request are always allowed\n"); return; } void ppb_url_loader_register_status_callback(PP_Resource loader, PP_URLLoaderTrusted_StatusCallback cb) { return; } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_url_loader_create(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_url_loader_create(instance); } TRACE_WRAPPER PP_Bool trace_ppb_url_loader_is_url_loader(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_url_loader_is_url_loader(resource); } TRACE_WRAPPER int32_t trace_ppb_url_loader_open(PP_Resource loader, PP_Resource request_info, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s loader=%d, request_info=%d, callback={.func=%p, .user_data=%p, " ".flags=%d}\n", __func__+6, loader, request_info, callback.func, callback.user_data, callback.flags); return ppb_url_loader_open(loader, request_info, callback); } TRACE_WRAPPER int32_t trace_ppb_url_loader_follow_redirect(PP_Resource loader, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s loader=%d, callback={.func=%p, .user_data=%p, .flags=%d}\n", __func__+6, loader, callback.func, callback.user_data, callback.flags); return ppb_url_loader_follow_redirect(loader, callback); } TRACE_WRAPPER PP_Bool trace_ppb_url_loader_get_upload_progress(PP_Resource loader, int64_t *bytes_sent, int64_t *total_bytes_to_be_sent) { trace_info("[PPB] {full} %s loader=%d\n", __func__+6, loader); return ppb_url_loader_get_upload_progress(loader, bytes_sent, total_bytes_to_be_sent); } TRACE_WRAPPER PP_Bool trace_ppb_url_loader_get_download_progress(PP_Resource loader, int64_t *bytes_received, int64_t *total_bytes_to_be_received) { trace_info("[PPB] {full} %s loader=%d\n", __func__+6, loader); return ppb_url_loader_get_download_progress(loader, bytes_received, total_bytes_to_be_received); } TRACE_WRAPPER PP_Resource trace_ppb_url_loader_get_response_info(PP_Resource loader) { trace_info("[PPB] {full} %s loader=%d\n", __func__+6, loader); return ppb_url_loader_get_response_info(loader); } TRACE_WRAPPER int32_t trace_ppb_url_loader_read_response_body(PP_Resource loader, void *buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s loader=%d, buffer=%p, bytes_to_read=%d, callback={.func=%p, " ".user_data=%p, .flags=%d}\n", __func__+6, loader, buffer, bytes_to_read, callback.func, callback.user_data, callback.flags); return ppb_url_loader_read_response_body(loader, buffer, bytes_to_read, callback); } TRACE_WRAPPER int32_t trace_ppb_url_loader_finish_streaming_to_file(PP_Resource loader, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s loader=%d callback={.func=%p, .user_data=%p, flags=%d}\n", __func__+6, loader, callback.func, callback.user_data, callback.flags); return ppb_url_loader_finish_streaming_to_file(loader, callback); } TRACE_WRAPPER void trace_ppb_url_loader_close(PP_Resource loader) { trace_info("[PPB] {full} %s loader=%d\n", __func__+6, loader); ppb_url_loader_close(loader); } TRACE_WRAPPER void trace_ppb_url_loader_grant_universal_access(PP_Resource loader) { trace_info("[PPB] {full} %s loader=%d\n", __func__+6, loader); ppb_url_loader_grant_universal_access(loader); } TRACE_WRAPPER void trace_ppb_url_loader_register_status_callback(PP_Resource loader, PP_URLLoaderTrusted_StatusCallback cb) { trace_info("[PPB] {zilch} %s loader=%d, cb=%p\n", __func__+6, loader, cb); ppb_url_loader_register_status_callback(loader, cb); } const struct PPB_URLLoader_1_0 ppb_url_loader_interface_1_0 = { .Create = TWRAPF(ppb_url_loader_create), .IsURLLoader = TWRAPF(ppb_url_loader_is_url_loader), .Open = TWRAPF(ppb_url_loader_open), .FollowRedirect = TWRAPF(ppb_url_loader_follow_redirect), .GetUploadProgress = TWRAPF(ppb_url_loader_get_upload_progress), .GetDownloadProgress = TWRAPF(ppb_url_loader_get_download_progress), .GetResponseInfo = TWRAPF(ppb_url_loader_get_response_info), .ReadResponseBody = TWRAPF(ppb_url_loader_read_response_body), .FinishStreamingToFile = TWRAPF(ppb_url_loader_finish_streaming_to_file), .Close = TWRAPF(ppb_url_loader_close), }; const struct PPB_URLLoaderTrusted_0_3 ppb_url_loader_trusted_interface_0_3 = { .GrantUniversalAccess = TWRAPF(ppb_url_loader_grant_universal_access), .RegisterStatusCallback = TWRAPZ(ppb_url_loader_register_status_callback), }; static void __attribute__((constructor)) constructor_ppb_url_loader(void) { register_interface(PPB_URLLOADER_INTERFACE_1_0, &ppb_url_loader_interface_1_0); register_interface(PPB_URLLOADERTRUSTED_INTERFACE_0_3, &ppb_url_loader_trusted_interface_0_3); register_resource(PP_RESOURCE_URL_LOADER, ppb_url_loader_destroy); } freshplayerplugin-0.3.9/src/ppb_url_loader.h000066400000000000000000000117531321746453100212340ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include "pp_resource.h" #include #include #include #include #include struct pp_url_loader_s { COMMON_STRUCTURE_FIELDS char *status_line; ///< HTTP/1.1 200 OK char *headers; ///< response headers int http_code; ///< HTTP response code int fd; ///< file used to store response size_t read_pos; ///< reading position enum pp_request_method_e method; ///< GET/POST char *url; ///< request URL char *redirect_url; ///< value of the Location header if this is ///< a redirection response int finished_loading; ///< if whole stream loaded already int64_t response_size; ///< Content-Length value of -1 if absent int stream_to_file; ///< whenever streaming to file is allowed struct PP_CompletionCallback stream_to_file_ccb; ///< callback to call on end of streaming PP_Resource stream_to_file_ccb_ml; ///< message loop to call callback on char *request_headers; PP_Bool follow_redirects; ///< handle redirections internally PP_Bool record_download_progress; PP_Bool record_upload_progress; char *custom_referrer_url; PP_Bool allow_cross_origin_requests; PP_Bool allow_credentials; char *custom_content_transfer_encoding; char *custom_user_agent; char *target; GArray *post_data; GList *read_tasks; ///< list of url_loader_read_task_s NPStream *np_stream; ///< associated NPStream struct PP_CompletionCallback ccb; ///< callback to call on headers arrival PP_Resource ccb_ml; ///< message loop to call callback on }; struct url_loader_read_task_s { PP_Resource url_loader; void *buffer; int32_t bytes_to_read; struct PP_CompletionCallback ccb; PP_Resource ccb_ml; }; PP_Resource ppb_url_loader_create(PP_Instance instance); PP_Bool ppb_url_loader_is_url_loader(PP_Resource resource); int32_t ppb_url_loader_open(PP_Resource loader, PP_Resource request_info, struct PP_CompletionCallback callback); int32_t ppb_url_loader_open_target(PP_Resource loader, PP_Resource request_info, struct PP_CompletionCallback callback, const char *target); int32_t ppb_url_loader_follow_redirect(PP_Resource loader, struct PP_CompletionCallback callback); PP_Bool ppb_url_loader_get_upload_progress(PP_Resource loader, int64_t *bytes_sent, int64_t *total_bytes_to_be_sent); PP_Bool ppb_url_loader_get_download_progress(PP_Resource loader, int64_t *bytes_received, int64_t *total_bytes_to_be_received); PP_Resource ppb_url_loader_get_response_info(PP_Resource loader); int32_t ppb_url_loader_read_response_body(PP_Resource loader, void *buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback); int32_t ppb_url_loader_finish_streaming_to_file(PP_Resource loader, struct PP_CompletionCallback callback); void ppb_url_loader_close(PP_Resource loader); void ppb_url_loader_grant_universal_access(PP_Resource loader); void ppb_url_loader_register_status_callback(PP_Resource loader, PP_URLLoaderTrusted_StatusCallback cb); freshplayerplugin-0.3.9/src/ppb_url_request_info.c000066400000000000000000000351611321746453100224630ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "eintr_retry.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_core.h" #include "ppb_flash_file.h" #include "ppb_url_request_info.h" #include "ppb_var.h" #include "reverse_constant.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include "utils.h" #include #include #include #include #include #include #include #include STATIC_ASSERT(sizeof(struct pp_url_request_info_s) <= LARGEST_RESOURCE_SIZE); PP_Resource ppb_url_request_info_create(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource request_info = pp_resource_allocate(PP_RESOURCE_URL_REQUEST_INFO, pp_i); struct pp_url_request_info_s *ri = pp_resource_acquire(request_info, PP_RESOURCE_URL_REQUEST_INFO); if (!ri) { trace_error("%s, resource allocation failure\n", __func__); return 0; } ri->method = PP_METHOD_UNKNOWN; ri->url = NULL; ri->headers = NULL; ri->stream_to_file = PP_FALSE; ri->follow_redirects = PP_TRUE; ri->record_download_progress = PP_FALSE; ri->record_upload_progress = PP_FALSE; ri->custom_referrer_url = NULL; ri->allow_cross_origin_requests = PP_FALSE; ri->allow_credentials = PP_FALSE; ri->custom_content_transfer_encoding = NULL; ri->prefetch_buffer_upper_threshold = -1; ri->prefetch_buffer_lower_threshold = -1; ri->custom_user_agent = NULL; ri->post_data = post_data_new(); pp_resource_release(request_info); return request_info; } static void ppb_url_request_info_destroy(void *p) { struct pp_url_request_info_s *ri = p; if (!ri) return; free_and_nullify(ri->url); free_and_nullify(ri->headers); free_and_nullify(ri->custom_referrer_url); free_and_nullify(ri->custom_content_transfer_encoding); free_and_nullify(ri->custom_user_agent); post_data_free(ri->post_data); ri->post_data = NULL; } PP_Bool ppb_url_request_info_is_url_request_info(PP_Resource resource) { return PP_RESOURCE_URL_REQUEST_INFO == pp_resource_get_type(resource); } static const char * ltrim(const char *s) { while (*s && isspace(*s)) s++; return s; } PP_Bool ppb_url_request_info_set_property(PP_Resource request, PP_URLRequestProperty property, struct PP_Var value) { const char *tmp, *tmp2; PP_Bool retval = PP_TRUE; struct pp_url_request_info_s *ri = pp_resource_acquire(request, PP_RESOURCE_URL_REQUEST_INFO); if (!ri) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } #define ENSURE_TYPE(vartype) if (value.type != vartype) { retval = PP_FALSE; break; } switch (property) { case PP_URLREQUESTPROPERTY_URL: ENSURE_TYPE(PP_VARTYPE_STRING); free_and_nullify(ri->url); tmp = ppb_var_var_to_utf8(value, NULL); tmp2 = ltrim(tmp); ri->url = strdup(tmp2); ri->is_immediate_javascript = (strncasecmp(tmp2, "javascript:", strlen("javascript:"))==0); break; case PP_URLREQUESTPROPERTY_METHOD: ENSURE_TYPE(PP_VARTYPE_STRING); tmp = ppb_var_var_to_utf8(value, NULL); if (strcmp(tmp, "GET") == 0) { ri->method = PP_METHOD_GET; } else if (strcmp(tmp, "POST") == 0) { ri->method = PP_METHOD_POST; } else { trace_warning("%s, unknown method %s\n", __func__, tmp); ri->method = PP_METHOD_UNKNOWN; } break; case PP_URLREQUESTPROPERTY_HEADERS: ENSURE_TYPE(PP_VARTYPE_STRING); free_and_nullify(ri->headers); ri->headers = strdup(ppb_var_var_to_utf8(value, NULL)); break; case PP_URLREQUESTPROPERTY_STREAMTOFILE: ENSURE_TYPE(PP_VARTYPE_BOOL); ri->stream_to_file = value.value.as_bool; break; case PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS: ENSURE_TYPE(PP_VARTYPE_BOOL); ri->follow_redirects = value.value.as_bool; break; case PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS: ENSURE_TYPE(PP_VARTYPE_BOOL); ri->record_download_progress = value.value.as_bool; break; case PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS: ENSURE_TYPE(PP_VARTYPE_BOOL); ri->record_upload_progress = value.value.as_bool; break; case PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL: ENSURE_TYPE(PP_VARTYPE_STRING); free_and_nullify(ri->custom_referrer_url); ri->custom_referrer_url = strdup(ppb_var_var_to_utf8(value, NULL)); break; case PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS: ENSURE_TYPE(PP_VARTYPE_BOOL); ri->allow_cross_origin_requests = value.value.as_bool; break; case PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS: ENSURE_TYPE(PP_VARTYPE_BOOL); ri->allow_credentials = value.value.as_bool; break; case PP_URLREQUESTPROPERTY_CUSTOMCONTENTTRANSFERENCODING: ENSURE_TYPE(PP_VARTYPE_STRING); free_and_nullify(ri->custom_content_transfer_encoding); ri->custom_content_transfer_encoding = strdup(ppb_var_var_to_utf8(value, NULL)); break; case PP_URLREQUESTPROPERTY_PREFETCHBUFFERUPPERTHRESHOLD: ENSURE_TYPE(PP_VARTYPE_INT32); ri->prefetch_buffer_upper_threshold = value.value.as_int; break; case PP_URLREQUESTPROPERTY_PREFETCHBUFFERLOWERTHRESHOLD: ENSURE_TYPE(PP_VARTYPE_INT32); ri->prefetch_buffer_lower_threshold = value.value.as_int; break; case PP_URLREQUESTPROPERTY_CUSTOMUSERAGENT: ENSURE_TYPE(PP_VARTYPE_STRING); free_and_nullify(ri->custom_user_agent); ri->custom_user_agent = strdup(ppb_var_var_to_utf8(value, NULL)); break; default: trace_error("%s, unknown url request property %d\n", __func__, property); retval = PP_FALSE; break; } pp_resource_release(request); return retval; } PP_Bool ppb_url_request_info_append_data_to_body(PP_Resource request, const void *data, uint32_t len) { struct pp_url_request_info_s *ri = pp_resource_acquire(request, PP_RESOURCE_URL_REQUEST_INFO); if (!ri) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } PP_Bool retval = PP_FALSE; struct post_data_item_s pdi = { 0 }; pdi.data = g_memdup(data, len); if (!pdi.data) { retval = PP_FALSE; goto err; } pdi.len = len; g_array_append_val(ri->post_data, pdi); retval = PP_TRUE; err: pp_resource_release(request); return retval; } PP_Bool ppb_url_request_info_append_file_to_body(PP_Resource request, PP_Resource file_ref, int64_t start_offset, int64_t number_of_bytes, PP_Time expected_last_modified_time) { struct pp_url_request_info_s *ri = pp_resource_acquire(request, PP_RESOURCE_URL_REQUEST_INFO); if (!ri) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } struct post_data_item_s pdi = { 0 }; ppb_core_add_ref_resource(file_ref); pdi.file_ref = file_ref; pdi.start_offset = start_offset; pdi.number_of_bytes = number_of_bytes; pdi.expected_last_modified_time = expected_last_modified_time; g_array_append_val(ri->post_data, pdi); pp_resource_release(request); return PP_TRUE; } GArray * post_data_new(void) { return g_array_new(FALSE, TRUE, sizeof(struct post_data_item_s)); } GArray * post_data_duplicate(GArray *post_data) { GArray *post_data2; if (!post_data) return NULL; post_data2 = post_data_new(); if (!post_data2) return NULL; for (guint k = 0; k < post_data->len; k ++) { struct post_data_item_s *pdi = &g_array_index(post_data, struct post_data_item_s, k); struct post_data_item_s pdi2 = *pdi; if (pdi2.file_ref != 0) { ppb_core_add_ref_resource(pdi2.file_ref); } else { pdi2.data = g_memdup(pdi->data, pdi->len); if (!pdi2.data) { trace_error("%s, can't allocate memory\n", __func__); continue; } } g_array_append_val(post_data2, pdi2); } return post_data2; } static size_t post_data_get_item_length(struct post_data_item_s *pdi) { if (pdi->file_ref != 0) { size_t start_offset = MAX(pdi->start_offset, 0); struct PP_FileInfo finfo; if (ppb_flash_file_file_ref_query_file(pdi->file_ref, &finfo) != PP_OK) return (size_t)-1; if (pdi->expected_last_modified_time != 0 && finfo.last_modified_time != pdi->expected_last_modified_time) { return (size_t)-1; } if (pdi->number_of_bytes >= 0) { return (size_t)pdi->number_of_bytes; } else if (finfo.size <= (int64_t)start_offset) { return 0; } else { return finfo.size - start_offset; } } else { return pdi->len; } } size_t post_data_get_all_item_length(GArray *post_data) { size_t total_len = 0; for (guint k = 0; k < post_data->len; k ++) { struct post_data_item_s *pdi = &g_array_index(post_data, struct post_data_item_s, k); size_t item_len = post_data_get_item_length(pdi); if (item_len == (size_t)-1) goto err; total_len += item_len; } return total_len; err: return (size_t)-1; } void post_data_free(GArray *post_data) { if (!post_data) return; for (guint k = 0; k < post_data->len; k ++) { struct post_data_item_s *pdi = &g_array_index(post_data, struct post_data_item_s, k); if (pdi->file_ref != 0) ppb_core_release_resource(pdi->file_ref); else free(pdi->data); } post_data->len = 0; // set length to zero to avoid double freing g_array_unref(post_data); } void post_data_write_to_gstring(GArray *post_data, guint idx, GString *s) { char buf[128 * 1024]; struct post_data_item_s *pdi = &g_array_index(post_data, struct post_data_item_s, idx); if (pdi->file_ref != 0) { int fd = -1; if (ppb_flash_file_file_ref_open_file(pdi->file_ref, PP_FILEOPENFLAG_READ, &fd) != PP_OK) { // some error, skipping this one goto err; } size_t to_write = post_data_get_item_length(pdi); while (to_write > 0) { ssize_t read_bytes = RETRY_ON_EINTR(read(fd, buf, MIN(to_write, sizeof(buf)))); if (read_bytes == -1) goto err; g_string_append_len(s, buf, (size_t)read_bytes); to_write -= read_bytes; } err: if (fd >= 0) close(fd); } else { g_string_append_len(s, pdi->data, pdi->len); } } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_url_request_info_create(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_url_request_info_create(instance); } TRACE_WRAPPER PP_Bool trace_ppb_url_request_info_is_url_request_info(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_url_request_info_is_url_request_info(resource); } TRACE_WRAPPER PP_Bool trace_ppb_url_request_info_set_property(PP_Resource request, PP_URLRequestProperty property, struct PP_Var value) { char *value_str = trace_var_as_string(value); trace_info("[PPB] {full} %s request=%d, property=%s, value=%s\n", __func__+6, request, reverse_pp_url_request_property(property), value_str); g_free(value_str); return ppb_url_request_info_set_property(request, property, value); } TRACE_WRAPPER PP_Bool trace_ppb_url_request_info_append_data_to_body(PP_Resource request, const void *data, uint32_t len) { trace_info("[PPB] {full} %s request=%d, data=%p, len=%u\n", __func__+6, request, data, len); return ppb_url_request_info_append_data_to_body(request, data, len); } TRACE_WRAPPER PP_Bool trace_ppb_url_request_info_append_file_to_body(PP_Resource request, PP_Resource file_ref, int64_t start_offset, int64_t number_of_bytes, PP_Time expected_last_modified_time) { trace_info("[PPB] {full} %s request=%d, file_ref=%d, start_offset=%"PRId64", " "number_of_bytes=%"PRId64", expected_last_modified_time=%f\n", __func__+6, request, file_ref, start_offset, number_of_bytes, expected_last_modified_time); return ppb_url_request_info_append_file_to_body(request, file_ref, start_offset, number_of_bytes, expected_last_modified_time); } const struct PPB_URLRequestInfo_1_0 ppb_url_request_info_interface_1_0 = { .Create = TWRAPF(ppb_url_request_info_create), .IsURLRequestInfo = TWRAPF(ppb_url_request_info_is_url_request_info), .SetProperty = TWRAPF(ppb_url_request_info_set_property), .AppendDataToBody = TWRAPF(ppb_url_request_info_append_data_to_body), .AppendFileToBody = TWRAPF(ppb_url_request_info_append_file_to_body), }; static void __attribute__((constructor)) constructor_ppb_url_request_info(void) { register_interface(PPB_URLREQUESTINFO_INTERFACE_1_0, &ppb_url_request_info_interface_1_0); register_resource(PP_RESOURCE_URL_REQUEST_INFO, ppb_url_request_info_destroy); } freshplayerplugin-0.3.9/src/ppb_url_request_info.h000066400000000000000000000066171321746453100224740ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include "pp_resource.h" #include #include #include #include #include struct pp_url_request_info_s { COMMON_STRUCTURE_FIELDS enum pp_request_method_e method; char *url; char *headers; unsigned int is_immediate_javascript; // data in url is javascript line PP_Bool stream_to_file; PP_Bool follow_redirects; PP_Bool record_download_progress; PP_Bool record_upload_progress; char *custom_referrer_url; PP_Bool allow_cross_origin_requests; PP_Bool allow_credentials; char *custom_content_transfer_encoding; int32_t prefetch_buffer_upper_threshold; int32_t prefetch_buffer_lower_threshold; char *custom_user_agent; GArray *post_data; }; /// descriptor of post data item struct post_data_item_s { char *data; size_t len; PP_Resource file_ref; ///< non-zero if the item is file slice int64_t start_offset; int64_t number_of_bytes; PP_Time expected_last_modified_time; }; GArray * post_data_new(void); GArray * post_data_duplicate(GArray *post_data); void post_data_free(GArray *post_data); size_t post_data_get_all_item_length(GArray *post_data); void post_data_write_to_gstring(GArray *post_data, guint idx, GString *buf); PP_Resource ppb_url_request_info_create(PP_Instance instance); PP_Bool ppb_url_request_info_is_url_request_info(PP_Resource resource); PP_Bool ppb_url_request_info_set_property(PP_Resource request, PP_URLRequestProperty property, struct PP_Var value); PP_Bool ppb_url_request_info_append_data_to_body(PP_Resource request, const void *data, uint32_t len); PP_Bool ppb_url_request_info_append_file_to_body(PP_Resource request, PP_Resource file_ref, int64_t start_offset, int64_t number_of_bytes, PP_Time expected_last_modified_time); freshplayerplugin-0.3.9/src/ppb_url_response_info.c000066400000000000000000000122621321746453100226260ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "pp_resource.h" #include "ppb_file_ref.h" #include "ppb_url_loader.h" #include "ppb_url_response_info.h" #include "ppb_var.h" #include "reverse_constant.h" #include "static_assert.h" #include "trace_core.h" #include STATIC_ASSERT(sizeof(struct pp_url_response_info_s) <= LARGEST_RESOURCE_SIZE); PP_Bool ppb_url_response_info_is_url_response_info(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_URL_RESPONSE_INFO; } static void ppb_url_response_info_destroy(void *p) { struct pp_url_response_info_s *ri = p; pp_resource_unref(ri->url_loader_id); } struct PP_Var ppb_url_response_info_get_property(PP_Resource response, PP_URLResponseProperty property) { struct pp_url_response_info_s *ri = pp_resource_acquire(response,PP_RESOURCE_URL_RESPONSE_INFO); if (!ri) { trace_error("%s, bad resource\n", __func__); return PP_MakeUndefined(); } struct pp_url_loader_s *ul = ri->url_loader; struct PP_Var var = PP_MakeUndefined(); switch (property) { case PP_URLRESPONSEPROPERTY_URL: var = ppb_var_var_from_utf8_z(ul->url); break; case PP_URLRESPONSEPROPERTY_REDIRECTURL: var = ppb_var_var_from_utf8_z(ul->redirect_url); break; case PP_URLRESPONSEPROPERTY_REDIRECTMETHOD: // redirection is believed to be always GET // TODO: check whenever it may be HEAD var = ppb_var_var_from_utf8_z("GET"); break; case PP_URLRESPONSEPROPERTY_STATUSCODE: var.type = PP_VARTYPE_INT32; var.value.as_int = ul->http_code; break; case PP_URLRESPONSEPROPERTY_STATUSLINE: var = ppb_var_var_from_utf8_z(ul->status_line); break; case PP_URLRESPONSEPROPERTY_HEADERS: var = ppb_var_var_from_utf8_z(ul->headers); break; } pp_resource_release(response); return var; } PP_Resource ppb_url_response_info_get_body_as_file_ref(PP_Resource response) { struct pp_url_response_info_s *ri = pp_resource_acquire(response,PP_RESOURCE_URL_RESPONSE_INFO); if (!ri) { trace_error("%s, bad resource\n", __func__); return 0; } struct pp_url_loader_s *ul = ri->url_loader; PP_Resource file_ref = pp_resource_allocate(PP_RESOURCE_FILE_REF, ri->instance); struct pp_file_ref_s *fr = pp_resource_acquire(file_ref, PP_RESOURCE_FILE_REF); if (!fr) { trace_error("%s, resource allocation failure\n", __func__); pp_resource_release(response); return 0; } fr->fd = dup(ul->fd); fr->type = PP_FILE_REF_TYPE_FD; pp_resource_release(file_ref); pp_resource_release(response); return file_ref; } // trace wrappers TRACE_WRAPPER PP_Bool trace_ppb_url_response_info_is_url_response_info(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_url_response_info_is_url_response_info(resource); } TRACE_WRAPPER struct PP_Var trace_ppb_url_response_info_get_property(PP_Resource response, PP_URLResponseProperty property) { trace_info("[PPB] {full} %s response=%d, property=%s\n", __func__+6, response, reverse_pp_url_response_property(property)); return ppb_url_response_info_get_property(response, property); } TRACE_WRAPPER PP_Resource trace_ppb_url_response_info_get_body_as_file_ref(PP_Resource response) { trace_info("[PPB] {full} %s response=%d\n", __func__+6, response); return ppb_url_response_info_get_body_as_file_ref(response); } const struct PPB_URLResponseInfo_1_0 ppb_url_response_info_interface_1_0 = { .IsURLResponseInfo = TWRAPF(ppb_url_response_info_is_url_response_info), .GetProperty = TWRAPF(ppb_url_response_info_get_property), .GetBodyAsFileRef = TWRAPF(ppb_url_response_info_get_body_as_file_ref), }; static void __attribute__((constructor)) constructor_ppb_url_response_info(void) { register_interface(PPB_URLRESPONSEINFO_INTERFACE_1_0, &ppb_url_response_info_interface_1_0); register_resource(PP_RESOURCE_URL_RESPONSE_INFO, ppb_url_response_info_destroy); } freshplayerplugin-0.3.9/src/ppb_url_response_info.h000066400000000000000000000032051321746453100226300ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include "pp_resource.h" #include struct pp_url_response_info_s { COMMON_STRUCTURE_FIELDS PP_Resource url_loader_id; struct pp_url_loader_s *url_loader; }; PP_Bool ppb_url_response_info_is_url_response_info(PP_Resource resource); struct PP_Var ppb_url_response_info_get_property(PP_Resource response, PP_URLResponseProperty property); PP_Resource ppb_url_response_info_get_body_as_file_ref(PP_Resource response); freshplayerplugin-0.3.9/src/ppb_url_util.c000066400000000000000000000206261321746453100207350ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "ppb_instance.h" #include "ppb_url_util.h" #include "ppb_var.h" #include "tables.h" #include "trace_core.h" #include "uri_parser/uri_parser.h" #include #include struct PP_Var ppb_url_util_canonicalize(struct PP_Var url, struct PP_URLComponents_Dev *components) { if (components) uri_parser_parse_uri(ppb_var_var_to_utf8(url, NULL), components); return url; } struct PP_Var ppb_url_util_resolve_relative_to_url(struct PP_Var base_url, struct PP_Var relative_string, struct PP_URLComponents_Dev *components) { const char *s_base_url = ppb_var_var_to_utf8(base_url, NULL); const char *s_relative_string = ppb_var_var_to_utf8(relative_string, NULL); gchar *res = uri_parser_merge_uris(s_base_url, s_relative_string); if (components) uri_parser_parse_uri(res, components); struct PP_Var var = ppb_var_var_from_utf8_z(res); g_free(res); return var; } struct PP_Var ppb_url_util_resolve_relative_to_document(PP_Instance instance, struct PP_Var relative_string, struct PP_URLComponents_Dev *components) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_MakeUndefined(); } return ppb_url_util_resolve_relative_to_url(pp_i->document_base_url, relative_string, components); } PP_Bool ppb_url_util_is_same_security_origin(struct PP_Var url_a, struct PP_Var url_b) { return PP_TRUE; } PP_Bool ppb_url_util_document_can_request(PP_Instance instance, struct PP_Var url) { return PP_TRUE; } PP_Bool ppb_url_util_document_can_access_document(PP_Instance active, PP_Instance target) { return PP_TRUE; } struct PP_Var ppb_url_util_get_document_url(PP_Instance instance, struct PP_URLComponents_Dev *components) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_MakeUndefined(); } if (components) uri_parser_parse_uri(ppb_var_var_to_utf8(pp_i->document_url, NULL), components); return pp_i->document_url; } struct PP_Var ppb_url_util_get_plugin_instance_url(PP_Instance instance, struct PP_URLComponents_Dev *components) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_MakeUndefined(); } struct PP_Var var = pp_i->instance_url; ppb_var_add_ref(var); if (components) uri_parser_parse_uri(ppb_var_var_to_utf8(var, NULL), components); return var; } struct PP_Var ppb_url_util_get_plugin_referrer_url(PP_Instance instance, struct PP_URLComponents_Dev *components) { const char *url = ""; if (components) uri_parser_parse_uri(url, components); return ppb_var_var_from_utf8_z(url); } // trace wrappers TRACE_WRAPPER struct PP_Var trace_ppb_url_util_canonicalize(struct PP_Var url, struct PP_URLComponents_Dev *components) { trace_info("[PPB] {zilch} %s\n", __func__+6); return ppb_url_util_canonicalize(url, components); } TRACE_WRAPPER struct PP_Var trace_ppb_url_util_resolve_relative_to_url(struct PP_Var base_url, struct PP_Var relative_string, struct PP_URLComponents_Dev *components) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_url_util_resolve_relative_to_url(base_url, relative_string, components); } TRACE_WRAPPER struct PP_Var trace_ppb_url_util_resolve_relative_to_document(PP_Instance instance, struct PP_Var relative_string, struct PP_URLComponents_Dev *components) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_url_util_resolve_relative_to_document(instance, relative_string, components); } TRACE_WRAPPER PP_Bool trace_ppb_url_util_is_same_security_origin(struct PP_Var url_a, struct PP_Var url_b) { trace_info("[PPB] {zilch} %s\n", __func__+6); return ppb_url_util_is_same_security_origin(url_a, url_b); } TRACE_WRAPPER PP_Bool trace_ppb_url_util_document_can_request(PP_Instance instance, struct PP_Var url) { trace_info("[PPB] {zilch} %s\n", __func__+6); return ppb_url_util_document_can_request(instance, url); } TRACE_WRAPPER PP_Bool trace_ppb_url_util_document_can_access_document(PP_Instance active, PP_Instance target) { trace_info("[PPB] {zilch} %s active=%d, target=%d\n", __func__+6, active, target); return ppb_url_util_document_can_access_document(active, target); } TRACE_WRAPPER struct PP_Var trace_ppb_url_util_get_document_url(PP_Instance instance, struct PP_URLComponents_Dev *components) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_url_util_get_document_url(instance, components); } TRACE_WRAPPER struct PP_Var trace_ppb_url_util_get_plugin_instance_url(PP_Instance instance, struct PP_URLComponents_Dev *components) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_url_util_get_plugin_instance_url(instance, components); } TRACE_WRAPPER struct PP_Var trace_ppb_url_util_get_plugin_referrer_url(PP_Instance instance, struct PP_URLComponents_Dev *components) { trace_info("[PPB] {zilch} %s instance=%d\n", __func__+6, instance); return ppb_url_util_get_plugin_referrer_url(instance, components); } const struct PPB_URLUtil_Dev_0_6 ppb_url_util_dev_interface_0_6 = { .Canonicalize = TWRAPZ(ppb_url_util_canonicalize), .ResolveRelativeToURL = TWRAPF(ppb_url_util_resolve_relative_to_url), .ResolveRelativeToDocument = TWRAPF(ppb_url_util_resolve_relative_to_document), .IsSameSecurityOrigin = TWRAPZ(ppb_url_util_is_same_security_origin), .DocumentCanRequest = TWRAPZ(ppb_url_util_document_can_request), .DocumentCanAccessDocument = TWRAPZ(ppb_url_util_document_can_access_document), .GetDocumentURL = TWRAPF(ppb_url_util_get_document_url), .GetPluginInstanceURL = TWRAPF(ppb_url_util_get_plugin_instance_url), }; const struct PPB_URLUtil_Dev_0_7 ppb_url_util_dev_interface_0_7 = { .Canonicalize = TWRAPZ(ppb_url_util_canonicalize), .ResolveRelativeToURL = TWRAPF(ppb_url_util_resolve_relative_to_url), .ResolveRelativeToDocument = TWRAPF(ppb_url_util_resolve_relative_to_document), .IsSameSecurityOrigin = TWRAPZ(ppb_url_util_is_same_security_origin), .DocumentCanRequest = TWRAPZ(ppb_url_util_document_can_request), .DocumentCanAccessDocument = TWRAPZ(ppb_url_util_document_can_access_document), .GetDocumentURL = TWRAPF(ppb_url_util_get_document_url), .GetPluginInstanceURL = TWRAPF(ppb_url_util_get_plugin_instance_url), .GetPluginReferrerURL = TWRAPZ(ppb_url_util_get_plugin_referrer_url), }; static void __attribute__((constructor)) constructor_ppb_url_util(void) { register_interface(PPB_URLUTIL_DEV_INTERFACE_0_6, &ppb_url_util_dev_interface_0_6); register_interface(PPB_URLUTIL_DEV_INTERFACE_0_7, &ppb_url_util_dev_interface_0_7); } freshplayerplugin-0.3.9/src/ppb_url_util.h000066400000000000000000000044151321746453100207400ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include struct PP_Var ppb_url_util_canonicalize(struct PP_Var url, struct PP_URLComponents_Dev *components); struct PP_Var ppb_url_util_resolve_relative_to_url(struct PP_Var base_url, struct PP_Var relative_string, struct PP_URLComponents_Dev *components); struct PP_Var ppb_url_util_resolve_relative_to_document(PP_Instance instance, struct PP_Var relative_string, struct PP_URLComponents_Dev *components); PP_Bool ppb_url_util_is_same_security_origin(struct PP_Var url_a, struct PP_Var url_b); PP_Bool ppb_url_util_document_can_request(PP_Instance instance, struct PP_Var url); PP_Bool ppb_url_util_document_can_access_document(PP_Instance active, PP_Instance target); struct PP_Var ppb_url_util_get_document_url(PP_Instance instance, struct PP_URLComponents_Dev *components); struct PP_Var ppb_url_util_get_plugin_instance_url(PP_Instance instance, struct PP_URLComponents_Dev *components); struct PP_Var ppb_url_util_get_plugin_referrer_url(PP_Instance instance, struct PP_URLComponents_Dev *components); freshplayerplugin-0.3.9/src/ppb_var.c000066400000000000000000001177421321746453100176740ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "compat.h" #include "config.h" #include "n2p_proxy_class.h" #include "p2n_proxy_class.h" #include "pp_interface.h" #include "ppb_core.h" #include "ppb_instance.h" #include "ppb_message_loop.h" #include "ppb_var.h" #include "tables.h" #include "trace_core.h" #include "trace_helpers.h" #include "utils.h" #include #include #include #include #include #include #include #include #include static GHashTable *var_ht; static pthread_mutex_t lock; static uint32_t var_id = 1; struct var_s { struct PP_Var var; int ref_count; struct { uint32_t len; char *data; } str; struct { const struct PPP_Class_Deprecated *_class; void *data; } obj; void *map_addr; GHashTable *dict; // string -> struct PP_Var GArray *array; // of struct PP_Var }; static void __attribute__((destructor)) destructor_ppb_var(void) { g_hash_table_unref(var_ht); pthread_mutex_destroy(&lock); } static int reference_countable(struct PP_Var var) { return var.type == PP_VARTYPE_STRING || var.type == PP_VARTYPE_OBJECT || var.type == PP_VARTYPE_ARRAY || var.type == PP_VARTYPE_DICTIONARY || var.type == PP_VARTYPE_ARRAY_BUFFER; } /* should be run with lock held */ static uint32_t get_new_var_id(void) { do { var_id ++; } while (g_hash_table_lookup(var_ht, GSIZE_TO_POINTER(var_id)) != NULL); return var_id; } static struct var_s * get_var_s(struct PP_Var var) { pthread_mutex_lock(&lock); struct var_s *v = g_hash_table_lookup(var_ht, GSIZE_TO_POINTER(var.value.as_id)); pthread_mutex_unlock(&lock); return v; } struct create_np_object_param_s { NPClass *npclass; NPObject *res; PP_Resource m_loop; int32_t depth; }; static void create_np_object_ptac(void *param) { struct create_np_object_param_s *p = param; struct pp_instance_s *pp_i = tables_get_some_pp_instance(); if (pp_i && pp_i->npp) { p->res = npn.createobject(pp_i->npp, p->npclass); } else { p->res = NULL; trace_error("%s, no alive plugin instance\n", __func__); } ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void create_np_object_comt(void *user_data, int32_t result) { ppb_core_call_on_browser_thread(0, create_np_object_ptac, user_data); } static NPObject * create_np_object(NPClass *npclass) { if (ppb_message_loop_get_current() == ppb_message_loop_get_for_browser_thread()) { // already on browser thread, no need to jump there struct pp_instance_s *pp_i = tables_get_some_pp_instance(); return (pp_i && pp_i->npp) ? npn.createobject(pp_i->npp, npclass) : NULL; } struct create_np_object_param_s *p = g_slice_alloc(sizeof(*p)); p->npclass = npclass; p->res = NULL; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(create_np_object_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); NPObject *res = p->res; g_slice_free1(sizeof(*p), p); return res; } struct retain_np_object_param_s { NPObject *np_object; PP_Resource m_loop; int depth; }; static void retain_np_object_ptac(void *param) { struct retain_np_object_param_s *p = param; npn.retainobject(p->np_object); ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); } static void retain_np_object_comt(void *user_data, int32_t result) { ppb_core_call_on_browser_thread(0, retain_np_object_ptac, user_data); } static void retain_np_object(NPObject *np_object) { if (ppb_message_loop_get_current() == ppb_message_loop_get_for_browser_thread()) { // already on browser thread, no need to jump there npn.retainobject(np_object); return; } struct retain_np_object_param_s *p = g_slice_alloc(sizeof(*p)); p->np_object = np_object; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(retain_np_object_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); g_slice_free1(sizeof(*p), p); } NPVariant pp_var_to_np_variant(struct PP_Var var) { NPVariant res; struct var_s *v; switch (var.type) { case PP_VARTYPE_NULL: NULL_TO_NPVARIANT(res); break; case PP_VARTYPE_BOOL: BOOLEAN_TO_NPVARIANT(var.value.as_bool, res); break; case PP_VARTYPE_INT32: INT32_TO_NPVARIANT(var.value.as_int, res); break; case PP_VARTYPE_DOUBLE: DOUBLE_TO_NPVARIANT(var.value.as_double, res); break; case PP_VARTYPE_STRING: do { uint32_t len; const char *s1 = ppb_var_var_to_utf8(var, &len); char *s2 = npn.memalloc(len + 1); // TODO: call on main thread? memcpy(s2, s1, len + 1); res.type = NPVariantType_String; res.value.stringValue.UTF8Length = len; res.value.stringValue.UTF8Characters = s2; } while (0); break; case PP_VARTYPE_OBJECT: v = get_var_s(var); res.type = NPVariantType_Object; if (v->obj._class == &n2p_proxy_class) { res.type = NPVariantType_Object; res.value.objectValue = v->obj.data; retain_np_object(res.value.objectValue); } else { res.value.objectValue = create_np_object(&p2n_proxy_class); if (res.value.objectValue) { struct np_proxy_object_s *np_proxy_object; res.type = NPVariantType_Object; np_proxy_object = (struct np_proxy_object_s *)res.value.objectValue; np_proxy_object->ppobj = var; ppb_var_add_ref(var); } else { VOID_TO_NPVARIANT(res); } } break; case PP_VARTYPE_UNDEFINED: case PP_VARTYPE_ARRAY: case PP_VARTYPE_DICTIONARY: case PP_VARTYPE_ARRAY_BUFFER: case PP_VARTYPE_RESOURCE: default: VOID_TO_NPVARIANT(res); break; } return res; } struct PP_Var np_variant_to_pp_var(NPVariant v) { switch (v.type) { case NPVariantType_Void: return PP_MakeUndefined(); case NPVariantType_Null: return PP_MakeNull(); case NPVariantType_Bool: return PP_MakeBool(v.value.boolValue); case NPVariantType_Int32: return PP_MakeInt32(v.value.intValue); case NPVariantType_Double: return PP_MakeDouble(v.value.doubleValue); case NPVariantType_String: return ppb_var_var_from_utf8(v.value.stringValue.UTF8Characters, v.value.stringValue.UTF8Length); default: return PP_MakeUndefined(); case NPVariantType_Object: if (v.value.objectValue->_class == &p2n_proxy_class) { struct np_proxy_object_s *p = (void *)v.value.objectValue; ppb_var_add_ref(p->ppobj); return p->ppobj; } else { return ppb_var_create_object(0, &n2p_proxy_class, v.value.objectValue); } break; } } void ppb_var_add_ref(struct PP_Var var) { if (!reference_countable(var)) return; pthread_mutex_lock(&lock); void *key = GSIZE_TO_POINTER(var.value.as_id); struct var_s *v = g_hash_table_lookup(var_ht, key); if (v) v->ref_count ++; pthread_mutex_unlock(&lock); } struct PP_Var ppb_var_add_ref2(struct PP_Var var) { ppb_var_add_ref(var); return var; } void ppb_var_release(struct PP_Var var) { if (!reference_countable(var)) return; pthread_mutex_lock(&lock); void *key = GSIZE_TO_POINTER(var.value.as_id); struct var_s *v = g_hash_table_lookup(var_ht, key); int retain = 1; if (v) { v->ref_count --; if (v->ref_count <= 0) { retain = 0; g_hash_table_remove(var_ht, key); } } pthread_mutex_unlock(&lock); if (retain) return; switch (var.type) { case PP_VARTYPE_STRING: free(v->str.data); break; case PP_VARTYPE_OBJECT: if (v->obj._class == &n2p_proxy_class) n2p_proxy_class.Deallocate(v->obj.data); break; case PP_VARTYPE_ARRAY_BUFFER: free(v->str.data); if (v->map_addr) free(v->map_addr); v->map_addr = NULL; break; case PP_VARTYPE_DICTIONARY: g_hash_table_unref(v->dict); break; case PP_VARTYPE_ARRAY: g_array_free(v->array, TRUE); break; default: // do nothing break; } g_slice_free(struct var_s, v); if (config.quirks.dump_variables) { time_t current_time = time(NULL); static uintptr_t throttling = 0; if (current_time % 5 == 0 || config.quirks.dump_variables > 1) { if (!throttling || config.quirks.dump_variables > 1) { pthread_mutex_lock(&lock); GList *key_list = g_hash_table_get_keys(var_ht); guint var_count = g_list_length(key_list); pthread_mutex_unlock(&lock); trace_info("--- %3u variables --------------------------------\n", var_count); GList *lptr = key_list; while (lptr) { pthread_mutex_lock(&lock); struct var_s *v = g_hash_table_lookup(var_ht, lptr->data); struct PP_Var var = v ? v->var : PP_MakeUndefined(); pthread_mutex_unlock(&lock); if (v) { gchar *s_var = trace_var_as_string(var); trace_info("[%d] = %s\n", GPOINTER_TO_INT(lptr->data), s_var); g_free(s_var); } else { trace_info("[%d] expunged\n", GPOINTER_TO_INT(lptr->data)); } lptr = g_list_next(lptr); } g_list_free(key_list); trace_info("==================================================\n"); throttling = 1; } } else { throttling = 0; } } } int ppb_var_get_ref_count(struct PP_Var var) { if (!reference_countable(var)) return 0; pthread_mutex_lock(&lock); void *key = GSIZE_TO_POINTER(var.value.as_id); struct var_s *v = g_hash_table_lookup(var_ht, key); int ref_count = v ? v->ref_count : 0; pthread_mutex_unlock(&lock); return ref_count; } struct PP_Var ppb_var_var_from_utf8(const char *data, uint32_t len) { struct var_s *v = g_slice_alloc(sizeof(*v)); struct PP_Var var = {}; var.type = PP_VARTYPE_STRING; v->str.len = len; v->str.data = malloc(len + 1); if (data) memcpy(v->str.data, data, len); else memset(v->str.data, 0, len); v->str.data[len] = 0; // ensure all strings are zero terminated v->ref_count = 1; pthread_mutex_lock(&lock); var.value.as_id = get_new_var_id(); v->var = var; g_hash_table_insert(var_ht, GSIZE_TO_POINTER(var.value.as_id), v); pthread_mutex_unlock(&lock); return var; } struct PP_Var ppb_var_var_from_utf8_z(const char *data) { return ppb_var_var_from_utf8(data, data ? strlen(data) : 0); } struct PP_Var ppb_var_var_from_utf8_1_0(PP_Module module, const char *data, uint32_t len) { return ppb_var_var_from_utf8(data, len); } const char * ppb_var_var_to_utf8(struct PP_Var var, uint32_t *len) { if (PP_VARTYPE_STRING == var.type) { struct var_s *v = get_var_s(var); if (v) { if (len) *len = v->str.len; // assuming all strings are stored with zero terminator return v->str.data; } } trace_warning("%s, 'var' is not a string, (%d)\n", __func__, var.type); if (len) *len = 0; return ""; } PP_Resource ppb_var_var_to_resource(struct PP_Var var) { return 0; } struct PP_Var ppb_var_var_from_resource(PP_Resource resource) { return PP_MakeUndefined(); } bool ppb_var_has_property(struct PP_Var object, struct PP_Var name, struct PP_Var *exception) { if (object.type != PP_VARTYPE_OBJECT) { trace_error("%s, 'object' is not an object\n", __func__); return false; } if (name.type != PP_VARTYPE_STRING) { trace_error("%s, 'name' is not a string\n", __func__); return false; } struct var_s *objv = get_var_s(object); if (objv->obj._class->HasProperty) return objv->obj._class->HasProperty(objv->obj.data, name, exception); else return false; } bool ppb_var_has_method(struct PP_Var object, struct PP_Var name, struct PP_Var *exception) { if (object.type != PP_VARTYPE_OBJECT) { trace_error("%s, 'object' is not an object\n", __func__); return false; } if (name.type != PP_VARTYPE_STRING) { trace_error("%s, 'name' is not a string\n", __func__); return false; } struct var_s *objv = get_var_s(object); if (objv->obj._class->HasMethod) return objv->obj._class->HasMethod(objv->obj.data, name, exception); else return false; } struct PP_Var ppb_var_get_property(struct PP_Var object, struct PP_Var name, struct PP_Var *exception) { if (object.type != PP_VARTYPE_OBJECT) { // TODO: fill exception trace_error("%s, 'object' is not an object\n", __func__); return PP_MakeUndefined(); } if (name.type != PP_VARTYPE_STRING) { trace_error("%s, 'name' is not a string\n", __func__); return PP_MakeUndefined(); } struct var_s *objv = get_var_s(object); if (objv->obj._class->GetProperty) return objv->obj._class->GetProperty(objv->obj.data, name, exception); else return PP_MakeUndefined(); } void ppb_var_get_all_property_names(struct PP_Var object, uint32_t *property_count, struct PP_Var **properties, struct PP_Var *exception) { if (object.type != PP_VARTYPE_OBJECT) { // TODO: fill exception trace_error("%s, 'object' is not an object\n", __func__); return; } struct var_s *objv = get_var_s(object); if (objv->obj._class->GetAllPropertyNames) objv->obj._class->GetAllPropertyNames(objv->obj.data, property_count, properties, exception); } void ppb_var_set_property(struct PP_Var object, struct PP_Var name, struct PP_Var value, struct PP_Var *exception) { if (object.type != PP_VARTYPE_OBJECT) { // TODO: fill exception trace_error("%s, 'object' is not an object\n", __func__); return; } if (name.type != PP_VARTYPE_STRING) { trace_error("%s, 'name' is not a string\n", __func__); return; } struct var_s *objv = get_var_s(object); if (objv->obj._class->SetProperty) objv->obj._class->SetProperty(objv->obj.data, name, value, exception); } void ppb_var_remove_property(struct PP_Var object, struct PP_Var name, struct PP_Var *exception) { if (object.type != PP_VARTYPE_OBJECT) { // TODO: fill exception trace_error("%s, 'object' is not an object\n", __func__); return; } if (name.type != PP_VARTYPE_STRING) { trace_error("%s, 'name' is not a string\n", __func__); return; } struct var_s *objv = get_var_s(object); if (objv->obj._class->RemoveProperty) objv->obj._class->RemoveProperty(objv->obj.data, name, exception); } struct PP_Var ppb_var_call(struct PP_Var object, struct PP_Var method_name, uint32_t argc, struct PP_Var *argv, struct PP_Var *exception) { if (object.type != PP_VARTYPE_OBJECT) { // TODO: fill exception trace_error("%s, 'object' is not an object\n", __func__); return PP_MakeUndefined(); } if (method_name.type != PP_VARTYPE_STRING) { trace_error("%s, 'method_name' is not a string\n", __func__); return PP_MakeUndefined(); } struct var_s *objv = get_var_s(object); if (objv->obj._class->Call) return objv->obj._class->Call(objv->obj.data, method_name, argc, argv, exception); else return PP_MakeUndefined(); } struct PP_Var ppb_var_construct(struct PP_Var object, uint32_t argc, struct PP_Var *argv, struct PP_Var *exception) { if (object.type != PP_VARTYPE_OBJECT) { // TODO: fill exception trace_error("%s, 'object' is not an object\n", __func__); return PP_MakeUndefined(); } struct var_s *objv = get_var_s(object); if (objv->obj._class->Construct) return objv->obj._class->Construct(objv->obj.data, argc, argv, exception); else return PP_MakeUndefined(); } bool ppb_var_is_instance_of(struct PP_Var var, const struct PPP_Class_Deprecated *object_class, void **object_data) { if (var.type != PP_VARTYPE_OBJECT) { trace_error("%s, 'var' is not an object\n", __func__); return false; } struct var_s *objv = get_var_s(var); if (objv->obj._class == object_class) { if (object_data) *object_data = objv->obj.data; return true; } return false; } struct PP_Var ppb_var_create_object(PP_Instance instance, const struct PPP_Class_Deprecated *object_class, void *object_data) { (void)instance; struct PP_Var var = {}; struct var_s *v = g_slice_alloc(sizeof(*v)); var.type = PP_VARTYPE_OBJECT; v->obj._class = object_class; v->obj.data = object_data; v->ref_count = 1; pthread_mutex_lock(&lock); var.value.as_id = get_new_var_id(); v->var = var; g_hash_table_insert(var_ht, GSIZE_TO_POINTER(var.value.as_id), v); pthread_mutex_unlock(&lock); return var; } struct PP_Var ppb_var_create_object_with_module_deprecated(PP_Module module, const struct PPP_Class_Deprecated *object_class, void *object_data) { (void)module; return ppb_var_create_object(0, object_class, object_data); } char * ppb_var_trace_object_var(struct PP_Var var) { if (var.type == PP_VARTYPE_OBJECT) { struct var_s *objv = get_var_s(var); int ref_count = ppb_var_get_ref_count(var); return g_strdup_printf("{OBJECT:%d:class=%p:data=%p}", ref_count, objv->obj._class, objv->obj.data); } else { return ""; } } struct PP_Var ppb_var_array_buffer_create(uint32_t size_in_bytes) { struct var_s *v = g_slice_alloc0(sizeof(*v)); struct PP_Var var = {}; var.type = PP_VARTYPE_ARRAY_BUFFER; v->str.len = size_in_bytes; v->str.data = calloc(size_in_bytes, 1); v->ref_count = 1; pthread_mutex_lock(&lock); var.value.as_id = get_new_var_id(); v->var = var; g_hash_table_insert(var_ht, GSIZE_TO_POINTER(var.value.as_id), v); pthread_mutex_unlock(&lock); return var; } PP_Bool ppb_var_array_buffer_byte_length(struct PP_Var var, uint32_t *byte_length) { if (var.type != PP_VARTYPE_ARRAY_BUFFER || !byte_length) return PP_FALSE; struct var_s *v = get_var_s(var); if (!v) return PP_FALSE; *byte_length = v->str.len; return PP_TRUE; } void * ppb_var_array_buffer_map(struct PP_Var var) { if (var.type != PP_VARTYPE_ARRAY_BUFFER) { trace_error("%s, not an array buffer var\n", __func__); return NULL; } struct var_s *v = get_var_s(var); if (!v) { trace_error("%s, variable gone\n", __func__); return NULL; } if (v->map_addr) return v->map_addr; v->map_addr = malloc(v->str.len); if (!v->map_addr) return NULL; memcpy(v->map_addr, v->str.data, v->str.len); return v->map_addr; } void ppb_var_array_buffer_unmap(struct PP_Var var) { if (var.type != PP_VARTYPE_ARRAY_BUFFER) { trace_error("%s, not an array buffer var\n", __func__); return; } struct var_s *v = get_var_s(var); if (!v) { trace_error("%s, variable gone\n", __func__); return; } // return if not mapped if (!v->map_addr) return; // copy data back to the buffer memcpy(v->str.data, v->map_addr, v->str.len); free(v->map_addr); v->map_addr = NULL; } static void var_dict_key_destroy_func(gpointer data) { // it's just a memory block free(data); } static void var_dict_val_destroy_func(gpointer data) { struct PP_Var *var = data; ppb_var_release(*var); g_slice_free(struct PP_Var, var); } struct PP_Var ppb_var_dictionary_create(void) { struct var_s *v = g_slice_alloc0(sizeof(*v)); struct PP_Var var = {}; var.type = PP_VARTYPE_DICTIONARY; v->ref_count = 1; v->dict = g_hash_table_new_full(g_str_hash, g_str_equal, var_dict_key_destroy_func, var_dict_val_destroy_func); pthread_mutex_lock(&lock); var.value.as_id = get_new_var_id(); v->var = var; g_hash_table_insert(var_ht, GSIZE_TO_POINTER(var.value.as_id), v); pthread_mutex_unlock(&lock); return var; } struct PP_Var ppb_var_dictionary_get(struct PP_Var dict, struct PP_Var key) { if (dict.type != PP_VARTYPE_DICTIONARY || key.type != PP_VARTYPE_STRING) return PP_MakeUndefined(); struct var_s *d = get_var_s(dict); const char *s_key = ppb_var_var_to_utf8(key, NULL); struct PP_Var *val = g_hash_table_lookup(d->dict, s_key); if (!val) return PP_MakeUndefined(); return ppb_var_add_ref2(*val); } PP_Bool ppb_var_dictionary_set(struct PP_Var dict, struct PP_Var key, struct PP_Var value) { if (dict.type != PP_VARTYPE_DICTIONARY || key.type != PP_VARTYPE_STRING) return PP_FALSE; struct var_s *d = get_var_s(dict); char *key_copy = nullsafe_strdup(ppb_var_var_to_utf8(key, NULL)); struct PP_Var *value_copy = g_slice_alloc(sizeof(*value_copy)); memcpy(value_copy, &value, sizeof(struct PP_Var)); g_hash_table_replace(d->dict, key_copy, value_copy); ppb_var_add_ref(value); return PP_TRUE; } void ppb_var_dictionary_delete(struct PP_Var dict, struct PP_Var key) { } PP_Bool ppb_var_dictionary_has_key(struct PP_Var dict, struct PP_Var key) { return PP_FALSE; } struct PP_Var ppb_var_dictionary_get_keys(struct PP_Var dict) { if (dict.type != PP_VARTYPE_DICTIONARY) return PP_MakeUndefined(); struct PP_Var keys = ppb_var_array_create(); struct var_s *d = get_var_s(dict); GHashTableIter iter; gpointer s_key; gpointer value; uint32_t idx = 0; g_hash_table_iter_init(&iter, d->dict); while (g_hash_table_iter_next(&iter, &s_key, &value)) { struct PP_Var key = ppb_var_var_from_utf8_z(s_key); ppb_var_array_set(keys, idx, key); ppb_var_release(key); idx ++; } return keys; } static void var_array_value_clear_func(gpointer data) { struct PP_Var *var = data; ppb_var_release(*var); } struct PP_Var ppb_var_array_create(void) { struct var_s *v = g_slice_alloc0(sizeof(*v)); struct PP_Var var = {}; var.type = PP_VARTYPE_ARRAY; v->ref_count = 1; v->array = g_array_new(FALSE, TRUE, sizeof(struct PP_Var)); g_array_set_clear_func(v->array, var_array_value_clear_func); pthread_mutex_lock(&lock); var.value.as_id = get_new_var_id(); v->var = var; g_hash_table_insert(var_ht, GSIZE_TO_POINTER(var.value.as_id), v); pthread_mutex_unlock(&lock); return var; } struct PP_Var ppb_var_array_get(struct PP_Var array, uint32_t index) { if (array.type != PP_VARTYPE_ARRAY) return PP_MakeUndefined(); struct var_s *v = get_var_s(array); if (index >= v->array->len) return PP_MakeUndefined(); struct PP_Var var = g_array_index(v->array, struct PP_Var, index); return ppb_var_add_ref2(var); } PP_Bool ppb_var_array_set(struct PP_Var array, uint32_t index, struct PP_Var value) { if (array.type != PP_VARTYPE_ARRAY) return PP_FALSE; struct var_s *v = get_var_s(array); if (index >= v->array->len) g_array_set_size(v->array, index + 1); memcpy(&g_array_index(v->array, struct PP_Var, index), &value, sizeof(struct PP_Var)); ppb_var_add_ref(value); return PP_TRUE; } uint32_t ppb_var_array_get_length(struct PP_Var array) { if (array.type != PP_VARTYPE_ARRAY) return 0; struct var_s *v = get_var_s(array); return v->array->len; } PP_Bool ppb_var_array_set_length(struct PP_Var array, uint32_t length) { return PP_FALSE; } // trace wrappers TRACE_WRAPPER void trace_ppb_var_add_ref(struct PP_Var var) { char *var_str = trace_var_as_string(var); trace_info("[PPB] {full} %s var=%s\n", __func__+6, var_str); g_free(var_str); ppb_var_add_ref(var); } TRACE_WRAPPER void trace_ppb_var_release(struct PP_Var var) { char *var_str = trace_var_as_string(var); trace_info("[PPB] {full} %s var=%s\n", __func__+6, var_str); g_free(var_str); ppb_var_release(var); } TRACE_WRAPPER struct PP_Var trace_ppb_var_var_from_utf8(const char *data, uint32_t len) { trace_info("[PPB] {full} %s data=%.*s, len=%d\n", __func__+6, len, data, len); return ppb_var_var_from_utf8(data, len); } TRACE_WRAPPER struct PP_Var trace_ppb_var_var_from_utf8_1_0(PP_Module module, const char *data, uint32_t len) { trace_info("[PPB] {full} %s module=%d, data=%.*s, len=%d\n", __func__+6, module, len, data,len); return ppb_var_var_from_utf8_1_0(module, data, len); } TRACE_WRAPPER const char * trace_ppb_var_var_to_utf8(struct PP_Var var, uint32_t *len) { char *var_str = trace_var_as_string(var); trace_info("[PPB] {full} %s var=%s\n", __func__+6, var_str); g_free(var_str); return ppb_var_var_to_utf8(var, len); } TRACE_WRAPPER PP_Resource trace_ppb_var_var_to_resource(struct PP_Var var) { trace_info("[PPB] {zilch} %s\n", __func__+6); return ppb_var_var_to_resource(var); } TRACE_WRAPPER struct PP_Var trace_ppb_var_var_from_resource(PP_Resource resource) { trace_info("[PPB] {zilch} %s resource=%d\n", __func__+6, resource); return ppb_var_var_from_resource(resource); } TRACE_WRAPPER bool trace_ppb_var_has_property(struct PP_Var object, struct PP_Var name, struct PP_Var *exception) { char *s_object = trace_var_as_string(object); char *s_name = trace_var_as_string(name); trace_info("[PPB] {full} %s object=%s, name=%s\n", __func__+6, s_object, s_name); g_free(s_name); g_free(s_object); return ppb_var_has_property(object, name, exception); } TRACE_WRAPPER bool trace_ppb_var_has_method(struct PP_Var object, struct PP_Var name, struct PP_Var *exception) { char *s_object = trace_var_as_string(object); char *s_name = trace_var_as_string(name); trace_info("[PPB] {full} %s object=%s, name=%s\n", __func__+6, s_object, s_name); g_free(s_name); g_free(s_object); return ppb_var_has_method(object, name, exception); } TRACE_WRAPPER struct PP_Var trace_ppb_var_get_property(struct PP_Var object, struct PP_Var name, struct PP_Var *exception) { char *s_object = trace_var_as_string(object); char *s_name = trace_var_as_string(name); trace_info("[PPB] {full} %s object=%s, name=%s\n", __func__+6, s_object, s_name); g_free(s_name); g_free(s_object); return ppb_var_get_property(object, name, exception); } TRACE_WRAPPER void trace_ppb_var_get_all_property_names(struct PP_Var object, uint32_t *property_count, struct PP_Var **properties, struct PP_Var *exception) { char *s_object = trace_var_as_string(object); trace_info("[PPB] {full} %s object=%s\n", __func__+6, s_object); g_free(s_object); ppb_var_get_all_property_names(object, property_count, properties, exception); } TRACE_WRAPPER void trace_ppb_var_set_property(struct PP_Var object, struct PP_Var name, struct PP_Var value, struct PP_Var *exception) { char *s_object = trace_var_as_string(object); char *s_name = trace_var_as_string(name); char *s_value = trace_var_as_string(value); trace_info("[PPB] {full} %s object=%s, name=%s, value=%s\n", __func__+6, s_object, s_name, s_value); g_free(s_object); g_free(s_name); g_free(s_value); ppb_var_set_property(object, name, value, exception); } TRACE_WRAPPER void trace_ppb_var_remove_property(struct PP_Var object, struct PP_Var name, struct PP_Var *exception) { char *s_object = trace_var_as_string(object); char *s_name = trace_var_as_string(name); trace_info("[PPB] {full} %s object=%s, name=%s\n", __func__+6, s_object, s_name); g_free(s_object); g_free(s_name); ppb_var_remove_property(object, name, exception); } TRACE_WRAPPER struct PP_Var trace_ppb_var_call(struct PP_Var object, struct PP_Var method_name, uint32_t argc, struct PP_Var *argv, struct PP_Var *exception) { char *s_object = trace_var_as_string(object); char *s_method_name = trace_var_as_string(method_name); trace_info("[PPB] {full} %s object=%s, method_name=%s, argc=%u, argv=TODO\n", __func__+6, s_object, s_method_name, argc); g_free(s_object); g_free(s_method_name); return ppb_var_call(object, method_name, argc, argv, exception); } TRACE_WRAPPER struct PP_Var trace_ppb_var_construct(struct PP_Var object, uint32_t argc, struct PP_Var *argv, struct PP_Var *exception) { char *s_object = trace_var_as_string(object); trace_info("[PPB] {full} %s object=%s, argc=%u, argv=TODO\n", __func__+6, s_object, argc); g_free(s_object); return ppb_var_construct(object, argc, argv, exception); } TRACE_WRAPPER bool trace_ppb_var_is_instance_of(struct PP_Var var, const struct PPP_Class_Deprecated *object_class, void **object_data) { char *s_var = trace_var_as_string(var); trace_info("[PPB] {full} %s var=%s, object_class=%p\n", __func__+6, s_var, object_class); g_free(s_var); return ppb_var_is_instance_of(var, object_class, object_data); } TRACE_WRAPPER struct PP_Var trace_ppb_var_create_object(PP_Instance instance, const struct PPP_Class_Deprecated *object_class, void *object_data) { trace_info("[PPB] {full} %s instanse=%d, object_class=%p, object_data=%p\n", __func__+6, instance, object_class, object_data); return ppb_var_create_object(instance, object_class, object_data); } TRACE_WRAPPER struct PP_Var trace_ppb_var_create_object_with_module_deprecated(PP_Module module, const struct PPP_Class_Deprecated *object_class, void *object_data) { trace_info("[PPB] {full} %s module=%d, object_class=%p, object_data=%p\n", __func__+6, module, object_class, object_data); return ppb_var_create_object_with_module_deprecated(module, object_class, object_data); } TRACE_WRAPPER struct PP_Var trace_ppb_var_array_buffer_create(uint32_t size_in_bytes) { trace_info("[PPB] {full} %s size_in_bytes=%u\n", __func__+6, size_in_bytes); return ppb_var_array_buffer_create(size_in_bytes); } TRACE_WRAPPER PP_Bool trace_ppb_var_array_buffer_byte_length(struct PP_Var var, uint32_t *byte_length) { char *s_var = trace_var_as_string(var); trace_info("[PPB] {full} %s var=%s\n", __func__+6, s_var); g_free(s_var); return ppb_var_array_buffer_byte_length(var, byte_length); } TRACE_WRAPPER void * trace_ppb_var_array_buffer_map(struct PP_Var var) { char *s_var = trace_var_as_string(var); trace_info("[PPB] {full} %s var=%s\n", __func__+6, s_var); g_free(s_var); return ppb_var_array_buffer_map(var); } TRACE_WRAPPER void trace_ppb_var_array_buffer_unmap(struct PP_Var var) { char *s_var = trace_var_as_string(var); trace_info("[PPB] {full} %s var=%s\n", __func__+6, s_var); g_free(s_var); return ppb_var_array_buffer_unmap(var); } TRACE_WRAPPER struct PP_Var trace_ppb_var_dictionary_create(void) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_var_dictionary_create(); } TRACE_WRAPPER struct PP_Var trace_ppb_var_dictionary_get(struct PP_Var dict, struct PP_Var key) { gchar *s_dict = trace_var_as_string(dict); gchar *s_key = trace_var_as_string(key); trace_info("[PPB] {full} %s dict=%s, key=%s\n", __func__+6, s_dict, s_key); g_free(s_dict); g_free(s_key); return ppb_var_dictionary_get(dict, key); } TRACE_WRAPPER PP_Bool trace_ppb_var_dictionary_set(struct PP_Var dict, struct PP_Var key, struct PP_Var value) { gchar *s_dict = trace_var_as_string(dict); gchar *s_key = trace_var_as_string(key); gchar *s_value = trace_var_as_string(value); trace_info("[PPB] {full} %s dict=%s, key=%s, value=%s\n", __func__+6, s_dict, s_key, s_value); g_free(s_dict); g_free(s_key); g_free(s_value); return ppb_var_dictionary_set(dict, key, value); } TRACE_WRAPPER void trace_ppb_var_dictionary_delete(struct PP_Var dict, struct PP_Var key) { gchar *s_dict = trace_var_as_string(dict); gchar *s_key = trace_var_as_string(key); trace_info("[PPB] {zilch} %s dict=%s, key=%s\n", __func__+6, s_dict, s_key); g_free(s_dict); g_free(s_key); return ppb_var_dictionary_delete(dict, key); } TRACE_WRAPPER PP_Bool trace_ppb_var_dictionary_has_key(struct PP_Var dict, struct PP_Var key) { gchar *s_dict = trace_var_as_string(dict); gchar *s_key = trace_var_as_string(key); trace_info("[PPB] {zilch} %s dict=%s, key=%s\n", __func__+6, s_dict, s_key); g_free(s_dict); g_free(s_key); return ppb_var_dictionary_has_key(dict, key); } TRACE_WRAPPER struct PP_Var trace_ppb_var_dictionary_get_keys(struct PP_Var dict) { gchar *s_dict = trace_var_as_string(dict); trace_info("[PPB] {full} %s dict=%s\n", __func__+6, s_dict); g_free(s_dict); return ppb_var_dictionary_get_keys(dict); } TRACE_WRAPPER struct PP_Var trace_ppb_var_array_create(void) { trace_info("[PPB] {full} %s\n", __func__+6); return ppb_var_array_create(); } TRACE_WRAPPER struct PP_Var trace_ppb_var_array_get(struct PP_Var array, uint32_t index) { gchar *s_array = trace_var_as_string(array); trace_info("[PPB] {full} %s array=%s, index=%u\n", __func__+6, s_array, index); g_free(s_array); return ppb_var_array_get(array, index); } TRACE_WRAPPER PP_Bool trace_ppb_var_array_set(struct PP_Var array, uint32_t index, struct PP_Var value) { gchar *s_array = trace_var_as_string(array); gchar *s_value = trace_var_as_string(value); trace_info("[PPB] {full} %s array=%s, index=%u, value=%s\n", __func__+6, s_array, index, s_value); g_free(s_array); g_free(s_value); return ppb_var_array_set(array, index, value); } TRACE_WRAPPER uint32_t trace_ppb_var_array_get_length(struct PP_Var array) { gchar *s_array = trace_var_as_string(array); trace_info("[PPB] {full} %s array=%s\n", __func__+6, s_array); g_free(s_array); return ppb_var_array_get_length(array); } TRACE_WRAPPER PP_Bool trace_ppb_var_array_set_length(struct PP_Var array, uint32_t length) { gchar *s_array = trace_var_as_string(array); trace_info("[PPB] {zilch} %s array=%s, length=%u\n", __func__+6, s_array, length); g_free(s_array); return ppb_var_array_set_length(array, length); } const struct PPB_Var_1_2 ppb_var_interface_1_2 = { .AddRef = TWRAPF(ppb_var_add_ref), .Release = TWRAPF(ppb_var_release), .VarFromUtf8 = TWRAPF(ppb_var_var_from_utf8), .VarToUtf8 = TWRAPF(ppb_var_var_to_utf8), .VarToResource = TWRAPZ(ppb_var_var_to_resource), .VarFromResource = TWRAPZ(ppb_var_var_from_resource), }; const struct PPB_Var_1_1 ppb_var_interface_1_1 = { .AddRef = TWRAPF(ppb_var_add_ref), .Release = TWRAPF(ppb_var_release), .VarFromUtf8 = TWRAPF(ppb_var_var_from_utf8), .VarToUtf8 = TWRAPF(ppb_var_var_to_utf8), }; const struct PPB_Var_1_0 ppb_var_interface_1_0 = { .AddRef = TWRAPF(ppb_var_add_ref), .Release = TWRAPF(ppb_var_release), .VarFromUtf8 = TWRAPF(ppb_var_var_from_utf8_1_0), .VarToUtf8 = TWRAPF(ppb_var_var_to_utf8), }; const struct PPB_Var_Deprecated ppb_var_deprecated_interface_0_3 = { .AddRef = TWRAPF(ppb_var_add_ref), .Release = TWRAPF(ppb_var_release), .VarFromUtf8 = TWRAPF(ppb_var_var_from_utf8_1_0), .VarToUtf8 = TWRAPF(ppb_var_var_to_utf8), .HasProperty = TWRAPF(ppb_var_has_property), .HasMethod = TWRAPF(ppb_var_has_method), .GetProperty = TWRAPF(ppb_var_get_property), .GetAllPropertyNames = TWRAPF(ppb_var_get_all_property_names), .SetProperty = TWRAPF(ppb_var_set_property), .RemoveProperty = TWRAPF(ppb_var_remove_property), .Call = TWRAPF(ppb_var_call), .Construct = TWRAPF(ppb_var_construct), .IsInstanceOf = TWRAPF(ppb_var_is_instance_of), .CreateObject = TWRAPF(ppb_var_create_object), .CreateObjectWithModuleDeprecated = TWRAPF(ppb_var_create_object_with_module_deprecated), }; const struct PPB_VarArrayBuffer_1_0 ppb_var_array_buffer_interface_1_0 = { .Create = TWRAPF(ppb_var_array_buffer_create), .ByteLength = TWRAPF(ppb_var_array_buffer_byte_length), .Map = TWRAPF(ppb_var_array_buffer_map), .Unmap = TWRAPF(ppb_var_array_buffer_unmap), }; const struct PPB_VarDictionary_1_0 ppb_var_dictionary_interface_1_0 = { .Create = TWRAPF(ppb_var_dictionary_create), .Get = TWRAPF(ppb_var_dictionary_get), .Set = TWRAPF(ppb_var_dictionary_set), .Delete = TWRAPZ(ppb_var_dictionary_delete), .HasKey = TWRAPZ(ppb_var_dictionary_has_key), .GetKeys = TWRAPF(ppb_var_dictionary_get_keys), }; const struct PPB_VarArray_1_0 ppb_var_array_interface_1_0 = { .Create = TWRAPF(ppb_var_array_create), .Get = TWRAPF(ppb_var_array_get), .Set = TWRAPF(ppb_var_array_set), .GetLength = TWRAPF(ppb_var_array_get_length), .SetLength = TWRAPZ(ppb_var_array_set_length), }; static void __attribute__((constructor)) constructor_ppb_var(void) { var_ht = g_hash_table_new(g_direct_hash, g_direct_equal); pthread_mutex_init(&lock, NULL); register_interface(PPB_VAR_INTERFACE_1_0, &ppb_var_interface_1_0); register_interface(PPB_VAR_INTERFACE_1_1, &ppb_var_interface_1_1); register_interface(PPB_VAR_INTERFACE_1_2, &ppb_var_interface_1_2); register_interface(PPB_VAR_ARRAY_BUFFER_INTERFACE_1_0, &ppb_var_array_buffer_interface_1_0); register_interface(PPB_VAR_ARRAY_INTERFACE_1_0, &ppb_var_array_interface_1_0); register_interface(PPB_VAR_DICTIONARY_INTERFACE_1_0, &ppb_var_dictionary_interface_1_0); register_interface(PPB_VAR_DEPRECATED_INTERFACE_0_3, &ppb_var_deprecated_interface_0_3); } freshplayerplugin-0.3.9/src/ppb_var.h000066400000000000000000000106551321746453100176740ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include #include #include #include #include #include #include void ppb_var_add_ref(struct PP_Var var); struct PP_Var ppb_var_add_ref2(struct PP_Var var); void ppb_var_release(struct PP_Var var); int ppb_var_get_ref_count(struct PP_Var var); struct PP_Var ppb_var_var_from_utf8(const char *data, uint32_t len); struct PP_Var ppb_var_var_from_utf8_z(const char *data); const char * ppb_var_var_to_utf8(struct PP_Var var, uint32_t *len); bool ppb_var_has_property(struct PP_Var object, struct PP_Var name, struct PP_Var *exception); bool ppb_var_has_method(struct PP_Var object, struct PP_Var name, struct PP_Var *exception); struct PP_Var ppb_var_get_property(struct PP_Var object, struct PP_Var name, struct PP_Var *exception); void ppb_var_get_all_property_names(struct PP_Var object, uint32_t *property_count, struct PP_Var **properties, struct PP_Var *exception); void ppb_var_set_property(struct PP_Var object, struct PP_Var name, struct PP_Var value, struct PP_Var *exception); void ppb_var_remove_property(struct PP_Var object, struct PP_Var name, struct PP_Var *exception); struct PP_Var ppb_var_call(struct PP_Var object, struct PP_Var method_name, uint32_t argc, struct PP_Var *argv, struct PP_Var *exception); struct PP_Var ppb_var_construct(struct PP_Var object, uint32_t argc, struct PP_Var *argv, struct PP_Var *exception); bool ppb_var_is_instance_of(struct PP_Var var, const struct PPP_Class_Deprecated *object_class, void **object_data); struct PP_Var ppb_var_create_object(PP_Instance instance, const struct PPP_Class_Deprecated *object_class, void *object_data); struct PP_Var ppb_var_create_object_with_module_deprecated(PP_Module module, const struct PPP_Class_Deprecated *object_class, void *object_data); NPVariant pp_var_to_np_variant(struct PP_Var var); struct PP_Var np_variant_to_pp_var(NPVariant v); char * ppb_var_trace_object_var(struct PP_Var var); struct PP_Var ppb_var_array_buffer_create(uint32_t size_in_bytes); PP_Bool ppb_var_array_buffer_byte_length(struct PP_Var var, uint32_t *byte_length); void * ppb_var_array_buffer_map(struct PP_Var var); void ppb_var_array_buffer_unmap(struct PP_Var var); struct PP_Var ppb_var_dictionary_create(void); struct PP_Var ppb_var_dictionary_get(struct PP_Var dict, struct PP_Var key); PP_Bool ppb_var_dictionary_set(struct PP_Var dict, struct PP_Var key, struct PP_Var value); void ppb_var_dictionary_delete(struct PP_Var dict, struct PP_Var key); PP_Bool ppb_var_dictionary_has_key(struct PP_Var dict, struct PP_Var key); struct PP_Var ppb_var_dictionary_get_keys(struct PP_Var dict); struct PP_Var ppb_var_array_create(void); struct PP_Var ppb_var_array_get(struct PP_Var array, uint32_t index); PP_Bool ppb_var_array_set(struct PP_Var array, uint32_t index, struct PP_Var value); uint32_t ppb_var_array_get_length(struct PP_Var array); PP_Bool ppb_var_array_set_length(struct PP_Var array, uint32_t length); freshplayerplugin-0.3.9/src/ppb_video_capture.c000066400000000000000000000547021321746453100217310ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "config.h" #include "eintr_retry.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_buffer.h" #include "ppb_core.h" #include "ppb_device_ref.h" #include "ppb_instance.h" #include "ppb_message_loop.h" #include "ppb_var.h" #include "ppb_video_capture.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "utils.h" #include #include #include #include #include #include #include #include #include #include #if HAVE_LIBV4L2 #include #endif // HAVE_LIBV4L2 struct pp_video_capture_s { COMMON_STRUCTURE_FIELDS int fd; uint32_t width; uint32_t height; uint32_t fps; size_t buffer_size; uint32_t buffer_count; PP_Resource *buffers; char *buffer_is_free; pthread_t thread; uint32_t thread_started; uint32_t terminate_thread; const struct PPP_VideoCapture_Dev_0_1 *ppp_video_capture_dev; PP_Resource message_loop; }; STATIC_ASSERT(sizeof(struct pp_video_capture_s) <= LARGEST_RESOURCE_SIZE); const char *default_capture_device = "/dev/video0"; #if !HAVE_LIBV4L2 // define simple wrappers, if libv4l2 is not used static ssize_t v4l2_read(int fd, void *buffer, size_t n) { return read(fd, buffer, n); } static int v4l2_open(const char *filename, int oflag) { return open(filename, oflag); } static int v4l2_close(int fd) { return close(fd); } static int v4l2_ioctl(int fd, unsigned long int request, void *data) { return ioctl(fd, request, data); } #endif // !HAVE_LIBV4L2 PP_Resource ppb_video_capture_create(PP_Instance instance) { const struct PPP_VideoCapture_Dev_0_1 *ppp_video_capture_dev; struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } ppp_video_capture_dev = ppp_get_interface(PPP_VIDEO_CAPTURE_DEV_INTERFACE_0_1); if (!ppp_video_capture_dev) { trace_error("%s, no viable %s\n", __func__, PPP_VIDEO_CAPTURE_DEV_INTERFACE_0_1); return 0; } PP_Resource video_capture = pp_resource_allocate(PP_RESOURCE_VIDEO_CAPTURE, pp_i); struct pp_video_capture_s *vc = pp_resource_acquire(video_capture, PP_RESOURCE_VIDEO_CAPTURE); if (!vc) { trace_error("%s, resource allocation failure\n", __func__); return 0; } vc->fd = -1; vc->ppp_video_capture_dev = ppp_video_capture_dev; pp_resource_release(video_capture); return video_capture; } static void ppb_video_capture_destroy(void *p) { struct pp_video_capture_s *vc = p; if (vc->fd != -1) { v4l2_close(vc->fd); vc->fd = -1; } if (vc->buffers) { for (uint32_t k = 0; k < vc->buffer_count; k ++) ppb_core_release_resource(vc->buffers[k]); } free_and_nullify(vc->buffers); free_and_nullify(vc->buffer_is_free); } PP_Bool ppb_video_capture_is_video_capture(PP_Resource video_capture) { return pp_resource_get_type(video_capture) == PP_RESOURCE_VIDEO_CAPTURE; } static int video_device_is_usable(const char *dev, char **shortname) { if (!config.probe_video_capture_devices) { // do not probe device, assume it have default name, // and is capable of video capturing *shortname = g_strdup("Unknown"); return 1; } int fd = v4l2_open(dev, O_RDWR); if (fd < 0) return 0; struct v4l2_capability caps; if (v4l2_ioctl(fd, VIDIOC_QUERYCAP, &caps) != 0) goto err_1; #ifdef V4L2_CAP_DEVICE_CAPS const uint32_t device_caps = (caps.capabilities & V4L2_CAP_DEVICE_CAPS) ? caps.device_caps : caps.capabilities; #else const uint32_t device_caps = caps.capabilities; #endif // V4L2_CAP_DEVICE_CAPS if (!(device_caps & V4L2_CAP_VIDEO_CAPTURE)) goto err_1; if (!(device_caps & V4L2_CAP_READWRITE)) goto err_1; *shortname = g_strdup((char *)caps.card); v4l2_close(fd); return 1; err_1: v4l2_close(fd); return 0; } int32_t ppb_video_capture_enumerate_devices(PP_Resource video_capture, struct PP_ArrayOutput output, struct PP_CompletionCallback callback) { int32_t retval; struct pp_video_capture_s *vc = pp_resource_acquire(video_capture, PP_RESOURCE_VIDEO_CAPTURE); if (!vc) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } GArray *vc_devices = g_array_new(FALSE, TRUE, sizeof(PP_Resource)); struct dirent **namelist; int n = scandir("/dev", &namelist, NULL, NULL); if (n >= 0) { for (int k = 0; k < n; k ++) { if (strncmp(namelist[k]->d_name, "video", sizeof("video") - 1) != 0) continue; char *fullpath = g_strdup_printf("/dev/%s", namelist[k]->d_name); char *shortname = NULL; if (video_device_is_usable(fullpath, &shortname)) { struct PP_Var v_shortname = ppb_var_var_from_utf8_z(shortname); struct PP_Var v_fullpath = ppb_var_var_from_utf8_z(fullpath); PP_Resource device = ppb_device_ref_create(vc->instance->id, v_shortname, v_fullpath, PP_DEVICETYPE_DEV_VIDEOCAPTURE); g_array_append_val(vc_devices, device); free(shortname); ppb_var_release(v_shortname); ppb_var_release(v_fullpath); } g_free(fullpath); } for (int k = 0; k < n; k ++) free(namelist[k]); free(namelist); } PP_Resource *devs = output.GetDataBuffer(output.user_data, vc_devices->len, sizeof(PP_Resource)); if (!devs) { retval = PP_ERROR_FAILED; for (uintptr_t k = 0; k < vc_devices->len; k ++) ppb_core_release_resource(g_array_index(vc_devices, PP_Resource, k)); goto err; } for (uintptr_t k = 0; k < vc_devices->len; k ++) devs[k] = g_array_index(vc_devices, PP_Resource, k); retval = PP_OK_COMPLETIONPENDING; ppb_message_loop_post_work_with_result(ppb_message_loop_get_current(), callback, 0, PP_OK, 0, __func__); err: pp_resource_release(video_capture); g_array_free(vc_devices, TRUE); return retval; } int32_t ppb_video_capture_monitor_device_change(PP_Resource video_capture, PP_MonitorDeviceChangeCallback callback, void *user_data) { return 0; } int32_t ppb_video_capture_open(PP_Resource video_capture, PP_Resource device_ref, const struct PP_VideoCaptureDeviceInfo_Dev *requested_info, uint32_t buffer_count, struct PP_CompletionCallback callback) { int32_t result; struct pp_video_capture_s *vc = pp_resource_acquire(video_capture, PP_RESOURCE_VIDEO_CAPTURE); if (!vc) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } const char *capture_device = default_capture_device; struct PP_Var longname = ppb_device_ref_get_longname(device_ref); if (longname.type == PP_VARTYPE_STRING) capture_device = ppb_var_var_to_utf8(longname, NULL); vc->fd = v4l2_open(capture_device, O_RDWR); ppb_var_release(longname); if (vc->fd < 0) { result = PP_ERROR_NOACCESS; goto point_1; } struct v4l2_capability caps; if (v4l2_ioctl(vc->fd, VIDIOC_QUERYCAP, &caps) != 0) { result = PP_ERROR_FAILED; goto point_2; } #ifdef V4L2_CAP_DEVICE_CAPS const uint32_t device_caps = (caps.capabilities & V4L2_CAP_DEVICE_CAPS) ? caps.device_caps : caps.capabilities; #else const uint32_t device_caps = caps.capabilities; #endif // V4L2_CAP_DEVICE_CAPS if (!(device_caps & V4L2_CAP_VIDEO_CAPTURE)) { trace_error("%s, device can't capture\n", __func__); result = PP_ERROR_FAILED; goto point_2; } if (!(device_caps & V4L2_CAP_READWRITE)) { trace_error("%s, device doesn't support read/write interface\n", __func__); result = PP_ERROR_FAILED; goto point_2; } if (requested_info) { vc->width = requested_info->width; vc->height = requested_info->height; vc->fps = requested_info->frames_per_second; } else { vc->width = 640; vc->height = 480; vc->fps = 15; } struct v4l2_format fmt = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, .fmt.pix.width = vc->width, .fmt.pix.height = vc->height, .fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420, // PPAPI hardcodes format to YUV420 .fmt.pix.field = V4L2_FIELD_INTERLACED, }; if (v4l2_ioctl(vc->fd, VIDIOC_S_FMT, &fmt) != 0) { trace_error("%s, failed to set resolution\n", __func__); result = PP_ERROR_FAILED; goto point_2; } vc->width = fmt.fmt.pix.width; vc->height = fmt.fmt.pix.height; vc->buffer_size = fmt.fmt.pix.sizeimage; // buffer size in bytes vc->buffer_count = MAX(buffer_count, 5); // limit lowest number of buffers, just in case vc->buffers = calloc(sizeof(*vc->buffers), vc->buffer_count); if (!vc->buffers) { trace_error("%s, memory allocation failure (1)\n", __func__); result = PP_ERROR_FAILED; goto point_2; } vc->buffer_is_free = malloc(sizeof(*vc->buffer_is_free) * vc->buffer_count); if (!vc->buffer_is_free) { trace_error("%s, memory allocation failure (2)\n", __func__); result = PP_ERROR_FAILED; goto point_3; } for (unsigned int k = 0; k < vc->buffer_count; k ++) { vc->buffer_is_free[k] = 1; vc->buffers[k] = ppb_buffer_create(vc->instance->id, vc->buffer_size); if (vc->buffers[k] == 0) { result = PP_ERROR_FAILED; goto point_4; } } struct PP_VideoCaptureDeviceInfo_Dev info = { .width = vc->width, .height = vc->height, .frames_per_second = vc->fps, }; vc->ppp_video_capture_dev->OnDeviceInfo(vc->instance->id, video_capture, &info, vc->buffer_count, vc->buffers); result = PP_OK; goto point_1; point_4: for (unsigned int k = 0; k < vc->buffer_count; k ++) ppb_core_release_resource(vc->buffers[k]); free_and_nullify(vc->buffer_is_free); point_3: free_and_nullify(vc->buffers); point_2: v4l2_close(vc->fd); vc->fd = -1; point_1: pp_resource_release(video_capture); ppb_message_loop_post_work_with_result(ppb_message_loop_get_current(), callback, 0, result, 0, __func__); return PP_OK_COMPLETIONPENDING; } struct on_buffer_ready_param_s { PP_Instance instance; PP_Resource video_capture; uint32_t buf_idx; const struct PPP_VideoCapture_Dev_0_1 *ppp_video_capture_dev; }; static void on_buffer_ready_comt(void *user_data, int32_t result) { struct on_buffer_ready_param_s *p = user_data; struct pp_instance_s *pp_i = tables_get_pp_instance(p->instance); if (!pp_i) return; p->ppp_video_capture_dev->OnBufferReady(p->instance, p->video_capture, p->buf_idx); g_slice_free1(sizeof(*p), p); } static void * video_capture_thread(void *param) { struct pp_video_capture_s *vc = param; PP_Resource video_capture = vc->self_id; PP_Instance instance = vc->instance->id; const int fd = vc->fd; const size_t buffer_size = vc->buffer_size; vc = pp_resource_acquire(video_capture, PP_RESOURCE_VIDEO_CAPTURE); if (!vc) goto gone; while (!vc->terminate_thread) { // find free buffer uint32_t buf_idx = (uint32_t)-1; for (uint32_t k = 0; k < vc->buffer_count; k ++) { if (vc->buffer_is_free[k]) { buf_idx = k; vc->buffer_is_free[k] = 0; break; } } if (buf_idx == (uint32_t)-1) { // all buffers are busy, wait for some to free, with resource unlocked pp_resource_release(video_capture); usleep(10); vc = pp_resource_acquire(video_capture, PP_RESOURCE_VIDEO_CAPTURE); if (!vc) goto gone; continue; } PP_Resource buffer = vc->buffers[buf_idx]; pp_resource_release(video_capture); // wait on v4l2_read() with resource unlocked void *ptr = ppb_buffer_map(buffer); RETRY_ON_EINTR(v4l2_read(fd, ptr, buffer_size)); ppb_buffer_unmap(buffer); vc = pp_resource_acquire(video_capture, PP_RESOURCE_VIDEO_CAPTURE); if (!vc) goto gone; struct on_buffer_ready_param_s *p = g_slice_alloc(sizeof(*p)); p->instance = instance; p->video_capture = video_capture; p->buf_idx = buf_idx; p->ppp_video_capture_dev = vc->ppp_video_capture_dev; ppb_message_loop_post_work_with_result(vc->message_loop, PP_MakeCCB(on_buffer_ready_comt, p), 0, PP_OK, 0, __func__); } pp_resource_release(video_capture); return NULL; gone: trace_error("%s, resource gone\n", __func__); return NULL; } int32_t ppb_video_capture_start_capture(PP_Resource video_capture) { struct pp_video_capture_s *vc = pp_resource_acquire(video_capture, PP_RESOURCE_VIDEO_CAPTURE); if (!vc) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } if (vc->thread_started) goto done; if (vc->fd < 0) { trace_error("%s, device is closed\n", __func__); pp_resource_release(video_capture); return PP_ERROR_FAILED; } // memorize current message loop. It'll be used for callbacks vc->message_loop = ppb_message_loop_get_current(); vc->ppp_video_capture_dev->OnStatus(vc->instance->id, video_capture, PP_VIDEO_CAPTURE_STATUS_STARTING); pp_resource_ref(video_capture); // prevents freeing while thread is still running pthread_create(&vc->thread, NULL, video_capture_thread, vc); vc->thread_started = 1; vc->ppp_video_capture_dev->OnStatus(vc->instance->id, video_capture, PP_VIDEO_CAPTURE_STATUS_STARTED); done: pp_resource_release(video_capture); return PP_OK; } int32_t ppb_video_capture_reuse_buffer(PP_Resource video_capture, uint32_t buffer) { struct pp_video_capture_s *vc = pp_resource_acquire(video_capture, PP_RESOURCE_VIDEO_CAPTURE); if (!vc) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } if (buffer < vc->buffer_count) vc->buffer_is_free[buffer] = 1; pp_resource_release(video_capture); return PP_OK; } int32_t ppb_video_capture_stop_capture(PP_Resource video_capture) { struct pp_video_capture_s *vc = pp_resource_acquire(video_capture, PP_RESOURCE_VIDEO_CAPTURE); if (!vc) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } if (!vc->thread_started) goto done; vc->ppp_video_capture_dev->OnStatus(vc->instance->id, video_capture, PP_VIDEO_CAPTURE_STATUS_STOPPING); vc->terminate_thread = 1; pthread_t thread = vc->thread; pp_resource_release(video_capture); pthread_join(thread, NULL); vc = pp_resource_acquire(video_capture, PP_RESOURCE_VIDEO_CAPTURE); if (!vc) { trace_error("%s, resource gone\n", __func__); return PP_ERROR_BADRESOURCE; } vc->thread_started = 0; vc->terminate_thread = 0; vc->ppp_video_capture_dev->OnStatus(vc->instance->id, video_capture, PP_VIDEO_CAPTURE_STATUS_STOPPED); pp_resource_unref(video_capture); // remove reference made in start_capture() done: pp_resource_release(video_capture); return PP_OK; } void ppb_video_capture_close(PP_Resource video_capture) { ppb_video_capture_stop_capture(video_capture); struct pp_video_capture_s *vc = pp_resource_acquire(video_capture, PP_RESOURCE_VIDEO_CAPTURE); if (!vc) { trace_error("%s, bad resource\n", __func__); return; } ppb_video_capture_destroy(vc); pp_resource_release(video_capture); return; } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_video_capture_create(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_video_capture_create(instance); } TRACE_WRAPPER PP_Bool trace_ppb_video_capture_is_video_capture(PP_Resource video_capture) { trace_info("[PPB] {full} %s video_capture=%d\n", __func__+6, video_capture); return ppb_video_capture_is_video_capture(video_capture); } TRACE_WRAPPER int32_t trace_ppb_video_capture_enumerate_devices(PP_Resource video_capture, struct PP_ArrayOutput output, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s video_capture=%d, output={.GetDataBuffer=%p, .user_data=%p}, " "callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, video_capture, output.GetDataBuffer, output.user_data, callback.func, callback.user_data, callback.flags); return ppb_video_capture_enumerate_devices(video_capture, output, callback); } TRACE_WRAPPER int32_t trace_ppb_video_capture_monitor_device_change(PP_Resource video_capture, PP_MonitorDeviceChangeCallback callback, void *user_data) { trace_info("[PPB] {zilch} %s video_capture=%d, callback=%p, user_data=%p\n", __func__+6, video_capture, callback, user_data); return ppb_video_capture_monitor_device_change(video_capture, callback, user_data); } TRACE_WRAPPER int32_t trace_ppb_video_capture_open(PP_Resource video_capture, PP_Resource device_ref, const struct PP_VideoCaptureDeviceInfo_Dev *requested_info, uint32_t buffer_count, struct PP_CompletionCallback callback) { gchar *s_requested_info; if (requested_info) { s_requested_info = g_strdup_printf("{.width=%u, .height=%u, .frames_per_second=%u}", requested_info->width, requested_info->height, requested_info->frames_per_second); } else { s_requested_info = g_strdup("(nil)"); } trace_info("[PPB] {full} %s video_capture=%d, device_ref=%d, request_info=%s, buffer_count=%u," " callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, video_capture, device_ref, s_requested_info, buffer_count, callback.func, callback.user_data, callback.flags); g_free(s_requested_info); return ppb_video_capture_open(video_capture, device_ref, requested_info, buffer_count, callback); } TRACE_WRAPPER int32_t trace_ppb_video_capture_start_capture(PP_Resource video_capture) { trace_info("[PPB] {full} %s video_capture=%d\n", __func__+6, video_capture); return ppb_video_capture_start_capture(video_capture); } TRACE_WRAPPER int32_t trace_ppb_video_capture_reuse_buffer(PP_Resource video_capture, uint32_t buffer) { trace_info("[PPB] {full} %s video_capture=%d, buffer=%u\n", __func__+6, video_capture, buffer); return ppb_video_capture_reuse_buffer(video_capture, buffer); } TRACE_WRAPPER int32_t trace_ppb_video_capture_stop_capture(PP_Resource video_capture) { trace_info("[PPB] {full} %s video_capture=%d\n", __func__+6, video_capture); return ppb_video_capture_stop_capture(video_capture); } TRACE_WRAPPER void trace_ppb_video_capture_close(PP_Resource video_capture) { trace_info("[PPB] {full} %s video_capture=%d\n", __func__+6, video_capture); ppb_video_capture_close(video_capture); } const struct PPB_VideoCapture_Dev_0_3 ppb_video_capture_dev_interface_0_3 = { .Create = TWRAPF(ppb_video_capture_create), .IsVideoCapture = TWRAPF(ppb_video_capture_is_video_capture), .EnumerateDevices = TWRAPF(ppb_video_capture_enumerate_devices), .MonitorDeviceChange = TWRAPZ(ppb_video_capture_monitor_device_change), .Open = TWRAPF(ppb_video_capture_open), .StartCapture = TWRAPF(ppb_video_capture_start_capture), .ReuseBuffer = TWRAPF(ppb_video_capture_reuse_buffer), .StopCapture = TWRAPF(ppb_video_capture_stop_capture), .Close = TWRAPF(ppb_video_capture_close), }; static void __attribute__((constructor)) constructor_ppb_video_capture(void) { register_interface(PPB_VIDEOCAPTURE_DEV_INTERFACE_0_3, &ppb_video_capture_dev_interface_0_3); register_resource(PP_RESOURCE_VIDEO_CAPTURE, ppb_video_capture_destroy); } freshplayerplugin-0.3.9/src/ppb_video_capture.h000066400000000000000000000043131321746453100217270ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include PP_Resource ppb_video_capture_create(PP_Instance instance); PP_Bool ppb_video_capture_is_video_capture(PP_Resource video_capture); int32_t ppb_video_capture_enumerate_devices(PP_Resource video_capture, struct PP_ArrayOutput output, struct PP_CompletionCallback callback); int32_t ppb_video_capture_monitor_device_change(PP_Resource video_capture, PP_MonitorDeviceChangeCallback callback, void *user_data); int32_t ppb_video_capture_open(PP_Resource video_capture, PP_Resource device_ref, const struct PP_VideoCaptureDeviceInfo_Dev *requested_info, uint32_t buffer_count, struct PP_CompletionCallback callback); int32_t ppb_video_capture_start_capture(PP_Resource video_capture); int32_t ppb_video_capture_reuse_buffer(PP_Resource video_capture, uint32_t buffer); int32_t ppb_video_capture_stop_capture(PP_Resource video_capture); void ppb_video_capture_close(PP_Resource video_capture); freshplayerplugin-0.3.9/src/ppb_video_decoder.c000066400000000000000000001153021321746453100216650ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "autogenerated_ffmpeg_compat.h" #include "compat_glx_defines.h" #include "config.h" #include "glx.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_buffer.h" #include "ppb_graphics3d.h" #include "ppb_instance.h" #include "ppb_message_loop.h" #include "ppb_video_decoder.h" #include "reverse_constant.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "utils.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // compatibility definitions #if !HAVE_AVPixelFormat #define AVPixelFormat PixelFormat #define AV_PIX_FMT_NONE PIX_FMT_NONE #define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P #define AV_PIX_FMT_VAAPI_VLD PIX_FMT_VAAPI_VLD #endif // !HAVE_AVPixelFormat #if !HAVE_AV_PIX_FMT_VDPAU #define AV_PIX_FMT_VDPAU (-2) #endif // !HAVE_AV_PIX_FMT_VDPAU #if !HAVE_AVCodecID #define AV_CODEC_ID_H264 CODEC_ID_H264 #endif // !HAVE_AVCodecID enum hwdec_api_e { HWDEC_NONE = 0, HWDEC_VAAPI, HWDEC_VDPAU, }; #if !HAVE_AVVDPAUContext struct AVVDPAUContext { VdpDecoder decoder; VdpDecoderRender *render; char reserved[256]; }; #endif // !HAVE_AVVDPAUContext #define MAX_VA_SURFACES 18 // H.264: 16 references and 2 working #define MAX_VDP_SURFACES 16 // H.264: 16 references // H.264 have maximum 16 reference frames. Plus one current. Plus one frame for delayed // release when PPAPI client first calls .decode() and only then calls // .reuse_picture_buffer() struct pp_video_decoder_s { COMMON_STRUCTURE_FIELDS const struct PPP_VideoDecoder_Dev_0_11 *ppp_video_decoder_dev; PP_Resource orig_graphics3d; PP_Resource graphics3d; int codec_id; AVCodec *avcodec; AVCodecContext *avctx; AVCodecParserContext *avparser; AVFrame *avframe; uint32_t width; uint32_t height; int32_t last_consumed_bitstream_buffer_id; size_t buffer_count; struct { int32_t id; uint32_t width; uint32_t height; uint32_t texture_id; uint32_t used; Pixmap pixmap; GLXPixmap glx_pixmap; VdpPresentationQueueTarget vdp_presentation_queue_target; VdpPresentationQueue vdp_presentation_queue; } *buffers; struct vaapi_context va_context; struct AVVDPAUContext vdpau_context; VASurfaceID surfaces[MAX_VA_SURFACES]; VdpVideoSurface vdp_video_surfaces[MAX_VDP_SURFACES]; int surface_used[MAX_VA_SURFACES]; // TODO: use overall maximum VdpVideoMixer vdp_video_mixer; VdpOutputSurface vdp_output_surface; unsigned int initialized : 1; unsigned int buffers_were_requested : 1; unsigned int failed_state : 1; enum hwdec_api_e hwdec_api; ///< HW decoding API used by this resource }; STATIC_ASSERT(sizeof(struct pp_video_decoder_s) <= LARGEST_RESOURCE_SIZE); #if !HAVE_av_frame_alloc static inline AVFrame * av_frame_alloc(void) { return avcodec_alloc_frame(); } #endif // !HAVE_av_frame_alloc #if !HAVE_av_frame_free static inline void av_frame_free(AVFrame **frame) { av_free(*frame); *frame = NULL; } #endif // !HAVE_av_frame_free #if HAVE_AVCodecContext_get_buffer2 #define AVCTX_HAVE_REFCOUNTED_BUFFERS 1 #else #define AVCTX_HAVE_REFCOUNTED_BUFFERS 0 #endif // HAVE_AVCodecContext_get_buffer2 #if !HAVE_avcodec_free_context static void avcodec_free_context(AVCodecContext **pavctx) { avcodec_close(*pavctx); av_free(*pavctx); *pavctx = NULL; } #endif // !HAVE_avcodec_free_context static void report_vdpau_error(VdpStatus st, const char *what, const char *where) { if (st == VDP_STATUS_OK) return; trace_error("%s, %s failed: %d, %s\n", where, what, (int)st, display.vdp_get_error_string(st)); } static void deinitialize_decoder(struct pp_video_decoder_s *vd) { if (vd->graphics3d) { pp_resource_unref(vd->graphics3d); vd->graphics3d = 0; } if (vd->avparser) { av_parser_close(vd->avparser); vd->avparser = NULL; } if (vd->avctx) { avcodec_close(vd->avctx); avcodec_free_context(&vd->avctx); } if (vd->avframe) av_frame_free(&vd->avframe); switch (vd->hwdec_api) { case HWDEC_VAAPI: if (vd->va_context.context_id) { vaDestroyContext(display.va, vd->va_context.context_id); vd->va_context.context_id = 0; } if (vd->va_context.config_id) { vaDestroyConfig(display.va, vd->va_context.config_id); vd->va_context.config_id = 0; } vaDestroySurfaces(display.va, vd->surfaces, MAX_VA_SURFACES); for (uintptr_t k = 0; k < MAX_VA_SURFACES; k ++) { vd->surfaces[k] = VA_INVALID_SURFACE; vd->surface_used[k] = 0; } break; case HWDEC_VDPAU: if (vd->vdpau_context.decoder != VDP_INVALID_HANDLE) { display.vdp_decoder_destroy(vd->vdpau_context.decoder); vd->vdpau_context.decoder = VDP_INVALID_HANDLE; } if (vd->vdp_video_mixer != VDP_INVALID_HANDLE) { display.vdp_video_mixer_destroy(vd->vdp_video_mixer); vd->vdp_video_mixer = VDP_INVALID_HANDLE; } if (vd->vdp_output_surface != VDP_INVALID_HANDLE) { display.vdp_output_surface_destroy(vd->vdp_output_surface); vd->vdp_output_surface = VDP_INVALID_HANDLE; } for (uintptr_t k = 0; k < MAX_VDP_SURFACES; k ++) { if (vd->vdp_video_surfaces[k] != VDP_INVALID_HANDLE) { display.vdp_video_surface_destroy(vd->vdp_video_surfaces[k]); vd->vdp_video_surfaces[k] = VDP_INVALID_HANDLE; vd->surface_used[k] = 0; } } for (uintptr_t k = 0; k < vd->buffer_count; k ++) { if (vd->buffers[k].vdp_presentation_queue != VDP_INVALID_HANDLE) { display.vdp_presentation_queue_destroy(vd->buffers[k].vdp_presentation_queue); vd->buffers[k].vdp_presentation_queue = VDP_INVALID_HANDLE; } if (vd->buffers[k].vdp_presentation_queue_target != VDP_INVALID_HANDLE) { display.vdp_presentation_queue_target_destroy(vd->buffers[k] .vdp_presentation_queue_target); vd->buffers[k].vdp_presentation_queue_target = VDP_INVALID_HANDLE; } } break; default: // no-op break; } for (uintptr_t k = 0; k < vd->buffer_count; k ++) { vd->ppp_video_decoder_dev->DismissPictureBuffer(vd->instance->id, vd->self_id, vd->buffers[k].id); pthread_mutex_lock(&display.lock); if (vd->buffers[k].glx_pixmap != None) { glXDestroyPixmap(display.x, vd->buffers[k].glx_pixmap); vd->buffers[k].glx_pixmap = None; } if (vd->buffers[k].pixmap != None) { XFreePixmap(display.x, vd->buffers[k].pixmap); vd->buffers[k].pixmap = None; } pthread_mutex_unlock(&display.lock); } vd->buffer_count = 0; vd->buffers_were_requested = 0; vd->initialized = 0; free_and_nullify(vd->buffers); } static void ppb_video_decoder_destroy_priv(void *p) { struct pp_video_decoder_s *vd = p; if (vd->orig_graphics3d) { pp_resource_unref(vd->orig_graphics3d); vd->orig_graphics3d = 0; } deinitialize_decoder(vd); } static enum AVPixelFormat prepare_vaapi_context(struct pp_video_decoder_s *vd, int width, int height) { VAStatus status; vd->va_context.display = display.va; vd->va_context.config_id = VA_INVALID_ID; vd->va_context.context_id = VA_INVALID_ID; // function is called from libavcodec internals which were already protected by mutex status = vaCreateConfig(display.va, VAProfileH264High, VAEntrypointVLD, NULL, 0, &vd->va_context.config_id); if (status != VA_STATUS_SUCCESS) { trace_error("%s, can't create VA config\n", __func__); goto err; } #if VA_CHECK_VERSION(0, 34, 0) status = vaCreateSurfaces(display.va, VA_RT_FORMAT_YUV420, width, height, vd->surfaces, MAX_VA_SURFACES, NULL, 0); #else status = vaCreateSurfaces(display.va, width, height, VA_RT_FORMAT_YUV420, MAX_VA_SURFACES, vd->surfaces); #endif if (status != VA_STATUS_SUCCESS) { trace_error("%s, can't create VA surfaces\n", __func__); goto err; } status = vaCreateContext(display.va, vd->va_context.config_id, width, height, VA_PROGRESSIVE, vd->surfaces, MAX_VA_SURFACES, &vd->va_context.context_id); if (status != VA_STATUS_SUCCESS) { trace_error("%s, can't create VA context\n", __func__); goto err; } vd->avctx->hwaccel_context = &vd->va_context; vd->hwdec_api = HWDEC_VAAPI; return AV_PIX_FMT_VAAPI_VLD; err: vd->failed_state = 1; vd->ppp_video_decoder_dev->NotifyError(vd->instance->id, vd->self_id, PP_VIDEODECODERERROR_UNREADABLE_INPUT); return AV_PIX_FMT_NONE; } static enum AVPixelFormat prepare_vdpau_context(struct pp_video_decoder_s *vd, int width, int height) { VdpStatus st; vd->hwdec_api = HWDEC_VDPAU; vd->vdpau_context.decoder = VDP_INVALID_HANDLE; vd->vdp_video_mixer = VDP_INVALID_HANDLE; vd->vdp_output_surface = VDP_INVALID_HANDLE; for (uintptr_t k = 0; k < MAX_VDP_SURFACES; k ++) vd->vdp_video_surfaces[k] = VDP_INVALID_HANDLE; st = display.vdp_decoder_create(display.vdp_device, VDP_DECODER_PROFILE_H264_HIGH, width, height, MAX_VDP_SURFACES, &vd->vdpau_context.decoder); if (st != VDP_STATUS_OK) { report_vdpau_error(st, "VdpDecoderCreate", __func__); goto err; } for (uintptr_t k = 0; k < MAX_VDP_SURFACES; k ++) { st = display.vdp_video_surface_create(display.vdp_device, VDP_CHROMA_TYPE_420, width, height, &vd->vdp_video_surfaces[k]); if (st != VDP_STATUS_OK) { report_vdpau_error(st, "VdpVideoSurfaceCreate", __func__); goto err; } } const VdpVideoMixerParameter param_names[] = { VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH, VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT, VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE, }; const void * const param_values[] = { &(uint32_t){width}, &(uint32_t){height}, &(VdpChromaType){VDP_CHROMA_TYPE_420}, }; st = display.vdp_video_mixer_create(display.vdp_device, 0, NULL, sizeof(param_names)/sizeof(param_names[0]), param_names, param_values, &vd->vdp_video_mixer); if (st != VDP_STATUS_OK) { report_vdpau_error(st, "VdpVideoMixerCreate", __func__); goto err; } st = display.vdp_output_surface_create(display.vdp_device, VDP_RGBA_FORMAT_B8G8R8A8, width, height, &vd->vdp_output_surface); if (st != VDP_STATUS_OK) { report_vdpau_error(st, "VdpOutputSurfaceCreate", __func__); goto err; } vd->vdpau_context.render = display.vdp_decoder_render; vd->avctx->hwaccel_context = &vd->vdpau_context; return AV_PIX_FMT_VDPAU; err: vd->failed_state = 1; vd->ppp_video_decoder_dev->NotifyError(vd->instance->id, vd->self_id, PP_VIDEODECODERERROR_UNREADABLE_INPUT); return AV_PIX_FMT_NONE; } static enum AVPixelFormat get_format(struct AVCodecContext *s, const enum AVPixelFormat *fmt) { struct pp_video_decoder_s *vd = s->opaque; int have_vaapi = 0; int have_vdpau = 0; for (int k = 0; fmt[k] != AV_PIX_FMT_NONE; k ++) { if (fmt[k] == AV_PIX_FMT_VAAPI_VLD) have_vaapi = display.va_available; if (fmt[k] == AV_PIX_FMT_VDPAU) have_vdpau = display.vdpau_available; } trace_info_f(" VDPAU: %s\n", have_vdpau ? "present" : "not present"); trace_info_f(" VA-API: %s\n", have_vaapi ? "present" : "not present"); if (have_vaapi) { return prepare_vaapi_context(vd, s->width, s->height); } if (have_vdpau) { return prepare_vdpau_context(vd, s->width, s->height); } // nothing found, report error vd->ppp_video_decoder_dev->NotifyError(vd->instance->id, vd->self_id, PP_VIDEODECODERERROR_UNREADABLE_INPUT); return AV_PIX_FMT_NONE; } static void release_buffer2(void *opaque, uint8_t *data) { struct pp_video_decoder_s *vd = opaque; switch (vd->hwdec_api) { case HWDEC_VAAPI: { VASurfaceID surface = GPOINTER_TO_SIZE(data); for (int k = 0; k < MAX_VA_SURFACES; k ++) { if (surface == vd->surfaces[k]) { vd->surface_used[k] = 0; break; } } } break; case HWDEC_VDPAU: { VdpVideoSurface surface = GPOINTER_TO_SIZE(data); for (int k = 0; k < MAX_VDP_SURFACES; k ++) { if (surface == vd->vdp_video_surfaces[k]) { vd->surface_used[k] = 0; break; } } } default: // no-op break; } } static int get_buffer2(struct AVCodecContext *s, AVFrame *pic, int flags) { struct pp_video_decoder_s *vd = s->opaque; #if AVCTX_HAVE_REFCOUNTED_BUFFERS == 0 pic->type = FF_BUFFER_TYPE_USER; pic->pkt_pts = s->pkt->pts; #endif switch (vd->hwdec_api) { case HWDEC_VAAPI: { VASurfaceID surface = VA_INVALID_SURFACE; for (int k = 0; k < MAX_VA_SURFACES; k ++) { if (!vd->surface_used[k]) { surface = vd->surfaces[k]; vd->surface_used[k] = 1; break; } } pic->data[0] = GSIZE_TO_POINTER(surface); pic->data[1] = NULL; pic->data[2] = NULL; pic->data[3] = GSIZE_TO_POINTER(surface); if (surface == VA_INVALID_SURFACE) { trace_error("%s, can't find free VA surface\n", __func__); return -1; } } break; case HWDEC_VDPAU: { VdpVideoSurface surface = VDP_INVALID_HANDLE; for (int k = 0; k < MAX_VDP_SURFACES; k ++) { if (!vd->surface_used[k]) { surface = vd->vdp_video_surfaces[k]; vd->surface_used[k] = 1; break; } } pic->data[0] = GSIZE_TO_POINTER(surface); pic->data[1] = NULL; pic->data[2] = NULL; pic->data[3] = GSIZE_TO_POINTER(surface); if (surface == VDP_INVALID_HANDLE) { trace_error("%s, can't find free VDP surface\n", __func__); return -1; } } break; default: trace_error("%s, not reached\n", __func__); break; } #if AVCTX_HAVE_REFCOUNTED_BUFFERS AVBufferRef *buf = av_buffer_create(pic->data[3], 0, release_buffer2, vd, 0); if (!buf) return -1; pic->buf[0] = buf; pic->reordered_opaque = s->reordered_opaque; #endif return 0; } #if AVCTX_HAVE_REFCOUNTED_BUFFERS == 0 static int get_buffer(struct AVCodecContext *s, AVFrame *pic) { return get_buffer2(s, pic, 0); } static void release_buffer(struct AVCodecContext *avctx, AVFrame *pic) { release_buffer2(avctx->opaque, pic->data[0]); pic->data[0] = NULL; pic->data[1] = NULL; pic->data[2] = NULL; pic->data[3] = NULL; } #endif static int initialize_decoder(struct pp_video_decoder_s *vd) { // create auxiliary GL context int32_t attribs[] = { PP_GRAPHICS3DATTRIB_WIDTH, 32, // dimensions can be arbitrary PP_GRAPHICS3DATTRIB_HEIGHT, 32, PP_GRAPHICS3DATTRIB_RED_SIZE, 8, PP_GRAPHICS3DATTRIB_GREEN_SIZE, 8, PP_GRAPHICS3DATTRIB_BLUE_SIZE, 8, PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8, PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 16, GLX_Y_INVERTED_EXT, True, GLX_BIND_TO_TEXTURE_RGBA_EXT, True, PP_GRAPHICS3DATTRIB_NONE, }; vd->graphics3d = ppb_graphics3d_create(vd->instance->id, vd->orig_graphics3d, attribs); if (!vd->graphics3d) { trace_error("%s, can't create graphics3d context\n", __func__); goto err; } vd->hwdec_api = HWDEC_NONE; vd->avcodec = avcodec_find_decoder(vd->codec_id); if (!vd->avcodec) { trace_error("%s, can't create codec\n", __func__); goto err; } vd->avparser = av_parser_init(vd->codec_id); if (!vd->avparser) { trace_error("%s, can't create parser\n", __func__); goto err; } vd->avctx = avcodec_alloc_context3(vd->avcodec); if (!vd->avctx) { trace_error("%s, can't create codec context\n", __func__); goto err; } if (vd->avcodec->capabilities & CODEC_CAP_TRUNCATED) { trace_info("%s, codec have CODEC_CAP_TRUNCATED\n", __func__); vd->avctx->flags |= CODEC_FLAG_TRUNCATED; } vd->avctx->opaque = vd; vd->avctx->thread_count = 1; vd->avctx->get_format = get_format; #if AVCTX_HAVE_REFCOUNTED_BUFFERS vd->avctx->get_buffer2 = get_buffer2; vd->avctx->refcounted_frames = 1; #else vd->avctx->get_buffer = get_buffer; vd->avctx->release_buffer = release_buffer; #endif if (avcodec_open2(vd->avctx, vd->avcodec, NULL) < 0) { trace_error("%s, can't open codec\n", __func__); goto err; } vd->avframe = av_frame_alloc(); if (!vd->avframe) { trace_error("%s, can't alloc frame\n", __func__); goto err; } vd->initialized = 1; return 0; err: deinitialize_decoder(vd); return -1; } PP_Resource ppb_video_decoder_create(PP_Instance instance, PP_Resource context, PP_VideoDecoder_Profile profile) { if (!config.enable_hwdec) { trace_info_f(" hardware-accelerated decoding was disabled in config file\n"); return 0; } if (!display.va_available && !display.vdpau_available) { trace_info_f(" no hw acceleration available\n"); return 0; } if (!display.glXBindTexImageEXT) { trace_info_f(" no glXBindTexImageEXT available\n"); return 0; } if (!display.glXReleaseTexImageEXT) { trace_info_f(" no glXReleaseTexImageEXT available\n"); return 0; } switch (profile) { case PP_VIDEODECODER_H264PROFILE_BASELINE: case PP_VIDEODECODER_H264PROFILE_MAIN: case PP_VIDEODECODER_H264PROFILE_EXTENDED: case PP_VIDEODECODER_H264PROFILE_HIGH: // pass, there is an implementation below break; case PP_VIDEODECODER_H264PROFILE_NONE: case PP_VIDEODECODER_H264PROFILE_HIGH10PROFILE: case PP_VIDEODECODER_H264PROFILE_HIGH422PROFILE: case PP_VIDEODECODER_H264PROFILE_HIGH444PREDICTIVEPROFILE: case PP_VIDEODECODER_H264PROFILE_SCALABLEBASELINE: case PP_VIDEODECODER_H264PROFILE_SCALABLEHIGH: case PP_VIDEODECODER_H264PROFILE_STEREOHIGH: case PP_VIDEODECODER_H264PROFILE_MULTIVIEWHIGH: case PP_VIDEODECODER_VP8PROFILE_ANY: case PP_VIDEODECODER_PROFILE_UNKNOWN: default: trace_error("%s, profile %d is not supported\n", __func__, profile); return 0; } const struct PPP_VideoDecoder_Dev_0_11 *ppp_video_decoder_dev = NULL; struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } ppp_video_decoder_dev = ppp_get_interface(PPP_VIDEODECODER_DEV_INTERFACE); if (!ppp_video_decoder_dev) { trace_error("%s, no viable %s\n", __func__, PPP_VIDEODECODER_DEV_INTERFACE); return 0; } if (pp_resource_get_type(context) != PP_RESOURCE_GRAPHICS3D) { trace_error("%s, bad resource\n", __func__); return 0; } PP_Resource video_decoder = pp_resource_allocate(PP_RESOURCE_VIDEO_DECODER, pp_i); struct pp_video_decoder_s *vd = pp_resource_acquire(video_decoder, PP_RESOURCE_VIDEO_DECODER); if (!vd) { trace_error("%s, resource allocation failed\n", __func__); return 0; } vd->orig_graphics3d = pp_resource_ref(context); vd->ppp_video_decoder_dev = ppp_video_decoder_dev; vd->codec_id = AV_CODEC_ID_H264; // TODO: other codecs vd->hwdec_api = HWDEC_NONE; pp_resource_release(video_decoder); return video_decoder; } PP_Bool ppb_video_decoder_is_video_decoder(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_VIDEO_DECODER; } static void request_buffers(struct pp_video_decoder_s *vd) { int requested_buffer_count; const PP_Instance instance = vd->instance->id; const struct PP_Size dimensions = { .width = vd->avctx->width, .height = vd->avctx->height }; switch (vd->hwdec_api) { case HWDEC_VAAPI: requested_buffer_count = MAX_VA_SURFACES; break; case HWDEC_VDPAU: requested_buffer_count = MAX_VDP_SURFACES; break; default: requested_buffer_count = 5; break; // just a number, no particular reason } pp_resource_release(vd->self_id); vd->ppp_video_decoder_dev->ProvidePictureBuffers(instance, vd->self_id, requested_buffer_count, &dimensions, GL_TEXTURE_2D); pp_resource_acquire(vd->self_id, PP_RESOURCE_VIDEO_DECODER); } static uint32_t find_free_buffer(struct pp_video_decoder_s *vd) { for (uint32_t idx = 0; idx < vd->buffer_count; idx ++) { if (!vd->buffers[idx].used) { vd->buffers[idx].used = 1; return idx; } } return (uint32_t)-1; } static void issue_frame(struct pp_video_decoder_s *vd) { AVFrame *frame = vd->avframe; uint32_t idx = find_free_buffer(vd); int32_t bitstream_buffer_id = (int32_t)frame->pkt_pts; if (idx == (uint32_t)-1) { trace_warning("%s, no free buffer available\n", __func__); return; } struct pp_graphics3d_s *g3d = pp_resource_acquire(vd->graphics3d, PP_RESOURCE_GRAPHICS3D); if (!g3d) { trace_error("%s, bad resource\n", __func__); return; } pthread_mutex_lock(&display.lock); glXMakeCurrent(display.x, g3d->glx_pixmap, g3d->glc); glBindTexture(GL_TEXTURE_2D, vd->buffers[idx].texture_id); display.glXBindTexImageEXT(display.x, vd->buffers[idx].glx_pixmap, GLX_FRONT_EXT, NULL); XFlush(display.x); switch (vd->hwdec_api) { case HWDEC_VAAPI: { VASurfaceID va_surf = GPOINTER_TO_SIZE(frame->data[3]); vaPutSurface(display.va, va_surf, vd->buffers[idx].pixmap, 0, 0, frame->width, frame->height, 0, 0, frame->width, frame->height, NULL, 0, VA_FRAME_PICTURE); } break; case HWDEC_VDPAU: { VdpStatus st; VdpVideoSurface vdp_surf = GPOINTER_TO_SIZE(frame->data[3]); st = display.vdp_video_mixer_render(vd->vdp_video_mixer, VDP_INVALID_HANDLE, NULL, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME, 0, NULL, vdp_surf, 0, NULL, NULL, vd->vdp_output_surface, NULL, NULL, 0, NULL); report_vdpau_error(st, "VdpVideoMixerRender", __func__); st = display.vdp_presentation_queue_display(vd->buffers[idx].vdp_presentation_queue, vd->vdp_output_surface, vd->buffers[idx].width, vd->buffers[idx].height, 0); report_vdpau_error(st, "VdpPresentationQueueDisplay", __func__); } break; default: trace_error("%s, not reached\n", __func__); break; } XFlush(display.x); glXMakeCurrent(display.x, None, NULL); pthread_mutex_unlock(&display.lock); pp_resource_release(vd->graphics3d); const PP_Instance instance = vd->instance->id; const struct PP_Picture_Dev picture = { .picture_buffer_id = vd->buffers[idx].id, .bitstream_buffer_id = bitstream_buffer_id, }; pp_resource_release(vd->self_id); vd->ppp_video_decoder_dev->PictureReady(instance, vd->self_id, &picture); pp_resource_acquire(vd->self_id, PP_RESOURCE_VIDEO_DECODER); } static void decode_frame(struct pp_video_decoder_s *vd, uint8_t *data, size_t data_len, int32_t bitstream_buffer_id) { AVPacket packet; av_init_packet(&packet); packet.data = data; packet.size = data_len; packet.pts = bitstream_buffer_id; // libavcodec can call hw functions, which in turn can call Xlib functions, // therefore we need to lock pthread_mutex_lock(&display.lock); int got_frame = 0; int len = avcodec_decode_video2(vd->avctx, vd->avframe, &got_frame, &packet); pthread_mutex_unlock(&display.lock); if (len < 0) { trace_error("%s, error %d while decoding frame\n", __func__, len); return; } if (got_frame) { if (!vd->buffers_were_requested) { request_buffers(vd); vd->buffers_were_requested = 1; } issue_frame(vd); } } int32_t ppb_video_decoder_decode(PP_Resource video_decoder, const struct PP_VideoBitstreamBuffer_Dev *bitstream_buffer, struct PP_CompletionCallback callback) { struct pp_video_decoder_s *vd = pp_resource_acquire(video_decoder, PP_RESOURCE_VIDEO_DECODER); if (!vd) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } if (vd->failed_state) { trace_warning("%s, there were errors before, giving up\n", __func__); pp_resource_release(video_decoder); return PP_ERROR_FAILED; } if (!vd->initialized) { int err = initialize_decoder(vd); if (err != 0) { vd->failed_state = 1; vd->ppp_video_decoder_dev->NotifyError(vd->instance->id, vd->self_id, PP_VIDEODECODERERROR_PLATFORM_FAILURE); pp_resource_release(video_decoder); return PP_ERROR_FAILED; } } void *rawdata = ppb_buffer_map(bitstream_buffer->data); if (!rawdata) { trace_error("%s, bad bitstream buffer\n", __func__); pp_resource_release(video_decoder); return PP_ERROR_FAILED; } uint8_t *inbuf = rawdata; size_t inbuf_sz = bitstream_buffer->size; while (inbuf_sz > 0) { uint8_t *outbuf = NULL; int outbuf_sz = 0; int len = av_parser_parse2(vd->avparser, vd->avctx, &outbuf, &outbuf_sz, inbuf, inbuf_sz, 0, 0, AV_NOPTS_VALUE); if (outbuf_sz > 0) decode_frame(vd, outbuf, outbuf_sz, vd->last_consumed_bitstream_buffer_id); inbuf += len; inbuf_sz -= len; } vd->last_consumed_bitstream_buffer_id = bitstream_buffer->id; ppb_buffer_unmap(bitstream_buffer->data); pp_resource_release(video_decoder); ppb_message_loop_post_work_with_result(ppb_message_loop_get_current(), callback, 0, PP_OK, 0, __func__); return PP_OK_COMPLETIONPENDING; } void ppb_video_decoder_assign_picture_buffers(PP_Resource video_decoder, uint32_t no_of_buffers, const struct PP_PictureBuffer_Dev buffers[]) { struct pp_video_decoder_s *vd = pp_resource_acquire(video_decoder, PP_RESOURCE_VIDEO_DECODER); if (!vd) { trace_error("%s, bad resource\n", __func__); goto err_1; } struct pp_graphics3d_s *g3d = pp_resource_acquire(vd->graphics3d, PP_RESOURCE_GRAPHICS3D); if (!g3d) { trace_error("%s, bad graphics3d context\n", __func__); goto err_2; } vd->buffers = malloc(no_of_buffers * sizeof(*vd->buffers)); if (!vd->buffers) { trace_error("%s, memory allocation failure\n", __func__); goto err_3; } vd->buffer_count = no_of_buffers; for (uintptr_t k = 0; k < no_of_buffers; k ++) { vd->buffers[k].id = buffers[k].id; vd->buffers[k].width = buffers[k].size.width; vd->buffers[k].height = buffers[k].size.height; vd->buffers[k].texture_id = buffers[k].texture_id; vd->buffers[k].used = 0; pthread_mutex_lock(&display.lock); vd->buffers[k].pixmap = XCreatePixmap(display.x, DefaultRootWindow(display.x), buffers[k].size.width, buffers[k].size.height, g3d->depth); int tfp_pixmap_attrs[] = { GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, GLX_MIPMAP_TEXTURE_EXT, GL_FALSE, GLX_TEXTURE_FORMAT_EXT, g3d->depth == 32 ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT, GL_NONE }; vd->buffers[k].glx_pixmap = glXCreatePixmap(display.x, g3d->fb_config, vd->buffers[k].pixmap, tfp_pixmap_attrs); pthread_mutex_unlock(&display.lock); if (vd->buffers[k].glx_pixmap == None) { trace_error("%s, failed to create GLX pixmap\n", __func__); goto err_3; // TODO: proper resource cleanup in case of an error } if (vd->hwdec_api == HWDEC_VDPAU) { VdpStatus st; VdpPresentationQueueTarget pq_target; VdpPresentationQueue pq; vd->buffers[k].vdp_presentation_queue_target = VDP_INVALID_HANDLE; vd->buffers[k].vdp_presentation_queue = VDP_INVALID_HANDLE; pthread_mutex_lock(&display.lock); XSync(display.x, False); st = display.vdp_presentation_queue_target_create_x11( display.vdp_device, vd->buffers[k].pixmap, &pq_target); report_vdpau_error(st, "VdpPresentationQueueTargetCreateX11", __func__); st = display.vdp_presentation_queue_create(display.vdp_device, pq_target, &pq); report_vdpau_error(st, "VdpPresentationQueueCreate", __func__); pthread_mutex_unlock(&display.lock); vd->buffers[k].vdp_presentation_queue_target = pq_target; vd->buffers[k].vdp_presentation_queue = pq; } } err_3: pp_resource_release(vd->graphics3d); err_2: pp_resource_release(video_decoder); err_1: ; } void ppb_video_decoder_reuse_picture_buffer(PP_Resource video_decoder, int32_t picture_buffer_id) { struct pp_video_decoder_s *vd = pp_resource_acquire(video_decoder, PP_RESOURCE_VIDEO_DECODER); if (!vd) { trace_error("%s, bad resource\n", __func__); return; } for (uintptr_t k = 0; k < vd->buffer_count; k ++) { if (vd->buffers[k].id == picture_buffer_id && vd->buffers[k].used) { vd->buffers[k].used = 0; struct pp_graphics3d_s *g3d = pp_resource_acquire(vd->graphics3d, PP_RESOURCE_GRAPHICS3D); if (g3d) { pthread_mutex_lock(&display.lock); glXMakeCurrent(display.x, g3d->glx_pixmap, g3d->glc); glBindTexture(GL_TEXTURE_2D, vd->buffers[k].texture_id); display.glXReleaseTexImageEXT(display.x, vd->buffers[k].glx_pixmap, GLX_FRONT_EXT); glXMakeCurrent(display.x, None, NULL); XFlush(display.x); pthread_mutex_unlock(&display.lock); pp_resource_release(vd->graphics3d); } } } pp_resource_release(video_decoder); } int32_t ppb_video_decoder_flush(PP_Resource video_decoder, struct PP_CompletionCallback callback) { struct pp_video_decoder_s *vd = pp_resource_acquire(video_decoder, PP_RESOURCE_VIDEO_DECODER); if (!vd) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } avcodec_flush_buffers(vd->avctx); pp_resource_release(video_decoder); ppb_message_loop_post_work_with_result(ppb_message_loop_get_current(), callback, 0, PP_OK, 0, __func__); return PP_OK_COMPLETIONPENDING; } int32_t ppb_video_decoder_reset(PP_Resource video_decoder, struct PP_CompletionCallback callback) { struct pp_video_decoder_s *vd = pp_resource_acquire(video_decoder, PP_RESOURCE_VIDEO_DECODER); if (!vd) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } deinitialize_decoder(vd); pp_resource_release(video_decoder); ppb_message_loop_post_work_with_result(ppb_message_loop_get_current(), callback, 0, PP_OK, 0, __func__); return PP_OK_COMPLETIONPENDING; } void ppb_video_decoder_destroy(PP_Resource video_decoder) { } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_video_decoder_create(PP_Instance instance, PP_Resource context, PP_VideoDecoder_Profile profile) { trace_info("[PPB] {full} %s instance=%d, context=%d, profile=%s\n", __func__+6, instance, context, reverse_video_decoder_profile(profile)); return ppb_video_decoder_create(instance, context, profile); } TRACE_WRAPPER PP_Bool trace_ppb_video_decoder_is_video_decoder(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_video_decoder_is_video_decoder(resource); } TRACE_WRAPPER int32_t trace_ppb_video_decoder_decode(PP_Resource video_decoder, const struct PP_VideoBitstreamBuffer_Dev *bitstream_buffer, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s video_decoder=%d, bitstream_buffer={.id=%d, .data=%d, .size=%u}, " "callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, video_decoder, bitstream_buffer->id, bitstream_buffer->data, bitstream_buffer->size, callback.func, callback.user_data, callback.flags); return ppb_video_decoder_decode(video_decoder, bitstream_buffer, callback); } TRACE_WRAPPER void trace_ppb_video_decoder_assign_picture_buffers(PP_Resource video_decoder, uint32_t no_of_buffers, const struct PP_PictureBuffer_Dev buffers[]) { trace_info("[PPB] {full} %s video_decoder=%d, no_of_buffers=%u, buffers=%p\n", __func__+6, video_decoder, no_of_buffers, buffers); return ppb_video_decoder_assign_picture_buffers(video_decoder, no_of_buffers, buffers); } TRACE_WRAPPER void trace_ppb_video_decoder_reuse_picture_buffer(PP_Resource video_decoder, int32_t picture_buffer_id) { trace_info("[PPB] {full} %s video_decoder=%d, picture_buffer_id=%d\n", __func__+6, video_decoder, picture_buffer_id); return ppb_video_decoder_reuse_picture_buffer(video_decoder, picture_buffer_id); } TRACE_WRAPPER int32_t trace_ppb_video_decoder_flush(PP_Resource video_decoder, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s video_decoder=%d, callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, video_decoder, callback.func, callback.user_data, callback.flags); return ppb_video_decoder_flush(video_decoder, callback); } TRACE_WRAPPER int32_t trace_ppb_video_decoder_reset(PP_Resource video_decoder, struct PP_CompletionCallback callback) { trace_info("[PPB] {full} %s video_decoder=%d, callback={.func=%p, .user_data=%p, .flags=%u}\n", __func__+6, video_decoder, callback.func, callback.user_data, callback.flags); return ppb_video_decoder_reset(video_decoder, callback); } TRACE_WRAPPER void trace_ppb_video_decoder_destroy(PP_Resource video_decoder) { trace_info("[PPB] {zilch} %s video_decoder=%d\n", __func__+6, video_decoder); return ppb_video_decoder_destroy(video_decoder); } const struct PPB_VideoDecoder_Dev_0_16 ppb_video_decoder_dev_interface_0_16 = { .Create = TWRAPF(ppb_video_decoder_create), .IsVideoDecoder = TWRAPF(ppb_video_decoder_is_video_decoder), .Decode = TWRAPF(ppb_video_decoder_decode), .AssignPictureBuffers = TWRAPF(ppb_video_decoder_assign_picture_buffers), .ReusePictureBuffer = TWRAPF(ppb_video_decoder_reuse_picture_buffer), .Flush = TWRAPF(ppb_video_decoder_flush), .Reset = TWRAPF(ppb_video_decoder_reset), .Destroy = TWRAPZ(ppb_video_decoder_destroy), }; static void __attribute__((constructor)) constructor_ppb_video_decoder(void) { avcodec_register_all(); register_interface(PPB_VIDEODECODER_DEV_INTERFACE_0_16, &ppb_video_decoder_dev_interface_0_16); register_resource(PP_RESOURCE_VIDEO_DECODER, ppb_video_decoder_destroy_priv); } freshplayerplugin-0.3.9/src/ppb_video_decoder.h000066400000000000000000000042241321746453100216720ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include PP_Resource ppb_video_decoder_create(PP_Instance instance, PP_Resource context, PP_VideoDecoder_Profile profile); PP_Bool ppb_video_decoder_is_video_decoder(PP_Resource resource); int32_t ppb_video_decoder_decode(PP_Resource video_decoder, const struct PP_VideoBitstreamBuffer_Dev *bitstream_buffer, struct PP_CompletionCallback callback); void ppb_video_decoder_assign_picture_buffers(PP_Resource video_decoder, uint32_t no_of_buffers, const struct PP_PictureBuffer_Dev buffers[]); void ppb_video_decoder_reuse_picture_buffer(PP_Resource video_decoder, int32_t picture_buffer_id); int32_t ppb_video_decoder_flush(PP_Resource video_decoder, struct PP_CompletionCallback callback); int32_t ppb_video_decoder_reset(PP_Resource video_decoder, struct PP_CompletionCallback callback); void ppb_video_decoder_destroy(PP_Resource video_decoder); freshplayerplugin-0.3.9/src/ppb_view.c000066400000000000000000000156261321746453100200540ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "config.h" #include "pp_interface.h" #include "pp_resource.h" #include "ppb_view.h" #include "static_assert.h" #include "trace_core.h" STATIC_ASSERT(sizeof(struct pp_view_s) <= LARGEST_RESOURCE_SIZE); PP_Bool ppb_view_is_view(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_VIEW; } static void ppb_view_destroy(void *ptr) { } PP_Bool ppb_view_get_rect(PP_Resource resource, struct PP_Rect *rect) { struct pp_view_s *v = pp_resource_acquire(resource, PP_RESOURCE_VIEW); if (!v) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } rect->point.x = v->rect.point.x; rect->point.y = v->rect.point.y; rect->size.width = v->rect.size.width; rect->size.height = v->rect.size.height; pp_resource_release(resource); return PP_TRUE; } PP_Bool ppb_view_is_fullscreen(PP_Resource resource) { // TODO: detect when in fullscreen mode return PP_FALSE; } PP_Bool ppb_view_is_visible(PP_Resource resource) { // TODO: detect when not visible return PP_TRUE; } PP_Bool ppb_view_is_page_visible(PP_Resource resource) { // TODO: detect when not visible return PP_TRUE; } PP_Bool ppb_view_get_clip_rect(PP_Resource resource, struct PP_Rect *clip) { struct pp_view_s *v = pp_resource_acquire(resource, PP_RESOURCE_VIEW); if (!v) { trace_error("%s, bad resource\n", __func__); return PP_FALSE; } clip->point.x = v->rect.point.x; clip->point.y = v->rect.point.y; clip->size.width = v->rect.size.width; clip->size.height = v->rect.size.height; pp_resource_release(resource); return PP_TRUE; } float ppb_view_get_device_scale(PP_Resource resource) { return config.device_scale; } float ppb_view_get_css_scale(PP_Resource resource) { return config.device_scale; } PP_Bool ppb_view_get_scroll_offset(PP_Resource resource, struct PP_Point *offset) { offset->x = 0; offset->y = 0; return PP_TRUE; } // trace wrappers TRACE_WRAPPER PP_Bool trace_ppb_view_is_view(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_view_is_view(resource); } TRACE_WRAPPER PP_Bool trace_ppb_view_get_rect(PP_Resource resource, struct PP_Rect *rect) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_view_get_rect(resource, rect); } TRACE_WRAPPER PP_Bool trace_ppb_view_is_fullscreen(PP_Resource resource) { trace_info("[PPB] {zilch} %s resource=%d\n", __func__+6, resource); return ppb_view_is_fullscreen(resource); } TRACE_WRAPPER PP_Bool trace_ppb_view_is_visible(PP_Resource resource) { trace_info("[PPB] {zilch} %s resource=%d\n", __func__+6, resource); return ppb_view_is_visible(resource); } TRACE_WRAPPER PP_Bool trace_ppb_view_is_page_visible(PP_Resource resource) { trace_info("[PPB] {zilch} %s resource=%d\n", __func__+6, resource); return ppb_view_is_page_visible(resource); } TRACE_WRAPPER PP_Bool trace_ppb_view_get_clip_rect(PP_Resource resource, struct PP_Rect *clip) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_view_get_clip_rect(resource, clip); } TRACE_WRAPPER float trace_ppb_view_get_device_scale(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_view_get_device_scale(resource); } TRACE_WRAPPER float trace_ppb_view_get_css_scale(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_view_get_css_scale(resource); } TRACE_WRAPPER PP_Bool trace_ppb_view_get_scroll_offset(PP_Resource resource, struct PP_Point *offset) { trace_info("[PPB] {zilch} %s resource=%d\n", __func__+6, resource); return ppb_view_get_scroll_offset(resource, offset); } const struct PPB_View_Dev_0_1 ppb_view_dev_interface_0_1 = { .GetDeviceScale = TWRAPF(ppb_view_get_device_scale), .GetCSSScale = TWRAPF(ppb_view_get_css_scale), }; const struct PPB_View_1_0 ppb_view_interface_1_0 = { .IsView = TWRAPF(ppb_view_is_view), .GetRect = TWRAPF(ppb_view_get_rect), .IsFullscreen = TWRAPZ(ppb_view_is_fullscreen), .IsVisible = TWRAPZ(ppb_view_is_visible), .IsPageVisible = TWRAPZ(ppb_view_is_page_visible), .GetClipRect = TWRAPF(ppb_view_get_clip_rect), }; const struct PPB_View_1_1 ppb_view_interface_1_1 = { .IsView = TWRAPF(ppb_view_is_view), .GetRect = TWRAPF(ppb_view_get_rect), .IsFullscreen = TWRAPZ(ppb_view_is_fullscreen), .IsVisible = TWRAPZ(ppb_view_is_visible), .IsPageVisible = TWRAPZ(ppb_view_is_page_visible), .GetClipRect = TWRAPF(ppb_view_get_clip_rect), .GetDeviceScale = TWRAPF(ppb_view_get_device_scale), .GetCSSScale = TWRAPF(ppb_view_get_css_scale), }; const struct PPB_View_1_2 ppb_view_interface_1_2 = { .IsView = TWRAPF(ppb_view_is_view), .GetRect = TWRAPF(ppb_view_get_rect), .IsFullscreen = TWRAPZ(ppb_view_is_fullscreen), .IsVisible = TWRAPZ(ppb_view_is_visible), .IsPageVisible = TWRAPZ(ppb_view_is_page_visible), .GetClipRect = TWRAPF(ppb_view_get_clip_rect), .GetDeviceScale = TWRAPF(ppb_view_get_device_scale), .GetCSSScale = TWRAPF(ppb_view_get_css_scale), .GetScrollOffset = TWRAPZ(ppb_view_get_scroll_offset), }; static void __attribute__((constructor)) constructor_ppb_view(void) { register_interface(PPB_VIEW_DEV_INTERFACE_0_1, &ppb_view_dev_interface_0_1); register_interface(PPB_VIEW_INTERFACE_1_0, &ppb_view_interface_1_0); register_interface(PPB_VIEW_INTERFACE_1_1, &ppb_view_interface_1_1); register_interface(PPB_VIEW_INTERFACE_1_2, &ppb_view_interface_1_2); register_resource(PP_RESOURCE_VIEW, ppb_view_destroy); } freshplayerplugin-0.3.9/src/ppb_view.h000066400000000000000000000035731321746453100200570ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include "pp_resource.h" #include #include struct pp_view_s { COMMON_STRUCTURE_FIELDS struct PP_Rect rect; }; PP_Bool ppb_view_is_view(PP_Resource resource); PP_Bool ppb_view_get_rect(PP_Resource resource, struct PP_Rect *rect); PP_Bool ppb_view_is_fullscreen(PP_Resource resource); PP_Bool ppb_view_is_visible(PP_Resource resource); PP_Bool ppb_view_is_page_visible(PP_Resource resource); PP_Bool ppb_view_get_clip_rect(PP_Resource resource, struct PP_Rect *clip); float ppb_view_get_device_scale(PP_Resource resource); float ppb_view_get_css_scale(PP_Resource resource); PP_Bool ppb_view_get_scroll_offset(PP_Resource resource, struct PP_Point *offset); freshplayerplugin-0.3.9/src/ppb_x509_certificate.c000066400000000000000000000371571321746453100221540ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "pp_interface.h" #include "pp_resource.h" #include "ppb_var.h" #include "ppb_x509_certificate.h" #include "reverse_constant.h" #include "static_assert.h" #include "tables.h" #include "trace_core.h" #include "utils.h" #include #include #include #include #include struct pp_x509_certificate_s { COMMON_STRUCTURE_FIELDS X509 *cert; char *raw_data; uint32_t raw_data_length; }; STATIC_ASSERT(sizeof(struct pp_x509_certificate_s) <= LARGEST_RESOURCE_SIZE); PP_Resource ppb_x509_certificate_create(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource x509 = pp_resource_allocate(PP_RESOURCE_X509_CERTIFICATE, pp_i); return x509; } static void ppb_x509_certificate_destroy(void *ptr) { struct pp_x509_certificate_s *xc = ptr; if (xc->cert) { X509_free(xc->cert); xc->cert = NULL; } free(xc->raw_data); } PP_Bool ppb_x509_certificate_is_x509_certificate(PP_Resource resource) { return pp_resource_get_type(resource) == PP_RESOURCE_X509_CERTIFICATE; } PP_Bool ppb_x509_certificate_initialize(PP_Resource resource, const char *bytes, uint32_t length) { const unsigned char *in = (const unsigned char *)bytes; struct pp_x509_certificate_s *xc = pp_resource_acquire(resource, PP_RESOURCE_X509_CERTIFICATE); if (!xc) { return PP_FALSE; } PP_Bool retval = PP_TRUE; if (d2i_X509(&xc->cert, &in, length) == NULL) { retval = PP_FALSE; goto done; } free_and_nullify(xc->raw_data); xc->raw_data = malloc(length); if (xc->raw_data) { memcpy(xc->raw_data, bytes, length); xc->raw_data_length = length; } done: pp_resource_release(resource); return retval; } static struct PP_Var get_xname_field_value(X509_NAME *xname, int nid) { ASN1_STRING *asn1_str; int loc; loc = X509_NAME_get_index_by_NID(xname, nid, -1); if (loc == -1) return PP_MakeNull(); asn1_str = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(xname, loc)); return ppb_var_var_from_utf8((char *)asn1_str->data, asn1_str->length); } static struct PP_Var get_cert_issuer_field_value(X509 *cert, int nid) { X509_NAME *xname = X509_get_issuer_name(cert); if (!xname) return PP_MakeNull(); return get_xname_field_value(xname, nid); } static struct PP_Var get_cert_subject_field_value(X509 *cert, int nid) { X509_NAME *xname = X509_get_subject_name(cert); if (!xname) return PP_MakeNull(); return get_xname_field_value(xname, nid); } static struct PP_Var convert_tm_to_pp_var(struct tm *t, double subsec, int hofs, int mofs) { return PP_MakeDouble(timegm(t) - hofs * 3600 - mofs * 60 + subsec); } static struct PP_Var convert_asn1_time_to_pp_var(ASN1_TIME *asn1_time) { struct tm t; int len = asn1_time->length; unsigned char *s = asn1_time->data; memset(&t, 0, sizeof(t)); if (asn1_time->type == V_ASN1_GENERALIZEDTIME) { // "YYYYMMDDHH[MM[SS[.fff]]]", "YYYYMMDDHH[MM[SS[.fff]]]Z", // or "YYYYMMDDHH[MM[SS[.fff]]]+-HHMM" double subsec = 0; // YYYY if (len < 4 || !isdigit(s[0]) || !isdigit(s[1]) || !isdigit(s[2]) || !isdigit(s[3])) goto parse_error; t.tm_year = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0'); t.tm_year -= 1900; len -= 4; s += 4; // MM if (len < 2 || !isdigit(s[0]) || !isdigit(s[1])) goto parse_error; t.tm_mon = (s[0] - '0') * 10 + (s[1] - '0') - 1; len -= 2; s += 2; // DD if (len < 2 || !isdigit(s[0]) || !isdigit(s[1])) goto parse_error; t.tm_mday = (s[0] - '0') * 10 + (s[1] - '0'); len -= 2; s += 2; // HH if (len < 2 || !isdigit(s[0]) || !isdigit(s[1])) goto parse_error; t.tm_hour = (s[0] - '0') * 10 + (s[1] - '0'); len -= 2; s += 2; if (len >= 2 && isdigit(s[0])) { // MM if (len < 2 || !isdigit(s[0]) || !isdigit(s[1])) goto parse_error; t.tm_min = (s[0] - '0') * 10 + (s[1] - '0'); len -= 2; s += 2; if (len >= 2 && isdigit(s[0])) { // SS if (len < 2 || !isdigit(s[0]) || !isdigit(s[1])) goto parse_error; t.tm_sec = (s[0] - '0') * 10 + (s[1] - '0'); len -= 2; s += 2; if (len >= 4 && s[0] == '.' && isdigit(s[1]) && isdigit(s[2]) && isdigit(s[3])) { // .fff subsec = (s[1] - '0') * 0.1 + (s[2] - '0') * 0.01 + (s[3] - '0') * 0.001; len -= 4; s += 4; } } } if (len == 0) return convert_tm_to_pp_var(&t, subsec, 0, 0); if (len == 1) { if (s[0] == 'Z') return convert_tm_to_pp_var(&t, subsec, 0, 0); else goto parse_error; } if (len < 1 || (s[0] != '+' && s[0] != '-')) goto parse_error; int tz_sign = (s[0] == '+') ? 1 : -1; len -= 1; s += 1; if (len < 2 || !isdigit(s[0]) || !isdigit(s[1])) goto parse_error; int tz_hours = (s[0] - '0') * 10 + (s[1] - '0'); len -= 2; s += 2; if (len < 2 || !isdigit(s[0]) || !isdigit(s[1])) goto parse_error; int tz_minutes = (s[0] - '0') * 10 + (s[1] - '0'); // keep as reminder: len -= 2; s += 2; return convert_tm_to_pp_var(&t, subsec, tz_sign * tz_hours, tz_minutes); } else if (asn1_time->type == V_ASN1_UTCTIME) { // either "YYMMDDhhmm[ss]Z" or "YYMMDDhhmm[ss](+|-)hhmm" // YY if (len < 2 || !isdigit(s[0]) || !isdigit(s[1])) goto parse_error; t.tm_year = (s[0] - '0') * 10 + (s[1] - '0'); t.tm_year += (t.tm_year < 70) * 100; len -= 2; s += 2; // MM if (len < 2 || !isdigit(s[0]) || !isdigit(s[1])) goto parse_error; t.tm_mon = (s[0] - '0') * 10 + (s[1] - '0') - 1; len -= 2; s += 2; // DD if (len < 2 || !isdigit(s[0]) || !isdigit(s[1])) goto parse_error; t.tm_mday = (s[0] - '0') * 10 + (s[1] - '0'); len -= 2; s += 2; // hh if (len < 2 || !isdigit(s[0]) || !isdigit(s[1])) goto parse_error; t.tm_hour = (s[0] - '0') * 10 + (s[1] - '0'); len -= 2; s += 2; // mm if (len < 2 || !isdigit(s[0]) || !isdigit(s[1])) goto parse_error; t.tm_min = (s[0] - '0') * 10 + (s[1] - '0'); len -= 2; s += 2; if (len >= 2 && isdigit(s[0])) { // ss if (len < 2 || !isdigit(s[0]) || !isdigit(s[1])) goto parse_error; t.tm_sec = (s[0] - '0') * 10 + (s[1] - '0'); len -= 2; s += 2; } if (len == 1 && s[0] == 'Z') return convert_tm_to_pp_var(&t, 0, 0, 0); if (len < 1 || (s[0] != '+' && s[0] != '-')) goto parse_error; int tz_sign = (s[0] == '+') ? 1 : -1; len -= 1; s += 1; if (len < 2 || !isdigit(s[0]) || !isdigit(s[1])) goto parse_error; int tz_hours = (s[0] - '0') * 10 + (s[1] - '0'); len -= 2; s += 2; if (len < 2 || !isdigit(s[0]) || !isdigit(s[1])) goto parse_error; int tz_minutes = (s[0] - '0') * 10 + (s[1] - '0'); // keep as reminder: len -= 2; s += 2; return convert_tm_to_pp_var(&t, 0, tz_sign * tz_hours, tz_minutes); } else { goto parse_error; } parse_error: return PP_MakeNull(); } struct PP_Var ppb_x509_certificate_get_field(PP_Resource resource, PP_X509Certificate_Private_Field field) { struct PP_Var var = PP_MakeNull(); ASN1_INTEGER *asn1_int; ASN1_TIME *asn1_time; struct pp_x509_certificate_s *xc = pp_resource_acquire(resource, PP_RESOURCE_X509_CERTIFICATE); if (!xc) { trace_error("%s, bad resource\n", __func__); return PP_MakeNull(); } switch (field) { case PP_X509CERTIFICATE_PRIVATE_ISSUER_COMMON_NAME: var = get_cert_issuer_field_value(xc->cert, NID_commonName); goto done; case PP_X509CERTIFICATE_PRIVATE_ISSUER_LOCALITY_NAME: var = get_cert_issuer_field_value(xc->cert, NID_localityName); goto done; case PP_X509CERTIFICATE_PRIVATE_ISSUER_STATE_OR_PROVINCE_NAME: var = get_cert_issuer_field_value(xc->cert, NID_stateOrProvinceName); goto done; case PP_X509CERTIFICATE_PRIVATE_ISSUER_COUNTRY_NAME: var = get_cert_issuer_field_value(xc->cert, NID_countryName); goto done; case PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_NAME: var = get_cert_issuer_field_value(xc->cert, NID_organizationName); goto done; case PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_UNIT_NAME: var = get_cert_issuer_field_value(xc->cert, NID_organizationalUnitName); goto done; case PP_X509CERTIFICATE_PRIVATE_ISSUER_UNIQUE_ID: var = PP_MakeNull(); // see ppapi/c/private/ppb_x509_certificate_private.h for details goto done; case PP_X509CERTIFICATE_PRIVATE_SUBJECT_COMMON_NAME: var = get_cert_subject_field_value(xc->cert, NID_commonName); goto done; case PP_X509CERTIFICATE_PRIVATE_SUBJECT_LOCALITY_NAME: var = get_cert_subject_field_value(xc->cert, NID_localityName); goto done; case PP_X509CERTIFICATE_PRIVATE_SUBJECT_STATE_OR_PROVINCE_NAME: var = get_cert_subject_field_value(xc->cert, NID_stateOrProvinceName); goto done; case PP_X509CERTIFICATE_PRIVATE_SUBJECT_COUNTRY_NAME: var = get_cert_subject_field_value(xc->cert, NID_countryName); goto done; case PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_NAME: var = get_cert_subject_field_value(xc->cert, NID_organizationName); goto done; case PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_UNIT_NAME: var = get_cert_subject_field_value(xc->cert, NID_organizationalUnitName); goto done; case PP_X509CERTIFICATE_PRIVATE_SUBJECT_UNIQUE_ID: var = PP_MakeNull(); // see ppapi/c/private/ppb_x509_certificate_private.h for details goto done; case PP_X509CERTIFICATE_PRIVATE_VERSION: var = PP_MakeNull(); // see ppapi/c/private/ppb_x509_certificate_private.h for details goto done; case PP_X509CERTIFICATE_PRIVATE_SERIAL_NUMBER: asn1_int = X509_get_serialNumber(xc->cert); if (!asn1_int) return PP_MakeNull(); var = ppb_var_array_buffer_create(asn1_int->length); memcpy(ppb_var_array_buffer_map(var), asn1_int->data, asn1_int->length); ppb_var_array_buffer_unmap(var); goto done; case PP_X509CERTIFICATE_PRIVATE_SIGNATURE_ALGORITHM_OID: var = PP_MakeNull(); // see ppapi/c/private/ppb_x509_certificate_private.h for details goto done; case PP_X509CERTIFICATE_PRIVATE_SIGNATURE_ALGORITHM_PARAMATERS_RAW: var = PP_MakeNull(); // see ppapi/c/private/ppb_x509_certificate_private.h for details goto done; case PP_X509CERTIFICATE_PRIVATE_VALIDITY_NOT_BEFORE: asn1_time = X509_get_notBefore(xc->cert); if (!asn1_time) return PP_MakeNull(); var = convert_asn1_time_to_pp_var(asn1_time); goto done; case PP_X509CERTIFICATE_PRIVATE_VALIDITY_NOT_AFTER: asn1_time = X509_get_notAfter(xc->cert); if (!asn1_time) return PP_MakeNull(); var = convert_asn1_time_to_pp_var(asn1_time); goto done; case PP_X509CERTIFICATE_PRIVATE_SUBJECT_PUBLIC_KEY_ALGORITHM_OID: trace_error("%s, not implemented path\n", __func__); goto done; case PP_X509CERTIFICATE_PRIVATE_SUBJECT_PUBLIC_KEY: var = PP_MakeNull(); // see ppapi/c/private/ppb_x509_certificate_private.h for details goto done; case PP_X509CERTIFICATE_PRIVATE_RAW: if (xc->raw_data) { var = ppb_var_array_buffer_create(xc->raw_data_length); memcpy(ppb_var_array_buffer_map(var), xc->raw_data, xc->raw_data_length); ppb_var_array_buffer_unmap(var); } goto done; case PP_X509CERTIFICATE_PRIVATE_ISSUER_DISTINGUISHED_NAME: var = get_cert_issuer_field_value(xc->cert, NID_distinguishedName); goto done; case PP_X509CERTIFICATE_PRIVATE_SUBJECT_DISTINGUISHED_NAME: var = get_cert_subject_field_value(xc->cert, NID_distinguishedName); goto done; default: var = PP_MakeNull(); // unknown goto done; } done: pp_resource_release(resource); return var; } // trace wrappers TRACE_WRAPPER PP_Resource trace_ppb_x509_certificate_create(PP_Instance instance) { trace_info("[PPB] {full} %s instance=%d\n", __func__+6, instance); return ppb_x509_certificate_create(instance); } TRACE_WRAPPER PP_Bool trace_ppb_x509_certificate_is_x509_certificate(PP_Resource resource) { trace_info("[PPB] {full} %s resource=%d\n", __func__+6, resource); return ppb_x509_certificate_is_x509_certificate(resource); } TRACE_WRAPPER PP_Bool trace_ppb_x509_certificate_initialize(PP_Resource resource, const char *bytes, uint32_t length) { trace_info("[PPB] {full} %s resource=%d, bytes=%p, length=%u\n", __func__+6, resource, bytes, length); return ppb_x509_certificate_initialize(resource, bytes, length); } TRACE_WRAPPER struct PP_Var trace_ppb_x509_certificate_get_field(PP_Resource resource, PP_X509Certificate_Private_Field field) { trace_info("[PPB] {full} %s resource=%d, field=%s(%u)\n", __func__+6, resource, reverse_x509_certificate_field(field), field); return ppb_x509_certificate_get_field(resource, field); } const struct PPB_X509Certificate_Private_0_1 ppb_x509_certificate_interface_0_1 = { .Create = TWRAPF(ppb_x509_certificate_create), .IsX509CertificatePrivate = TWRAPF(ppb_x509_certificate_is_x509_certificate), .Initialize = TWRAPF(ppb_x509_certificate_initialize), .GetField = TWRAPF(ppb_x509_certificate_get_field), }; static void __attribute__((constructor)) constructor_ppb_x509_certificate(void) { register_interface(PPB_X509CERTIFICATE_PRIVATE_INTERFACE_0_1, &ppb_x509_certificate_interface_0_1); register_resource(PP_RESOURCE_X509_CERTIFICATE, ppb_x509_certificate_destroy); } freshplayerplugin-0.3.9/src/ppb_x509_certificate.h000066400000000000000000000030761321746453100221520ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include PP_Resource ppb_x509_certificate_create(PP_Instance instance); PP_Bool ppb_x509_certificate_is_x509_certificate_private(PP_Resource resource); PP_Bool ppb_x509_certificate_initialize(PP_Resource resource, const char *bytes, uint32_t length); struct PP_Var ppb_x509_certificate_get_field(PP_Resource resource, PP_X509Certificate_Private_Field field); freshplayerplugin-0.3.9/src/reverse_constant.c000066400000000000000000001411321321746453100216150ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "reverse_constant.h" #include #include #define CASE(q) case q: return #q const char * reverse_npp_variable(NPPVariable var) { switch (var) { CASE(NPPVpluginNameString); CASE(NPPVpluginDescriptionString); CASE(NPPVpluginWindowBool); CASE(NPPVpluginTransparentBool); CASE(NPPVjavaClass); CASE(NPPVpluginWindowSize); CASE(NPPVpluginTimerInterval); CASE(NPPVpluginScriptableInstance); CASE(NPPVpluginScriptableIID); CASE(NPPVjavascriptPushCallerBool); CASE(NPPVpluginKeepLibraryInMemory); CASE(NPPVpluginNeedsXEmbed); CASE(NPPVpluginScriptableNPObject); CASE(NPPVformValue); CASE(NPPVpluginUrlRequestsDisplayedBool); CASE(NPPVpluginWantsAllNetworkStreams); CASE(NPPVpluginNativeAccessibleAtkPlugId); CASE(NPPVpluginCancelSrcStream); CASE(NPPVsupportsAdvancedKeyHandling); CASE(NPPVpluginUsesDOMForCursorBool); CASE(NPPVpluginDrawingModel); default: return "UNKNOWNVAR"; } } const char * reverse_npn_variable(NPNVariable var) { switch (var) { CASE(NPNVxDisplay); CASE(NPNVxtAppContext); CASE(NPNVnetscapeWindow); CASE(NPNVjavascriptEnabledBool); CASE(NPNVasdEnabledBool); CASE(NPNVisOfflineBool); CASE(NPNVserviceManager); CASE(NPNVDOMElement); CASE(NPNVDOMWindow); CASE(NPNVToolkit); CASE(NPNVSupportsXEmbedBool); CASE(NPNVWindowNPObject); CASE(NPNVPluginElementNPObject); CASE(NPNVSupportsWindowless); CASE(NPNVprivateModeBool); CASE(NPNVsupportsAdvancedKeyHandling); CASE(NPNVdocumentOrigin); CASE(NPNVpluginDrawingModel); CASE(NPNVmuteAudioBool); default: return "UNKNOWNVAR"; } } const char * reverse_pp_url_response_property(PP_URLResponseProperty prop) { switch (prop) { CASE(PP_URLRESPONSEPROPERTY_URL); CASE(PP_URLRESPONSEPROPERTY_REDIRECTURL); CASE(PP_URLRESPONSEPROPERTY_REDIRECTMETHOD); CASE(PP_URLRESPONSEPROPERTY_STATUSCODE); CASE(PP_URLRESPONSEPROPERTY_STATUSLINE); CASE(PP_URLRESPONSEPROPERTY_HEADERS); default: return "UNKNOWNPROP"; } } const char * reverse_pp_url_request_property(PP_URLRequestProperty prop) { switch (prop) { CASE(PP_URLREQUESTPROPERTY_URL); CASE(PP_URLREQUESTPROPERTY_METHOD); CASE(PP_URLREQUESTPROPERTY_HEADERS); CASE(PP_URLREQUESTPROPERTY_STREAMTOFILE); CASE(PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS); CASE(PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS); CASE(PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS); CASE(PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL); CASE(PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS); CASE(PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS); CASE(PP_URLREQUESTPROPERTY_CUSTOMCONTENTTRANSFERENCODING); CASE(PP_URLREQUESTPROPERTY_PREFETCHBUFFERUPPERTHRESHOLD); CASE(PP_URLREQUESTPROPERTY_PREFETCHBUFFERLOWERTHRESHOLD); CASE(PP_URLREQUESTPROPERTY_CUSTOMUSERAGENT); default: return "UNKNONWPROP"; } } const char * reverse_pp_text_input_type(PP_TextInput_Type_Dev type) { switch (type) { CASE(PP_TEXTINPUT_TYPE_DEV_NONE); CASE(PP_TEXTINPUT_TYPE_DEV_TEXT); CASE(PP_TEXTINPUT_TYPE_DEV_PASSWORD); CASE(PP_TEXTINPUT_TYPE_DEV_SEARCH); CASE(PP_TEXTINPUT_TYPE_DEV_EMAIL); CASE(PP_TEXTINPUT_TYPE_DEV_NUMBER); CASE(PP_TEXTINPUT_TYPE_DEV_TELEPHONE); CASE(PP_TEXTINPUT_TYPE_DEV_URL); default: return "UNKNOWNTYPE"; } } const char * reverse_pp_flash_setting(PP_FlashSetting setting) { switch (setting) { CASE(PP_FLASHSETTING_3DENABLED); CASE(PP_FLASHSETTING_INCOGNITO); CASE(PP_FLASHSETTING_STAGE3DENABLED); CASE(PP_FLASHSETTING_LANGUAGE); CASE(PP_FLASHSETTING_NUMCORES); CASE(PP_FLASHSETTING_LSORESTRICTIONS); CASE(PP_FLASHSETTING_STAGE3DBASELINEENABLED); default: return "UNKNOWNSETTING"; } } const char * reverse_pp_image_data_format(PP_ImageDataFormat fmt) { switch (fmt) { CASE(PP_IMAGEDATAFORMAT_BGRA_PREMUL); CASE(PP_IMAGEDATAFORMAT_RGBA_PREMUL); default: return "UNKNOWNIMAGEDATAFORMAT"; } } const char * reverse_xevent_type(int type) { switch (type) { CASE(KeyPress); CASE(KeyRelease); CASE(ButtonPress); CASE(ButtonRelease); CASE(MotionNotify); CASE(EnterNotify); CASE(LeaveNotify); CASE(FocusIn); CASE(FocusOut); CASE(KeymapNotify); CASE(Expose); CASE(GraphicsExpose); CASE(NoExpose); CASE(VisibilityNotify); CASE(CreateNotify); CASE(DestroyNotify); CASE(UnmapNotify); CASE(MapNotify); CASE(MapRequest); CASE(ReparentNotify); CASE(ConfigureNotify); CASE(ConfigureRequest); CASE(GravityNotify); CASE(ResizeRequest); CASE(CirculateNotify); CASE(CirculateRequest); CASE(PropertyNotify); CASE(SelectionClear); CASE(SelectionRequest); CASE(SelectionNotify); CASE(ColormapNotify); CASE(ClientMessage); CASE(MappingNotify); CASE(GenericEvent); default: return "UNKNOWNXEVENT"; } } const char * reverse_char_set_conversion_error(enum PP_CharSet_ConversionError e) { switch (e) { CASE(PP_CHARSET_CONVERSIONERROR_FAIL); CASE(PP_CHARSET_CONVERSIONERROR_SKIP); CASE(PP_CHARSET_CONVERSIONERROR_SUBSTITUTE); default: return "UNKNOWNCHARSETCONVERSION_ERROR"; } } const char * reverse_gl_enum(unsigned int e) { switch (e) { case 0x0000: return "GL_POINTS"; case 0x0001: return "GL_LINES"; case 0x0002: return "GL_LINE_LOOP"; case 0x0003: return "GL_LINE_STRIP"; case 0x0004: return "GL_TRIANGLES"; case 0x0005: return "GL_TRIANGLE_STRIP"; case 0x0006: return "GL_TRIANGLE_FAN"; case 0x0007: return "GL_QUADS"; case 0x0008: return "GL_QUAD_STRIP"; case 0x0009: return "GL_POLYGON"; case 0x0100: return "GL_ACCUM"; case 0x0101: return "GL_LOAD"; case 0x0102: return "GL_RETURN"; case 0x0103: return "GL_MULT"; case 0x0104: return "GL_ADD"; case 0x0200: return "GL_NEVER"; case 0x0201: return "GL_LESS"; case 0x0202: return "GL_EQUAL"; case 0x0203: return "GL_LEQUAL"; case 0x0204: return "GL_GREATER"; case 0x0205: return "GL_NOTEQUAL"; case 0x0206: return "GL_GEQUAL"; case 0x0207: return "GL_ALWAYS"; case 0x0300: return "GL_SRC_COLOR"; case 0x0301: return "GL_ONE_MINUS_SRC_COLOR"; case 0x0302: return "GL_SRC_ALPHA"; case 0x0303: return "GL_ONE_MINUS_SRC_ALPHA"; case 0x0304: return "GL_DST_ALPHA"; case 0x0305: return "GL_ONE_MINUS_DST_ALPHA"; case 0x0306: return "GL_DST_COLOR"; case 0x0307: return "GL_ONE_MINUS_DST_COLOR"; case 0x0308: return "GL_SRC_ALPHA_SATURATE"; case 0x0400: return "GL_FRONT_LEFT"; case 0x0401: return "GL_FRONT_RIGHT"; case 0x0402: return "GL_BACK_LEFT"; case 0x0403: return "GL_BACK_RIGHT"; case 0x0404: return "GL_FRONT"; case 0x0405: return "GL_BACK"; case 0x0406: return "GL_LEFT"; case 0x0407: return "GL_RIGHT"; case 0x0408: return "GL_FRONT_AND_BACK"; case 0x0409: return "GL_AUX0"; case 0x040A: return "GL_AUX1"; case 0x040B: return "GL_AUX2"; case 0x040C: return "GL_AUX3"; case 0x0500: return "GL_INVALID_ENUM"; case 0x0501: return "GL_INVALID_VALUE"; case 0x0502: return "GL_INVALID_OPERATION"; case 0x0503: return "GL_STACK_OVERFLOW"; case 0x0504: return "GL_STACK_UNDERFLOW"; case 0x0505: return "GL_OUT_OF_MEMORY"; case 0x0600: return "GL_2D"; case 0x0601: return "GL_3D"; case 0x0602: return "GL_3D_COLOR"; case 0x0603: return "GL_3D_COLOR_TEXTURE"; case 0x0604: return "GL_4D_COLOR_TEXTURE"; case 0x0700: return "GL_PASS_THROUGH_TOKEN"; case 0x0701: return "GL_POINT_TOKEN"; case 0x0702: return "GL_LINE_TOKEN"; case 0x0703: return "GL_POLYGON_TOKEN"; case 0x0704: return "GL_BITMAP_TOKEN"; case 0x0705: return "GL_DRAW_PIXEL_TOKEN"; case 0x0706: return "GL_COPY_PIXEL_TOKEN"; case 0x0707: return "GL_LINE_RESET_TOKEN"; case 0x0800: return "GL_EXP"; case 0x0801: return "GL_EXP2"; case 0x0900: return "GL_CW"; case 0x0901: return "GL_CCW"; case 0x0A00: return "GL_COEFF"; case 0x0A01: return "GL_ORDER"; case 0x0A02: return "GL_DOMAIN"; case 0x0B00: return "GL_CURRENT_COLOR"; case 0x0B01: return "GL_CURRENT_INDEX"; case 0x0B02: return "GL_CURRENT_NORMAL"; case 0x0B03: return "GL_CURRENT_TEXTURE_COORDS"; case 0x0B04: return "GL_CURRENT_RASTER_COLOR"; case 0x0B05: return "GL_CURRENT_RASTER_INDEX"; case 0x0B06: return "GL_CURRENT_RASTER_TEXTURE_COORDS"; case 0x0B07: return "GL_CURRENT_RASTER_POSITION"; case 0x0B08: return "GL_CURRENT_RASTER_POSITION_VALID"; case 0x0B09: return "GL_CURRENT_RASTER_DISTANCE"; case 0x0B10: return "GL_POINT_SMOOTH"; case 0x0B11: return "GL_POINT_SIZE"; case 0x0B12: return "GL_POINT_SIZE_RANGE"; case 0x0B13: return "GL_POINT_SIZE_GRANULARITY"; case 0x0B20: return "GL_LINE_SMOOTH"; case 0x0B21: return "GL_LINE_WIDTH"; case 0x0B22: return "GL_LINE_WIDTH_RANGE"; case 0x0B23: return "GL_LINE_WIDTH_GRANULARITY"; case 0x0B24: return "GL_LINE_STIPPLE"; case 0x0B25: return "GL_LINE_STIPPLE_PATTERN"; case 0x0B26: return "GL_LINE_STIPPLE_REPEAT"; case 0x0B30: return "GL_LIST_MODE"; case 0x0B31: return "GL_MAX_LIST_NESTING"; case 0x0B32: return "GL_LIST_BASE"; case 0x0B33: return "GL_LIST_INDEX"; case 0x0B40: return "GL_POLYGON_MODE"; case 0x0B41: return "GL_POLYGON_SMOOTH"; case 0x0B42: return "GL_POLYGON_STIPPLE"; case 0x0B43: return "GL_EDGE_FLAG"; case 0x0B44: return "GL_CULL_FACE"; case 0x0B45: return "GL_CULL_FACE_MODE"; case 0x0B46: return "GL_FRONT_FACE"; case 0x0B50: return "GL_LIGHTING"; case 0x0B51: return "GL_LIGHT_MODEL_LOCAL_VIEWER"; case 0x0B52: return "GL_LIGHT_MODEL_TWO_SIDE"; case 0x0B53: return "GL_LIGHT_MODEL_AMBIENT"; case 0x0B54: return "GL_SHADE_MODEL"; case 0x0B55: return "GL_COLOR_MATERIAL_FACE"; case 0x0B56: return "GL_COLOR_MATERIAL_PARAMETER"; case 0x0B57: return "GL_COLOR_MATERIAL"; case 0x0B60: return "GL_FOG"; case 0x0B61: return "GL_FOG_INDEX"; case 0x0B62: return "GL_FOG_DENSITY"; case 0x0B63: return "GL_FOG_START"; case 0x0B64: return "GL_FOG_END"; case 0x0B65: return "GL_FOG_MODE"; case 0x0B66: return "GL_FOG_COLOR"; case 0x0B70: return "GL_DEPTH_RANGE"; case 0x0B71: return "GL_DEPTH_TEST"; case 0x0B72: return "GL_DEPTH_WRITEMASK"; case 0x0B73: return "GL_DEPTH_CLEAR_VALUE"; case 0x0B74: return "GL_DEPTH_FUNC"; case 0x0B80: return "GL_ACCUM_CLEAR_VALUE"; case 0x0B90: return "GL_STENCIL_TEST"; case 0x0B91: return "GL_STENCIL_CLEAR_VALUE"; case 0x0B92: return "GL_STENCIL_FUNC"; case 0x0B93: return "GL_STENCIL_VALUE_MASK"; case 0x0B94: return "GL_STENCIL_FAIL"; case 0x0B95: return "GL_STENCIL_PASS_DEPTH_FAIL"; case 0x0B96: return "GL_STENCIL_PASS_DEPTH_PASS"; case 0x0B97: return "GL_STENCIL_REF"; case 0x0B98: return "GL_STENCIL_WRITEMASK"; case 0x0BA0: return "GL_MATRIX_MODE"; case 0x0BA1: return "GL_NORMALIZE"; case 0x0BA2: return "GL_VIEWPORT"; case 0x0BA3: return "GL_MODELVIEW_STACK_DEPTH"; case 0x0BA4: return "GL_PROJECTION_STACK_DEPTH"; case 0x0BA5: return "GL_TEXTURE_STACK_DEPTH"; case 0x0BA6: return "GL_MODELVIEW_MATRIX"; case 0x0BA7: return "GL_PROJECTION_MATRIX"; case 0x0BA8: return "GL_TEXTURE_MATRIX"; case 0x0BB0: return "GL_ATTRIB_STACK_DEPTH"; case 0x0BB1: return "GL_CLIENT_ATTRIB_STACK_DEPTH"; case 0x0BC0: return "GL_ALPHA_TEST"; case 0x0BC1: return "GL_ALPHA_TEST_FUNC"; case 0x0BC2: return "GL_ALPHA_TEST_REF"; case 0x0BD0: return "GL_DITHER"; case 0x0BE0: return "GL_BLEND_DST"; case 0x0BE1: return "GL_BLEND_SRC"; case 0x0BE2: return "GL_BLEND"; case 0x0BF0: return "GL_LOGIC_OP_MODE"; case 0x0BF1: return "GL_LOGIC_OP"; case 0x0BF2: return "GL_COLOR_LOGIC_OP"; case 0x0C00: return "GL_AUX_BUFFERS"; case 0x0C01: return "GL_DRAW_BUFFER"; case 0x0C02: return "GL_READ_BUFFER"; case 0x0C10: return "GL_SCISSOR_BOX"; case 0x0C11: return "GL_SCISSOR_TEST"; case 0x0C20: return "GL_INDEX_CLEAR_VALUE"; case 0x0C21: return "GL_INDEX_WRITEMASK"; case 0x0C22: return "GL_COLOR_CLEAR_VALUE"; case 0x0C23: return "GL_COLOR_WRITEMASK"; case 0x0C30: return "GL_INDEX_MODE"; case 0x0C31: return "GL_RGBA_MODE"; case 0x0C32: return "GL_DOUBLEBUFFER"; case 0x0C33: return "GL_STEREO"; case 0x0C40: return "GL_RENDER_MODE"; case 0x0C50: return "GL_PERSPECTIVE_CORRECTION_HINT"; case 0x0C51: return "GL_POINT_SMOOTH_HINT"; case 0x0C52: return "GL_LINE_SMOOTH_HINT"; case 0x0C53: return "GL_POLYGON_SMOOTH_HINT"; case 0x0C54: return "GL_FOG_HINT"; case 0x0C60: return "GL_TEXTURE_GEN_S"; case 0x0C61: return "GL_TEXTURE_GEN_T"; case 0x0C62: return "GL_TEXTURE_GEN_R"; case 0x0C63: return "GL_TEXTURE_GEN_Q"; case 0x0C70: return "GL_PIXEL_MAP_I_TO_I"; case 0x0C71: return "GL_PIXEL_MAP_S_TO_S"; case 0x0C72: return "GL_PIXEL_MAP_I_TO_R"; case 0x0C73: return "GL_PIXEL_MAP_I_TO_G"; case 0x0C74: return "GL_PIXEL_MAP_I_TO_B"; case 0x0C75: return "GL_PIXEL_MAP_I_TO_A"; case 0x0C76: return "GL_PIXEL_MAP_R_TO_R"; case 0x0C77: return "GL_PIXEL_MAP_G_TO_G"; case 0x0C78: return "GL_PIXEL_MAP_B_TO_B"; case 0x0C79: return "GL_PIXEL_MAP_A_TO_A"; case 0x0CB0: return "GL_PIXEL_MAP_I_TO_I_SIZE"; case 0x0CB1: return "GL_PIXEL_MAP_S_TO_S_SIZE"; case 0x0CB2: return "GL_PIXEL_MAP_I_TO_R_SIZE"; case 0x0CB3: return "GL_PIXEL_MAP_I_TO_G_SIZE"; case 0x0CB4: return "GL_PIXEL_MAP_I_TO_B_SIZE"; case 0x0CB5: return "GL_PIXEL_MAP_I_TO_A_SIZE"; case 0x0CB6: return "GL_PIXEL_MAP_R_TO_R_SIZE"; case 0x0CB7: return "GL_PIXEL_MAP_G_TO_G_SIZE"; case 0x0CB8: return "GL_PIXEL_MAP_B_TO_B_SIZE"; case 0x0CB9: return "GL_PIXEL_MAP_A_TO_A_SIZE"; case 0x0CF0: return "GL_UNPACK_SWAP_BYTES"; case 0x0CF1: return "GL_UNPACK_LSB_FIRST"; case 0x0CF2: return "GL_UNPACK_ROW_LENGTH"; case 0x0CF3: return "GL_UNPACK_SKIP_ROWS"; case 0x0CF4: return "GL_UNPACK_SKIP_PIXELS"; case 0x0CF5: return "GL_UNPACK_ALIGNMENT"; case 0x0D00: return "GL_PACK_SWAP_BYTES"; case 0x0D01: return "GL_PACK_LSB_FIRST"; case 0x0D02: return "GL_PACK_ROW_LENGTH"; case 0x0D03: return "GL_PACK_SKIP_ROWS"; case 0x0D04: return "GL_PACK_SKIP_PIXELS"; case 0x0D05: return "GL_PACK_ALIGNMENT"; case 0x0D10: return "GL_MAP_COLOR"; case 0x0D11: return "GL_MAP_STENCIL"; case 0x0D12: return "GL_INDEX_SHIFT"; case 0x0D13: return "GL_INDEX_OFFSET"; case 0x0D14: return "GL_RED_SCALE"; case 0x0D15: return "GL_RED_BIAS"; case 0x0D16: return "GL_ZOOM_X"; case 0x0D17: return "GL_ZOOM_Y"; case 0x0D18: return "GL_GREEN_SCALE"; case 0x0D19: return "GL_GREEN_BIAS"; case 0x0D1A: return "GL_BLUE_SCALE"; case 0x0D1B: return "GL_BLUE_BIAS"; case 0x0D1C: return "GL_ALPHA_SCALE"; case 0x0D1D: return "GL_ALPHA_BIAS"; case 0x0D1E: return "GL_DEPTH_SCALE"; case 0x0D1F: return "GL_DEPTH_BIAS"; case 0x0D30: return "GL_MAX_EVAL_ORDER"; case 0x0D31: return "GL_MAX_LIGHTS"; case 0x0D32: return "GL_MAX_CLIP_PLANES"; case 0x0D33: return "GL_MAX_TEXTURE_SIZE"; case 0x0D34: return "GL_MAX_PIXEL_MAP_TABLE"; case 0x0D35: return "GL_MAX_ATTRIB_STACK_DEPTH"; case 0x0D36: return "GL_MAX_MODELVIEW_STACK_DEPTH"; case 0x0D37: return "GL_MAX_NAME_STACK_DEPTH"; case 0x0D38: return "GL_MAX_PROJECTION_STACK_DEPTH"; case 0x0D39: return "GL_MAX_TEXTURE_STACK_DEPTH"; case 0x0D3A: return "GL_MAX_VIEWPORT_DIMS"; case 0x0D3B: return "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH"; case 0x0D50: return "GL_SUBPIXEL_BITS"; case 0x0D51: return "GL_INDEX_BITS"; case 0x0D52: return "GL_RED_BITS"; case 0x0D53: return "GL_GREEN_BITS"; case 0x0D54: return "GL_BLUE_BITS"; case 0x0D55: return "GL_ALPHA_BITS"; case 0x0D56: return "GL_DEPTH_BITS"; case 0x0D57: return "GL_STENCIL_BITS"; case 0x0D58: return "GL_ACCUM_RED_BITS"; case 0x0D59: return "GL_ACCUM_GREEN_BITS"; case 0x0D5A: return "GL_ACCUM_BLUE_BITS"; case 0x0D5B: return "GL_ACCUM_ALPHA_BITS"; case 0x0D70: return "GL_NAME_STACK_DEPTH"; case 0x0D80: return "GL_AUTO_NORMAL"; case 0x0D90: return "GL_MAP1_COLOR_4"; case 0x0D91: return "GL_MAP1_INDEX"; case 0x0D92: return "GL_MAP1_NORMAL"; case 0x0D93: return "GL_MAP1_TEXTURE_COORD_1"; case 0x0D94: return "GL_MAP1_TEXTURE_COORD_2"; case 0x0D95: return "GL_MAP1_TEXTURE_COORD_3"; case 0x0D96: return "GL_MAP1_TEXTURE_COORD_4"; case 0x0D97: return "GL_MAP1_VERTEX_3"; case 0x0D98: return "GL_MAP1_VERTEX_4"; case 0x0DB0: return "GL_MAP2_COLOR_4"; case 0x0DB1: return "GL_MAP2_INDEX"; case 0x0DB2: return "GL_MAP2_NORMAL"; case 0x0DB3: return "GL_MAP2_TEXTURE_COORD_1"; case 0x0DB4: return "GL_MAP2_TEXTURE_COORD_2"; case 0x0DB5: return "GL_MAP2_TEXTURE_COORD_3"; case 0x0DB6: return "GL_MAP2_TEXTURE_COORD_4"; case 0x0DB7: return "GL_MAP2_VERTEX_3"; case 0x0DB8: return "GL_MAP2_VERTEX_4"; case 0x0DD0: return "GL_MAP1_GRID_DOMAIN"; case 0x0DD1: return "GL_MAP1_GRID_SEGMENTS"; case 0x0DD2: return "GL_MAP2_GRID_DOMAIN"; case 0x0DD3: return "GL_MAP2_GRID_SEGMENTS"; case 0x0DE0: return "GL_TEXTURE_1D"; case 0x0DE1: return "GL_TEXTURE_2D"; case 0x0DF0: return "GL_FEEDBACK_BUFFER_POINTER"; case 0x0DF1: return "GL_FEEDBACK_BUFFER_SIZE"; case 0x0DF2: return "GL_FEEDBACK_BUFFER_TYPE"; case 0x0DF3: return "GL_SELECTION_BUFFER_POINTER"; case 0x0DF4: return "GL_SELECTION_BUFFER_SIZE"; case 0x1000: return "GL_TEXTURE_WIDTH"; case 0x1001: return "GL_TEXTURE_HEIGHT"; case 0x1003: return "GL_TEXTURE_COMPONENTS"; case 0x1004: return "GL_TEXTURE_BORDER_COLOR"; case 0x1005: return "GL_TEXTURE_BORDER"; case 0x1100: return "GL_DONT_CARE"; case 0x1101: return "GL_FASTEST"; case 0x1102: return "GL_NICEST"; case 0x1200: return "GL_AMBIENT"; case 0x1201: return "GL_DIFFUSE"; case 0x1202: return "GL_SPECULAR"; case 0x1203: return "GL_POSITION"; case 0x1204: return "GL_SPOT_DIRECTION"; case 0x1205: return "GL_SPOT_EXPONENT"; case 0x1206: return "GL_SPOT_CUTOFF"; case 0x1207: return "GL_CONSTANT_ATTENUATION"; case 0x1208: return "GL_LINEAR_ATTENUATION"; case 0x1209: return "GL_QUADRATIC_ATTENUATION"; case 0x1300: return "GL_COMPILE"; case 0x1301: return "GL_COMPILE_AND_EXECUTE"; case 0x1400: return "GL_BYTE"; case 0x1401: return "GL_UNSIGNED_BYTE"; case 0x1402: return "GL_SHORT"; case 0x1403: return "GL_UNSIGNED_SHORT"; case 0x1404: return "GL_INT"; case 0x1405: return "GL_UNSIGNED_INT"; case 0x1406: return "GL_FLOAT"; case 0x1407: return "GL_2_BYTES"; case 0x1408: return "GL_3_BYTES"; case 0x1409: return "GL_4_BYTES"; case 0x140A: return "GL_DOUBLE"; case 0x1500: return "GL_CLEAR"; case 0x1501: return "GL_AND"; case 0x1502: return "GL_AND_REVERSE"; case 0x1503: return "GL_COPY"; case 0x1504: return "GL_AND_INVERTED"; case 0x1505: return "GL_NOOP"; case 0x1506: return "GL_XOR"; case 0x1507: return "GL_OR"; case 0x1508: return "GL_NOR"; case 0x1509: return "GL_EQUIV"; case 0x150A: return "GL_INVERT"; case 0x150B: return "GL_OR_REVERSE"; case 0x150C: return "GL_COPY_INVERTED"; case 0x150D: return "GL_OR_INVERTED"; case 0x150E: return "GL_NAND"; case 0x150F: return "GL_SET"; case 0x1600: return "GL_EMISSION"; case 0x1601: return "GL_SHININESS"; case 0x1602: return "GL_AMBIENT_AND_DIFFUSE"; case 0x1603: return "GL_COLOR_INDEXES"; case 0x1700: return "GL_MODELVIEW"; case 0x1701: return "GL_PROJECTION"; case 0x1702: return "GL_TEXTURE"; case 0x1800: return "GL_COLOR"; case 0x1801: return "GL_DEPTH"; case 0x1802: return "GL_STENCIL"; case 0x1900: return "GL_COLOR_INDEX"; case 0x1901: return "GL_STENCIL_INDEX"; case 0x1902: return "GL_DEPTH_COMPONENT"; case 0x1903: return "GL_RED"; case 0x1904: return "GL_GREEN"; case 0x1905: return "GL_BLUE"; case 0x1906: return "GL_ALPHA"; case 0x1907: return "GL_RGB"; case 0x1908: return "GL_RGBA"; case 0x1909: return "GL_LUMINANCE"; case 0x190A: return "GL_LUMINANCE_ALPHA"; case 0x1A00: return "GL_BITMAP"; case 0x1B00: return "GL_POINT"; case 0x1B01: return "GL_LINE"; case 0x1B02: return "GL_FILL"; case 0x1C00: return "GL_RENDER"; case 0x1C01: return "GL_FEEDBACK"; case 0x1C02: return "GL_SELECT"; case 0x1D00: return "GL_FLAT"; case 0x1D01: return "GL_SMOOTH"; case 0x1E00: return "GL_KEEP"; case 0x1E01: return "GL_REPLACE"; case 0x1E02: return "GL_INCR"; case 0x1E03: return "GL_DECR"; case 0x1F00: return "GL_VENDOR"; case 0x1F01: return "GL_RENDERER"; case 0x1F02: return "GL_VERSION"; case 0x1F03: return "GL_EXTENSIONS"; case 0x2000: return "GL_S"; case 0x2001: return "GL_T"; case 0x2002: return "GL_R"; case 0x2003: return "GL_Q"; case 0x2100: return "GL_MODULATE"; case 0x2101: return "GL_DECAL"; case 0x2200: return "GL_TEXTURE_ENV_MODE"; case 0x2201: return "GL_TEXTURE_ENV_COLOR"; case 0x2300: return "GL_TEXTURE_ENV"; case 0x2400: return "GL_EYE_LINEAR"; case 0x2401: return "GL_OBJECT_LINEAR"; case 0x2402: return "GL_SPHERE_MAP"; case 0x2500: return "GL_TEXTURE_GEN_MODE"; case 0x2501: return "GL_OBJECT_PLANE"; case 0x2502: return "GL_EYE_PLANE"; case 0x2600: return "GL_NEAREST"; case 0x2601: return "GL_LINEAR"; case 0x2700: return "GL_NEAREST_MIPMAP_NEAREST"; case 0x2701: return "GL_LINEAR_MIPMAP_NEAREST"; case 0x2702: return "GL_NEAREST_MIPMAP_LINEAR"; case 0x2703: return "GL_LINEAR_MIPMAP_LINEAR"; case 0x2800: return "GL_TEXTURE_MAG_FILTER"; case 0x2801: return "GL_TEXTURE_MIN_FILTER"; case 0x2802: return "GL_TEXTURE_WRAP_S"; case 0x2803: return "GL_TEXTURE_WRAP_T"; case 0x2900: return "GL_CLAMP"; case 0x2901: return "GL_REPEAT"; case 0x2A00: return "GL_POLYGON_OFFSET_UNITS"; case 0x2A01: return "GL_POLYGON_OFFSET_POINT"; case 0x2A02: return "GL_POLYGON_OFFSET_LINE"; case 0x2A10: return "GL_R3_G3_B2"; case 0x2A20: return "GL_V2F"; case 0x2A21: return "GL_V3F"; case 0x2A22: return "GL_C4UB_V2F"; case 0x2A23: return "GL_C4UB_V3F"; case 0x2A24: return "GL_C3F_V3F"; case 0x2A25: return "GL_N3F_V3F"; case 0x2A26: return "GL_C4F_N3F_V3F"; case 0x2A27: return "GL_T2F_V3F"; case 0x2A28: return "GL_T4F_V4F"; case 0x2A29: return "GL_T2F_C4UB_V3F"; case 0x2A2A: return "GL_T2F_C3F_V3F"; case 0x2A2B: return "GL_T2F_N3F_V3F"; case 0x2A2C: return "GL_T2F_C4F_N3F_V3F"; case 0x2A2D: return "GL_T4F_C4F_N3F_V4F"; case 0x3000: return "GL_CLIP_PLANE0"; case 0x3001: return "GL_CLIP_PLANE1"; case 0x3002: return "GL_CLIP_PLANE2"; case 0x3003: return "GL_CLIP_PLANE3"; case 0x3004: return "GL_CLIP_PLANE4"; case 0x3005: return "GL_CLIP_PLANE5"; case 0x4000: return "GL_LIGHT0"; case 0x4001: return "GL_LIGHT1"; case 0x4002: return "GL_LIGHT2"; case 0x4003: return "GL_LIGHT3"; case 0x4004: return "GL_LIGHT4"; case 0x4005: return "GL_LIGHT5"; case 0x4006: return "GL_LIGHT6"; case 0x4007: return "GL_LIGHT7"; case 0x8001: return "GL_CONSTANT_COLOR"; case 0x8002: return "GL_ONE_MINUS_CONSTANT_COLOR"; case 0x8003: return "GL_CONSTANT_ALPHA"; case 0x8004: return "GL_ONE_MINUS_CONSTANT_ALPHA"; case 0x8005: return "GL_BLEND_COLOR"; case 0x8006: return "GL_FUNC_ADD"; case 0x8007: return "GL_MIN"; case 0x8008: return "GL_MAX"; case 0x8009: return "GL_BLEND_EQUATION"; case 0x800A: return "GL_FUNC_SUBTRACT"; case 0x800B: return "GL_FUNC_REVERSE_SUBTRACT"; case 0x8010: return "GL_CONVOLUTION_1D"; case 0x8011: return "GL_CONVOLUTION_2D"; case 0x8012: return "GL_SEPARABLE_2D"; case 0x8013: return "GL_CONVOLUTION_BORDER_MODE"; case 0x8014: return "GL_CONVOLUTION_FILTER_SCALE"; case 0x8015: return "GL_CONVOLUTION_FILTER_BIAS"; case 0x8016: return "GL_REDUCE"; case 0x8017: return "GL_CONVOLUTION_FORMAT"; case 0x8018: return "GL_CONVOLUTION_WIDTH"; case 0x8019: return "GL_CONVOLUTION_HEIGHT"; case 0x801A: return "GL_MAX_CONVOLUTION_WIDTH"; case 0x801B: return "GL_MAX_CONVOLUTION_HEIGHT"; case 0x801C: return "GL_POST_CONVOLUTION_RED_SCALE"; case 0x801D: return "GL_POST_CONVOLUTION_GREEN_SCALE"; case 0x801E: return "GL_POST_CONVOLUTION_BLUE_SCALE"; case 0x801F: return "GL_POST_CONVOLUTION_ALPHA_SCALE"; case 0x8020: return "GL_POST_CONVOLUTION_RED_BIAS"; case 0x8021: return "GL_POST_CONVOLUTION_GREEN_BIAS"; case 0x8022: return "GL_POST_CONVOLUTION_BLUE_BIAS"; case 0x8023: return "GL_POST_CONVOLUTION_ALPHA_BIAS"; case 0x8024: return "GL_HISTOGRAM"; case 0x8025: return "GL_PROXY_HISTOGRAM"; case 0x8026: return "GL_HISTOGRAM_WIDTH"; case 0x8027: return "GL_HISTOGRAM_FORMAT"; case 0x8028: return "GL_HISTOGRAM_RED_SIZE"; case 0x8029: return "GL_HISTOGRAM_GREEN_SIZE"; case 0x802A: return "GL_HISTOGRAM_BLUE_SIZE"; case 0x802B: return "GL_HISTOGRAM_ALPHA_SIZE"; case 0x802C: return "GL_HISTOGRAM_LUMINANCE_SIZE"; case 0x802D: return "GL_HISTOGRAM_SINK"; case 0x802E: return "GL_MINMAX"; case 0x802F: return "GL_MINMAX_FORMAT"; case 0x8030: return "GL_MINMAX_SINK"; case 0x8031: return "GL_TABLE_TOO_LARGE"; case 0x8032: return "GL_UNSIGNED_BYTE_3_3_2"; case 0x8033: return "GL_UNSIGNED_SHORT_4_4_4_4"; case 0x8034: return "GL_UNSIGNED_SHORT_5_5_5_1"; case 0x8035: return "GL_UNSIGNED_INT_8_8_8_8"; case 0x8036: return "GL_UNSIGNED_INT_10_10_10_2"; case 0x8037: return "GL_POLYGON_OFFSET_FILL"; case 0x8038: return "GL_POLYGON_OFFSET_FACTOR"; case 0x803A: return "GL_RESCALE_NORMAL"; case 0x803B: return "GL_ALPHA4"; case 0x803C: return "GL_ALPHA8"; case 0x803D: return "GL_ALPHA12"; case 0x803E: return "GL_ALPHA16"; case 0x803F: return "GL_LUMINANCE4"; case 0x8040: return "GL_LUMINANCE8"; case 0x8041: return "GL_LUMINANCE12"; case 0x8042: return "GL_LUMINANCE16"; case 0x8043: return "GL_LUMINANCE4_ALPHA4"; case 0x8044: return "GL_LUMINANCE6_ALPHA2"; case 0x8045: return "GL_LUMINANCE8_ALPHA8"; case 0x8046: return "GL_LUMINANCE12_ALPHA4"; case 0x8047: return "GL_LUMINANCE12_ALPHA12"; case 0x8048: return "GL_LUMINANCE16_ALPHA16"; case 0x8049: return "GL_INTENSITY"; case 0x804A: return "GL_INTENSITY4"; case 0x804B: return "GL_INTENSITY8"; case 0x804C: return "GL_INTENSITY12"; case 0x804D: return "GL_INTENSITY16"; case 0x804F: return "GL_RGB4"; case 0x8050: return "GL_RGB5"; case 0x8051: return "GL_RGB8"; case 0x8052: return "GL_RGB10"; case 0x8053: return "GL_RGB12"; case 0x8054: return "GL_RGB16"; case 0x8055: return "GL_RGBA2"; case 0x8056: return "GL_RGBA4"; case 0x8057: return "GL_RGB5_A1"; case 0x8058: return "GL_RGBA8"; case 0x8059: return "GL_RGB10_A2"; case 0x805A: return "GL_RGBA12"; case 0x805B: return "GL_RGBA16"; case 0x805C: return "GL_TEXTURE_RED_SIZE"; case 0x805D: return "GL_TEXTURE_GREEN_SIZE"; case 0x805E: return "GL_TEXTURE_BLUE_SIZE"; case 0x805F: return "GL_TEXTURE_ALPHA_SIZE"; case 0x8060: return "GL_TEXTURE_LUMINANCE_SIZE"; case 0x8061: return "GL_TEXTURE_INTENSITY_SIZE"; case 0x8063: return "GL_PROXY_TEXTURE_1D"; case 0x8064: return "GL_PROXY_TEXTURE_2D"; case 0x8066: return "GL_TEXTURE_PRIORITY"; case 0x8067: return "GL_TEXTURE_RESIDENT"; case 0x8068: return "GL_TEXTURE_BINDING_1D"; case 0x8069: return "GL_TEXTURE_BINDING_2D"; case 0x806A: return "GL_TEXTURE_BINDING_3D"; case 0x806B: return "GL_PACK_SKIP_IMAGES"; case 0x806C: return "GL_PACK_IMAGE_HEIGHT"; case 0x806D: return "GL_UNPACK_SKIP_IMAGES"; case 0x806E: return "GL_UNPACK_IMAGE_HEIGHT"; case 0x806F: return "GL_TEXTURE_3D"; case 0x8070: return "GL_PROXY_TEXTURE_3D"; case 0x8071: return "GL_TEXTURE_DEPTH"; case 0x8072: return "GL_TEXTURE_WRAP_R"; case 0x8073: return "GL_MAX_3D_TEXTURE_SIZE"; case 0x8074: return "GL_VERTEX_ARRAY"; case 0x8075: return "GL_NORMAL_ARRAY"; case 0x8076: return "GL_COLOR_ARRAY"; case 0x8077: return "GL_INDEX_ARRAY"; case 0x8078: return "GL_TEXTURE_COORD_ARRAY"; case 0x8079: return "GL_EDGE_FLAG_ARRAY"; case 0x807A: return "GL_VERTEX_ARRAY_SIZE"; case 0x807B: return "GL_VERTEX_ARRAY_TYPE"; case 0x807C: return "GL_VERTEX_ARRAY_STRIDE"; case 0x807E: return "GL_NORMAL_ARRAY_TYPE"; case 0x807F: return "GL_NORMAL_ARRAY_STRIDE"; case 0x8081: return "GL_COLOR_ARRAY_SIZE"; case 0x8082: return "GL_COLOR_ARRAY_TYPE"; case 0x8083: return "GL_COLOR_ARRAY_STRIDE"; case 0x8085: return "GL_INDEX_ARRAY_TYPE"; case 0x8086: return "GL_INDEX_ARRAY_STRIDE"; case 0x8088: return "GL_TEXTURE_COORD_ARRAY_SIZE"; case 0x8089: return "GL_TEXTURE_COORD_ARRAY_TYPE"; case 0x808A: return "GL_TEXTURE_COORD_ARRAY_STRIDE"; case 0x808C: return "GL_EDGE_FLAG_ARRAY_STRIDE"; case 0x808E: return "GL_VERTEX_ARRAY_POINTER"; case 0x808F: return "GL_NORMAL_ARRAY_POINTER"; case 0x8090: return "GL_COLOR_ARRAY_POINTER"; case 0x8091: return "GL_INDEX_ARRAY_POINTER"; case 0x8092: return "GL_TEXTURE_COORD_ARRAY_POINTER"; case 0x8093: return "GL_EDGE_FLAG_ARRAY_POINTER"; case 0x809D: return "GL_MULTISAMPLE"; case 0x809E: return "GL_SAMPLE_ALPHA_TO_COVERAGE"; case 0x809F: return "GL_SAMPLE_ALPHA_TO_ONE"; case 0x80A0: return "GL_SAMPLE_COVERAGE"; case 0x80A8: return "GL_SAMPLE_BUFFERS"; case 0x80A9: return "GL_SAMPLES"; case 0x80AA: return "GL_SAMPLE_COVERAGE_VALUE"; case 0x80AB: return "GL_SAMPLE_COVERAGE_INVERT"; case 0x80B1: return "GL_COLOR_MATRIX"; case 0x80B2: return "GL_COLOR_MATRIX_STACK_DEPTH"; case 0x80B3: return "GL_MAX_COLOR_MATRIX_STACK_DEPTH"; case 0x80B4: return "GL_POST_COLOR_MATRIX_RED_SCALE"; case 0x80B5: return "GL_POST_COLOR_MATRIX_GREEN_SCALE"; case 0x80B6: return "GL_POST_COLOR_MATRIX_BLUE_SCALE"; case 0x80B7: return "GL_POST_COLOR_MATRIX_ALPHA_SCALE"; case 0x80B8: return "GL_POST_COLOR_MATRIX_RED_BIAS"; case 0x80B9: return "GL_POST_COLOR_MATRIX_GREEN_BIAS"; case 0x80BA: return "GL_POST_COLOR_MATRIX_BLUE_BIAS"; case 0x80BB: return "GL_POST_COLOR_MATRIX_ALPHA_BIAS"; case 0x80D0: return "GL_COLOR_TABLE"; case 0x80D1: return "GL_POST_CONVOLUTION_COLOR_TABLE"; case 0x80D2: return "GL_POST_COLOR_MATRIX_COLOR_TABLE"; case 0x80D3: return "GL_PROXY_COLOR_TABLE"; case 0x80D4: return "GL_PROXY_POST_CONVOLUTION_COLOR_TABLE"; case 0x80D5: return "GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE"; case 0x80D6: return "GL_COLOR_TABLE_SCALE"; case 0x80D7: return "GL_COLOR_TABLE_BIAS"; case 0x80D8: return "GL_COLOR_TABLE_FORMAT"; case 0x80D9: return "GL_COLOR_TABLE_WIDTH"; case 0x80DA: return "GL_COLOR_TABLE_RED_SIZE"; case 0x80DB: return "GL_COLOR_TABLE_GREEN_SIZE"; case 0x80DC: return "GL_COLOR_TABLE_BLUE_SIZE"; case 0x80DD: return "GL_COLOR_TABLE_ALPHA_SIZE"; case 0x80DE: return "GL_COLOR_TABLE_LUMINANCE_SIZE"; case 0x80DF: return "GL_COLOR_TABLE_INTENSITY_SIZE"; case 0x80E0: return "GL_BGR"; case 0x80E1: return "GL_BGRA"; case 0x80E8: return "GL_MAX_ELEMENTS_VERTICES"; case 0x80E9: return "GL_MAX_ELEMENTS_INDICES"; case 0x812D: return "GL_CLAMP_TO_BORDER"; case 0x812F: return "GL_CLAMP_TO_EDGE"; case 0x813A: return "GL_TEXTURE_MIN_LOD"; case 0x813B: return "GL_TEXTURE_MAX_LOD"; case 0x813C: return "GL_TEXTURE_BASE_LEVEL"; case 0x813D: return "GL_TEXTURE_MAX_LEVEL"; case 0x8151: return "GL_CONSTANT_BORDER"; case 0x8153: return "GL_REPLICATE_BORDER"; case 0x8154: return "GL_CONVOLUTION_BORDER_COLOR"; case 0x81F8: return "GL_LIGHT_MODEL_COLOR_CONTROL"; case 0x81F9: return "GL_SINGLE_COLOR"; case 0x81FA: return "GL_SEPARATE_SPECULAR_COLOR"; case 0x8362: return "GL_UNSIGNED_BYTE_2_3_3_REV"; case 0x8363: return "GL_UNSIGNED_SHORT_5_6_5"; case 0x8364: return "GL_UNSIGNED_SHORT_5_6_5_REV"; case 0x8365: return "GL_UNSIGNED_SHORT_4_4_4_4_REV"; case 0x8366: return "GL_UNSIGNED_SHORT_1_5_5_5_REV"; case 0x8367: return "GL_UNSIGNED_INT_8_8_8_8_REV"; case 0x8368: return "GL_UNSIGNED_INT_2_10_10_10_REV"; case 0x846D: return "GL_ALIASED_POINT_SIZE_RANGE"; case 0x846E: return "GL_ALIASED_LINE_WIDTH_RANGE"; case 0x84C0: return "GL_TEXTURE0"; case 0x84C1: return "GL_TEXTURE1"; case 0x84C2: return "GL_TEXTURE2"; case 0x84C3: return "GL_TEXTURE3"; case 0x84C4: return "GL_TEXTURE4"; case 0x84C5: return "GL_TEXTURE5"; case 0x84C6: return "GL_TEXTURE6"; case 0x84C7: return "GL_TEXTURE7"; case 0x84C8: return "GL_TEXTURE8"; case 0x84C9: return "GL_TEXTURE9"; case 0x84CA: return "GL_TEXTURE10"; case 0x84CB: return "GL_TEXTURE11"; case 0x84CC: return "GL_TEXTURE12"; case 0x84CD: return "GL_TEXTURE13"; case 0x84CE: return "GL_TEXTURE14"; case 0x84CF: return "GL_TEXTURE15"; case 0x84D0: return "GL_TEXTURE16"; case 0x84D1: return "GL_TEXTURE17"; case 0x84D2: return "GL_TEXTURE18"; case 0x84D3: return "GL_TEXTURE19"; case 0x84D4: return "GL_TEXTURE20"; case 0x84D5: return "GL_TEXTURE21"; case 0x84D6: return "GL_TEXTURE22"; case 0x84D7: return "GL_TEXTURE23"; case 0x84D8: return "GL_TEXTURE24"; case 0x84D9: return "GL_TEXTURE25"; case 0x84DA: return "GL_TEXTURE26"; case 0x84DB: return "GL_TEXTURE27"; case 0x84DC: return "GL_TEXTURE28"; case 0x84DD: return "GL_TEXTURE29"; case 0x84DE: return "GL_TEXTURE30"; case 0x84DF: return "GL_TEXTURE31"; case 0x84E0: return "GL_ACTIVE_TEXTURE"; case 0x84E1: return "GL_CLIENT_ACTIVE_TEXTURE"; case 0x84E2: return "GL_MAX_TEXTURE_UNITS"; case 0x84E3: return "GL_TRANSPOSE_MODELVIEW_MATRIX"; case 0x84E4: return "GL_TRANSPOSE_PROJECTION_MATRIX"; case 0x84E5: return "GL_TRANSPOSE_TEXTURE_MATRIX"; case 0x84E6: return "GL_TRANSPOSE_COLOR_MATRIX"; case 0x84E7: return "GL_SUBTRACT"; case 0x84E9: return "GL_COMPRESSED_ALPHA"; case 0x84EA: return "GL_COMPRESSED_LUMINANCE"; case 0x84EB: return "GL_COMPRESSED_LUMINANCE_ALPHA"; case 0x84EC: return "GL_COMPRESSED_INTENSITY"; case 0x84ED: return "GL_COMPRESSED_RGB"; case 0x84EE: return "GL_COMPRESSED_RGBA"; case 0x84EF: return "GL_TEXTURE_COMPRESSION_HINT"; case 0x8511: return "GL_NORMAL_MAP"; case 0x8512: return "GL_REFLECTION_MAP"; case 0x8513: return "GL_TEXTURE_CUBE_MAP"; case 0x8514: return "GL_TEXTURE_BINDING_CUBE_MAP"; case 0x8515: return "GL_TEXTURE_CUBE_MAP_POSITIVE_X"; case 0x8516: return "GL_TEXTURE_CUBE_MAP_NEGATIVE_X"; case 0x8517: return "GL_TEXTURE_CUBE_MAP_POSITIVE_Y"; case 0x8518: return "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y"; case 0x8519: return "GL_TEXTURE_CUBE_MAP_POSITIVE_Z"; case 0x851A: return "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z"; case 0x851B: return "GL_PROXY_TEXTURE_CUBE_MAP"; case 0x851C: return "GL_MAX_CUBE_MAP_TEXTURE_SIZE"; case 0x8570: return "GL_COMBINE"; case 0x8571: return "GL_COMBINE_RGB"; case 0x8572: return "GL_COMBINE_ALPHA"; case 0x8573: return "GL_RGB_SCALE"; case 0x8574: return "GL_ADD_SIGNED"; case 0x8575: return "GL_INTERPOLATE"; case 0x8576: return "GL_CONSTANT"; case 0x8577: return "GL_PRIMARY_COLOR"; case 0x8578: return "GL_PREVIOUS"; case 0x8580: return "GL_SOURCE0_RGB"; case 0x8581: return "GL_SOURCE1_RGB"; case 0x8582: return "GL_SOURCE2_RGB"; case 0x8588: return "GL_SOURCE0_ALPHA"; case 0x8589: return "GL_SOURCE1_ALPHA"; case 0x858A: return "GL_SOURCE2_ALPHA"; case 0x8590: return "GL_OPERAND0_RGB"; case 0x8591: return "GL_OPERAND1_RGB"; case 0x8592: return "GL_OPERAND2_RGB"; case 0x8598: return "GL_OPERAND0_ALPHA"; case 0x8599: return "GL_OPERAND1_ALPHA"; case 0x859A: return "GL_OPERAND2_ALPHA"; case 0x86A0: return "GL_TEXTURE_COMPRESSED_IMAGE_SIZE"; case 0x86A1: return "GL_TEXTURE_COMPRESSED"; case 0x86A2: return "GL_NUM_COMPRESSED_TEXTURE_FORMATS"; case 0x86A3: return "GL_COMPRESSED_TEXTURE_FORMATS"; case 0x86AE: return "GL_DOT3_RGB"; case 0x86AF: return "GL_DOT3_RGBA"; case 0x8750: return "GL_DEPTH_STENCIL_MESA"; case 0x8751: return "GL_UNSIGNED_INT_24_8_MESA"; case 0x8752: return "GL_UNSIGNED_INT_8_24_REV_MESA"; case 0x8753: return "GL_UNSIGNED_SHORT_15_1_MESA"; case 0x8754: return "GL_UNSIGNED_SHORT_1_15_REV_MESA"; case 0x8622: return "GL_VERTEX_ATTRIB_ARRAY_ENABLED"; case 0x8623: return "GL_VERTEX_ATTRIB_ARRAY_SIZE"; case 0x8624: return "GL_VERTEX_ATTRIB_ARRAY_STRIDE"; case 0x8625: return "GL_VERTEX_ATTRIB_ARRAY_TYPE"; case 0x8626: return "GL_CURRENT_VERTEX_ATTRIB"; case 0x8642: return "GL_VERTEX_PROGRAM_POINT_SIZE"; case 0x8645: return "GL_VERTEX_ATTRIB_ARRAY_POINTER"; case 0x8800: return "GL_STENCIL_BACK_FUNC"; case 0x8801: return "GL_STENCIL_BACK_FAIL"; case 0x8802: return "GL_STENCIL_BACK_PASS_DEPTH_FAIL"; case 0x8803: return "GL_STENCIL_BACK_PASS_DEPTH_PASS"; case 0x8824: return "GL_MAX_DRAW_BUFFERS"; case 0x8825: return "GL_DRAW_BUFFER0"; case 0x8826: return "GL_DRAW_BUFFER1"; case 0x8827: return "GL_DRAW_BUFFER2"; case 0x8828: return "GL_DRAW_BUFFER3"; case 0x8829: return "GL_DRAW_BUFFER4"; case 0x882A: return "GL_DRAW_BUFFER5"; case 0x882B: return "GL_DRAW_BUFFER6"; case 0x882C: return "GL_DRAW_BUFFER7"; case 0x882D: return "GL_DRAW_BUFFER8"; case 0x882E: return "GL_DRAW_BUFFER9"; case 0x882F: return "GL_DRAW_BUFFER10"; case 0x8830: return "GL_DRAW_BUFFER11"; case 0x8831: return "GL_DRAW_BUFFER12"; case 0x8832: return "GL_DRAW_BUFFER13"; case 0x8833: return "GL_DRAW_BUFFER14"; case 0x8834: return "GL_DRAW_BUFFER15"; case 0x883D: return "GL_BLEND_EQUATION_ALPHA"; case 0x8869: return "GL_MAX_VERTEX_ATTRIBS"; case 0x886A: return "GL_VERTEX_ATTRIB_ARRAY_NORMALIZED"; case 0x8872: return "GL_MAX_TEXTURE_IMAGE_UNITS"; case 0x8B30: return "GL_FRAGMENT_SHADER"; case 0x8B31: return "GL_VERTEX_SHADER"; case 0x8B49: return "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS"; case 0x8B4A: return "GL_MAX_VERTEX_UNIFORM_COMPONENTS"; case 0x8B4B: return "GL_MAX_VARYING_FLOATS"; case 0x8B4C: return "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS"; case 0x8B4D: return "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS"; case 0x8B4F: return "GL_SHADER_TYPE"; case 0x8B50: return "GL_FLOAT_VEC2"; case 0x8B51: return "GL_FLOAT_VEC3"; case 0x8B52: return "GL_FLOAT_VEC4"; case 0x8B53: return "GL_INT_VEC2"; case 0x8B54: return "GL_INT_VEC3"; case 0x8B55: return "GL_INT_VEC4"; case 0x8B56: return "GL_BOOL"; case 0x8B57: return "GL_BOOL_VEC2"; case 0x8B58: return "GL_BOOL_VEC3"; case 0x8B59: return "GL_BOOL_VEC4"; case 0x8B5A: return "GL_FLOAT_MAT2"; case 0x8B5B: return "GL_FLOAT_MAT3"; case 0x8B5C: return "GL_FLOAT_MAT4"; case 0x8B5D: return "GL_SAMPLER_1D"; case 0x8B5E: return "GL_SAMPLER_2D"; case 0x8B5F: return "GL_SAMPLER_3D"; case 0x8B60: return "GL_SAMPLER_CUBE"; case 0x8B61: return "GL_SAMPLER_1D_SHADOW"; case 0x8B62: return "GL_SAMPLER_2D_SHADOW"; case 0x8B80: return "GL_DELETE_STATUS"; case 0x8B81: return "GL_COMPILE_STATUS"; case 0x8B82: return "GL_LINK_STATUS"; case 0x8B83: return "GL_VALIDATE_STATUS"; case 0x8B84: return "GL_INFO_LOG_LENGTH"; case 0x8B85: return "GL_ATTACHED_SHADERS"; case 0x8B86: return "GL_ACTIVE_UNIFORMS"; case 0x8B87: return "GL_ACTIVE_UNIFORM_MAX_LENGTH"; case 0x8B88: return "GL_SHADER_SOURCE_LENGTH"; case 0x8B89: return "GL_ACTIVE_ATTRIBUTES"; case 0x8B8A: return "GL_ACTIVE_ATTRIBUTE_MAX_LENGTH"; case 0x8B8B: return "GL_FRAGMENT_SHADER_DERIVATIVE_HINT"; case 0x8B8C: return "GL_SHADING_LANGUAGE_VERSION"; case 0x8B8D: return "GL_CURRENT_PROGRAM"; case 0x8CA0: return "GL_POINT_SPRITE_COORD_ORIGIN"; case 0x8CA1: return "GL_LOWER_LEFT"; case 0x8CA2: return "GL_UPPER_LEFT"; case 0x8CA3: return "GL_STENCIL_BACK_REF"; case 0x8CA4: return "GL_STENCIL_BACK_VALUE_MASK"; case 0x8CA5: return "GL_STENCIL_BACK_WRITEMASK"; case 0x8643: return "GL_VERTEX_PROGRAM_TWO_SIDE"; case 0x8861: return "GL_POINT_SPRITE"; case 0x8862: return "GL_COORD_REPLACE"; case 0x8871: return "GL_MAX_TEXTURE_COORDS"; case 0x8764: return "GL_BUFFER_SIZE"; case 0x8765: return "GL_BUFFER_USAGE"; case 0x8864: return "GL_QUERY_COUNTER_BITS"; case 0x8865: return "GL_CURRENT_QUERY"; case 0x8866: return "GL_QUERY_RESULT"; case 0x8867: return "GL_QUERY_RESULT_AVAILABLE"; case 0x8892: return "GL_ARRAY_BUFFER"; case 0x8893: return "GL_ELEMENT_ARRAY_BUFFER"; case 0x8894: return "GL_ARRAY_BUFFER_BINDING"; case 0x8895: return "GL_ELEMENT_ARRAY_BUFFER_BINDING"; case 0x889F: return "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING"; case 0x88B8: return "GL_READ_ONLY"; case 0x88B9: return "GL_WRITE_ONLY"; case 0x88BA: return "GL_READ_WRITE"; case 0x88BB: return "GL_BUFFER_ACCESS"; case 0x88BC: return "GL_BUFFER_MAPPED"; case 0x88BD: return "GL_BUFFER_MAP_POINTER"; case 0x88E0: return "GL_STREAM_DRAW"; case 0x88E1: return "GL_STREAM_READ"; case 0x88E2: return "GL_STREAM_COPY"; case 0x88E4: return "GL_STATIC_DRAW"; case 0x88E5: return "GL_STATIC_READ"; case 0x88E6: return "GL_STATIC_COPY"; case 0x88E8: return "GL_DYNAMIC_DRAW"; case 0x88E9: return "GL_DYNAMIC_READ"; case 0x88EA: return "GL_DYNAMIC_COPY"; case 0x8914: return "GL_SAMPLES_PASSED"; case 0x8896: return "GL_VERTEX_ARRAY_BUFFER_BINDING"; case 0x8897: return "GL_NORMAL_ARRAY_BUFFER_BINDING"; case 0x8898: return "GL_COLOR_ARRAY_BUFFER_BINDING"; case 0x8899: return "GL_INDEX_ARRAY_BUFFER_BINDING"; case 0x889A: return "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING"; case 0x889B: return "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING"; case 0x889C: return "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING"; case 0x889D: return "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING"; case 0x889E: return "GL_WEIGHT_ARRAY_BUFFER_BINDING"; case 0x8450: return "GL_FOG_COORD_SRC"; case 0x8451: return "GL_FOG_COORD"; case 0x8453: return "GL_CURRENT_FOG_COORD"; case 0x8454: return "GL_FOG_COORD_ARRAY_TYPE"; case 0x8455: return "GL_FOG_COORD_ARRAY_STRIDE"; case 0x8456: return "GL_FOG_COORD_ARRAY_POINTER"; case 0x8457: return "GL_FOG_COORD_ARRAY"; default: return "UNKNOWN_GL_ENUM"; } } const char * reverse_clipboard_type(PP_Flash_Clipboard_Type ct) { switch (ct) { CASE(PP_FLASH_CLIPBOARD_TYPE_STANDARD); CASE(PP_FLASH_CLIPBOARD_TYPE_SELECTION); default: return "UNKNOWNCLIPBOARDTYPE"; } } const char * reverse_clipboard_format(uint32_t cf) { switch (cf) { CASE(PP_FLASH_CLIPBOARD_FORMAT_INVALID); CASE(PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT); CASE(PP_FLASH_CLIPBOARD_FORMAT_HTML); CASE(PP_FLASH_CLIPBOARD_FORMAT_RTF); default: return "UNKNOWNCLIPBOARDFORMAT"; } } const char * reverse_video_decoder_profile(PP_VideoDecoder_Profile profile) { switch (profile) { CASE(PP_VIDEODECODER_PROFILE_UNKNOWN); CASE(PP_VIDEODECODER_H264PROFILE_NONE); CASE(PP_VIDEODECODER_H264PROFILE_BASELINE); CASE(PP_VIDEODECODER_H264PROFILE_MAIN); CASE(PP_VIDEODECODER_H264PROFILE_EXTENDED); CASE(PP_VIDEODECODER_H264PROFILE_HIGH); CASE(PP_VIDEODECODER_H264PROFILE_HIGH10PROFILE); CASE(PP_VIDEODECODER_H264PROFILE_HIGH422PROFILE); CASE(PP_VIDEODECODER_H264PROFILE_HIGH444PREDICTIVEPROFILE); CASE(PP_VIDEODECODER_H264PROFILE_SCALABLEBASELINE); CASE(PP_VIDEODECODER_H264PROFILE_SCALABLEHIGH); CASE(PP_VIDEODECODER_H264PROFILE_STEREOHIGH); CASE(PP_VIDEODECODER_H264PROFILE_MULTIVIEWHIGH); CASE(PP_VIDEODECODER_VP8PROFILE_ANY); default: return "UNKNOWNVIDEODECODERPROFILE"; } } const char * reverse_file_chooser_mode(PP_FileChooserMode_Dev mode) { switch (mode) { CASE(PP_FILECHOOSERMODE_OPEN); CASE(PP_FILECHOOSERMODE_OPENMULTIPLE); default: return "UNKNOWNFILECHOOSERMODE"; } } const char * reverse_udp_socket_feature(PP_UDPSocketFeature_Private feature) { switch (feature) { CASE(PP_UDPSOCKETFEATURE_PRIVATE_ADDRESS_REUSE); CASE(PP_UDPSOCKETFEATURE_PRIVATE_BROADCAST); default: return "UNKNOWNUDPSOCKETFEATURE"; } } const char * reverse_x509_certificate_field(PP_X509Certificate_Private_Field field) { switch (field) { CASE(PP_X509CERTIFICATE_PRIVATE_ISSUER_COMMON_NAME); CASE(PP_X509CERTIFICATE_PRIVATE_ISSUER_LOCALITY_NAME); CASE(PP_X509CERTIFICATE_PRIVATE_ISSUER_STATE_OR_PROVINCE_NAME); CASE(PP_X509CERTIFICATE_PRIVATE_ISSUER_COUNTRY_NAME); CASE(PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_NAME); CASE(PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_UNIT_NAME); CASE(PP_X509CERTIFICATE_PRIVATE_ISSUER_UNIQUE_ID); CASE(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COMMON_NAME); CASE(PP_X509CERTIFICATE_PRIVATE_SUBJECT_LOCALITY_NAME); CASE(PP_X509CERTIFICATE_PRIVATE_SUBJECT_STATE_OR_PROVINCE_NAME); CASE(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COUNTRY_NAME); CASE(PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_NAME); CASE(PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_UNIT_NAME); CASE(PP_X509CERTIFICATE_PRIVATE_SUBJECT_UNIQUE_ID); CASE(PP_X509CERTIFICATE_PRIVATE_VERSION); CASE(PP_X509CERTIFICATE_PRIVATE_SERIAL_NUMBER); CASE(PP_X509CERTIFICATE_PRIVATE_SIGNATURE_ALGORITHM_OID); CASE(PP_X509CERTIFICATE_PRIVATE_SIGNATURE_ALGORITHM_PARAMATERS_RAW); CASE(PP_X509CERTIFICATE_PRIVATE_VALIDITY_NOT_BEFORE); CASE(PP_X509CERTIFICATE_PRIVATE_VALIDITY_NOT_AFTER); CASE(PP_X509CERTIFICATE_PRIVATE_SUBJECT_PUBLIC_KEY_ALGORITHM_OID); CASE(PP_X509CERTIFICATE_PRIVATE_SUBJECT_PUBLIC_KEY); CASE(PP_X509CERTIFICATE_PRIVATE_RAW); CASE(PP_X509CERTIFICATE_PRIVATE_ISSUER_DISTINGUISHED_NAME); CASE(PP_X509CERTIFICATE_PRIVATE_SUBJECT_DISTINGUISHED_NAME); default: return "UNKNOWNX509CERTIFICATEFIELD"; } } const char * reverse_pdf_feature(PP_PDFFeature feature) { switch (feature) { CASE(PP_PDFFEATURE_HIDPI); CASE(PP_PDFFEATURE_PRINTING); default: return "UNKNOWNPDFFEATURE"; } } const char * reverse_private_font_charset(PP_PrivateFontCharset charset) { switch (charset) { CASE(PP_PRIVATEFONTCHARSET_ANSI); CASE(PP_PRIVATEFONTCHARSET_DEFAULT); CASE(PP_PRIVATEFONTCHARSET_SYMBOL); CASE(PP_PRIVATEFONTCHARSET_MAC); CASE(PP_PRIVATEFONTCHARSET_SHIFTJIS); CASE(PP_PRIVATEFONTCHARSET_HANGUL); CASE(PP_PRIVATEFONTCHARSET_JOHAB); CASE(PP_PRIVATEFONTCHARSET_GB2312); CASE(PP_PRIVATEFONTCHARSET_CHINESEBIG5); CASE(PP_PRIVATEFONTCHARSET_GREEK); CASE(PP_PRIVATEFONTCHARSET_TURKISH); CASE(PP_PRIVATEFONTCHARSET_VIETNAMESE); CASE(PP_PRIVATEFONTCHARSET_HEBREW); CASE(PP_PRIVATEFONTCHARSET_ARABIC); CASE(PP_PRIVATEFONTCHARSET_BALTIC); CASE(PP_PRIVATEFONTCHARSET_RUSSIAN); CASE(PP_PRIVATEFONTCHARSET_THAI); CASE(PP_PRIVATEFONTCHARSET_EASTEUROPE); CASE(PP_PRIVATEFONTCHARSET_OEM); default: return "UNKNOWNPRIVATEFONTCHARSET"; } } const char * reverse_graphics3d_attribute(int32_t attr) { switch (attr) { CASE(PP_GRAPHICS3DATTRIB_ALPHA_SIZE); CASE(PP_GRAPHICS3DATTRIB_BLUE_SIZE); CASE(PP_GRAPHICS3DATTRIB_GREEN_SIZE); CASE(PP_GRAPHICS3DATTRIB_RED_SIZE); CASE(PP_GRAPHICS3DATTRIB_DEPTH_SIZE); CASE(PP_GRAPHICS3DATTRIB_STENCIL_SIZE); CASE(PP_GRAPHICS3DATTRIB_SAMPLES); CASE(PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS); CASE(PP_GRAPHICS3DATTRIB_NONE); CASE(PP_GRAPHICS3DATTRIB_HEIGHT); CASE(PP_GRAPHICS3DATTRIB_WIDTH); CASE(PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR); CASE(PP_GRAPHICS3DATTRIB_GPU_PREFERENCE); default: return "UNKNOWNATTRIBUTE"; } } freshplayerplugin-0.3.9/src/reverse_constant.h000066400000000000000000000057051321746453100216270ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include const char *reverse_npp_variable(NPPVariable var); const char *reverse_npn_variable(NPNVariable var); const char *reverse_pp_url_response_property(PP_URLResponseProperty prop); const char *reverse_pp_url_request_property(PP_URLRequestProperty prop); const char *reverse_pp_text_input_type(PP_TextInput_Type_Dev type); const char *reverse_pp_flash_setting(PP_FlashSetting setting); const char *reverse_pp_image_data_format(PP_ImageDataFormat fmt); const char *reverse_xevent_type(int type); const char *reverse_char_set_conversion_error(enum PP_CharSet_ConversionError e); const char *reverse_gl_enum(unsigned int e); const char *reverse_clipboard_type(PP_Flash_Clipboard_Type ct); const char *reverse_clipboard_format(uint32_t cf); const char *reverse_video_decoder_profile(PP_VideoDecoder_Profile profile); const char *reverse_file_chooser_mode(PP_FileChooserMode_Dev mode); const char *reverse_udp_socket_feature(PP_UDPSocketFeature_Private feature); const char *reverse_x509_certificate_field(PP_X509Certificate_Private_Field field); const char *reverse_pdf_feature(PP_PDFFeature feature); const char *reverse_private_font_charset(PP_PrivateFontCharset charset); const char *reverse_graphics3d_attribute(int32_t attr); freshplayerplugin-0.3.9/src/screensaver_control.c000066400000000000000000000275171321746453100223230ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "compat.h" #include "config.h" #include "screensaver_control.h" #include "trace_core.h" #include #include #include #include #include #define GS_SERVICE "org.gnome.ScreenSaver" #define GS_PATH "/org/gnome/ScreenSaver" #define GS_INTERFACE "org.gnome.ScreenSaver" #define FDOS_SERVICE "org.freedesktop.ScreenSaver" #define FDOS_PATH "/org/freedesktop/ScreenSaver" #define FDOS_INTERFACE "org.freedesktop.ScreenSaver" #define KS_SERVICE "org.kde.screensaver" #define KS_PATH "/ScreenSaver" #define KS_INTERFACE "org.kde.screensaver" #define CINNAMON_SERVICE "org.cinnamon.ScreenSaver" #define CINNAMON_PATH "/" #define CINNAMON_INTERFACE "org.cinnamon.ScreenSaver" #if HAVE_GLIB_DBUS static GDBusConnection *connection = NULL; #endif // HAVE_GLIB_DBUS static Window find_xscreensaver_window(Display *dpy) { Window root = DefaultRootWindow(dpy); Window root2, parent_wnd, wnd; Window *children; unsigned int nchildren; Status status; status = XQueryTree(dpy, root, &root2, &parent_wnd, &children, &nchildren); if (status == 0) { // failure return 0; } Atom XA_SCREENSAVER_VERSION = XInternAtom(dpy, "_SCREENSAVER_VERSION", False); wnd = None; for (unsigned int k = 0; k < nchildren; k ++) { Atom type; int format; unsigned long nitems; unsigned long bytes_after; unsigned char *prop; status = XGetWindowProperty(dpy, children[k], XA_SCREENSAVER_VERSION, 0, 200, False, XA_STRING, &type, &format, &nitems, &bytes_after, &prop); // relying on error handler already set if (status == Success) { if (prop) XFree(prop); if (type != None) { wnd = children[k]; goto done; } } } done: if (children) XFree(children); return wnd; } static int is_xscreensaver_active(Display *dpy) { Atom XA_SCREENSAVER_STATUS = XInternAtom(dpy, "_SCREENSAVER_STATUS", False); Atom type; Atom *data; int format; unsigned long nitems, bytesafter; Status status; int screen = 0; // XScreenSaver always uses screen 0 status = XGetWindowProperty(dpy, RootWindow(dpy, screen), XA_SCREENSAVER_STATUS, 0, 200, False, XA_INTEGER, &type, &format, &nitems, &bytesafter, (unsigned char **)&data); if (status == Success && type == XA_INTEGER && nitems >= 3) { if (data[0] != 0) { // is active if data[0] equals XA_BLANK or XA_LOCK return 1; } return 0; } return 0; } static void deactivate_xscreensaver(Display *dpy) { Window xssw = find_xscreensaver_window(dpy); if (!xssw) { trace_warning("%s, no XScreenSaver's window found\n", __func__); return; } if (is_xscreensaver_active(dpy)) { // XScreenSaver already active, deactivating timer makes no sense return; } XEvent ev; Status status; Atom XA_SCREENSAVER = XInternAtom(dpy, "SCREENSAVER", False); Atom XA_DEACTIVATE = XInternAtom(dpy, "DEACTIVATE", False); ev.xany.type = ClientMessage; ev.xclient.display = dpy; ev.xclient.window = xssw; ev.xclient.message_type = XA_SCREENSAVER; ev.xclient.format = 32; memset(&ev.xclient.data, 0, sizeof(ev.xclient.data)); ev.xclient.data.l[0] = XA_DEACTIVATE; ev.xclient.data.l[1] = 0; ev.xclient.data.l[2] = 0; status = XSendEvent(dpy, xssw, False, 0, &ev); if (status == 0) { trace_warning("%s, can't send event to XScreenSaver's window\n", __func__); return; } } #if HAVE_GLIB_DBUS static int is_dbus_based_screensaver_active(const char *d_service, const char *d_path, const char *d_interface) { GDBusMessage *msg = NULL; GDBusMessage *reply = NULL; uint32_t ret = 0; assert(connection); // detect is screen saver already active msg = g_dbus_message_new_method_call(d_service, d_path, d_interface, "GetActive"); if (!msg) { trace_error("%s, can't allocate GDBusMessage\n", __func__); goto err; } GError *error = NULL; reply = g_dbus_connection_send_message_with_reply_sync(connection, msg, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error); if (error) { trace_error("%s, can't send message, %s\n", __func__, error->message); g_clear_error(&error); goto err; } g_dbus_connection_flush_sync(connection, NULL, &error); if (error != NULL) { trace_error("%s, can't flush dbus connection, %s\n", __func__, error->message); g_clear_error(&error); goto err; } GVariant *v = g_dbus_message_get_body(reply); v = g_variant_get_child_value(v, 0); if (g_variant_is_of_type(v, G_VARIANT_TYPE_BOOLEAN)) ret = g_variant_get_boolean(v); else ret = 0; err: if (reply) g_object_unref(reply); if (msg) g_object_unref(msg); return ret; } #endif // HAVE_GLIB_DBUS #if HAVE_GLIB_DBUS static void deactivate_dbus_based_screensaver(const char *d_service, const char *d_path, const char *d_interface) { if (!connection) screensaver_connect(); if (!connection) return; if (is_dbus_based_screensaver_active(d_service, d_path, d_interface)) { // screen saver is active already, deactivating timer makes no sense return; } GDBusMessage *msg = g_dbus_message_new_method_call(d_service, d_path, d_interface, "SimulateUserActivity"); if (!msg) return; GError *error = NULL; g_dbus_connection_send_message(connection, msg, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, &error); if (error != NULL) { trace_error("%s, can't send message, %s\n", __func__, error->message); g_clear_error(&error); goto err; } // workaround Plasma 5 issue by calling GetSessionIdleTime after SimulateUserActivity if (config.quirks.plasma5_screensaver) { msg = g_dbus_message_new_method_call(d_service, d_path, d_interface, "GetSessionIdleTime"); error = NULL; g_dbus_connection_send_message(connection, msg, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, &error); if (error != NULL) { trace_error("%s, can't send message, %s\n", __func__, error->message); g_clear_error(&error); goto err; } } g_dbus_connection_flush_sync(connection, NULL, &error); if (error != NULL) { trace_error("%s, can't flush dbus connection, %s\n", __func__, error->message); g_clear_error(&error); goto err; } err: g_object_unref(msg); } #endif // HAVE_GLIB_DBUS void screensaver_deactivate(Display *dpy, uint32_t types) { if (types & SST_XSCREENSAVER) deactivate_xscreensaver(dpy); // reset internal X screen saver timer XResetScreenSaver(dpy); #if HAVE_GLIB_DBUS if (types & SST_FDO_SCREENSAVER) deactivate_dbus_based_screensaver(FDOS_SERVICE, FDOS_PATH, FDOS_INTERFACE); if (types & SST_GNOME_SCREENSAVER) deactivate_dbus_based_screensaver(GS_SERVICE, GS_PATH, GS_INTERFACE); if (types & SST_KDE_SCREENSAVER) deactivate_dbus_based_screensaver(KS_SERVICE, KS_PATH, KS_INTERFACE); if (types & SST_CINNAMON_SCREENSAVER) deactivate_dbus_based_screensaver(CINNAMON_SERVICE, CINNAMON_PATH, CINNAMON_INTERFACE); #endif // HAVE_GLIB_DBUS } #if HAVE_GLIB_DBUS static uint32_t detect_dbus_based_screensavers(void) { GDBusMessage *msg, *reply; uint32_t ret; assert(connection); // enumerate all services msg = g_dbus_message_new_method_call("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "ListNames"); if (!msg) { trace_error("%s, can't allocate GDBusMessage\n", __func__); ret = 0; goto err_1; } GError *error = NULL; reply = g_dbus_connection_send_message_with_reply_sync(connection, msg, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error); if (error != NULL) { trace_error("%s, can't send message, %s\n", __func__, error->message); g_clear_error(&error); ret = 0; goto err_2; } g_dbus_connection_flush_sync(connection, NULL, &error); if (error != NULL) { trace_error("%s, can't flush dbus connection, %s\n", __func__, error->message); g_clear_error(&error); ret = 0; goto err_3; } // iterate over the list GVariant *v = g_dbus_message_get_body(reply); GVariantIter *iter; gchar *str; uint32_t flags = 0; g_variant_get(v, "(as)", &iter); while (g_variant_iter_loop(iter, "s", &str)) { if (strcmp(str, GS_SERVICE) == 0) flags |= SST_GNOME_SCREENSAVER; if (strcmp(str, KS_SERVICE) == 0) flags |= SST_KDE_SCREENSAVER; if (strcmp(str, FDOS_SERVICE) == 0) flags |= SST_FDO_SCREENSAVER; if (strcmp(str, CINNAMON_SERVICE) == 0) flags |= SST_CINNAMON_SCREENSAVER; } g_variant_iter_free(iter); ret = flags; err_3: g_object_unref(reply); err_2: g_object_unref(msg); err_1: return ret; } #endif // HAVE_GLIB_DBUS uint32_t screensaver_type_detect(Display *dpy) { #if HAVE_GLIB_DBUS if (!connection) screensaver_connect(); if (!connection) return 0; #endif // HAVE_GLIB_DBUS uint32_t flags = 0; if (find_xscreensaver_window(dpy) != 0) flags |= SST_XSCREENSAVER; #if HAVE_GLIB_DBUS flags |= detect_dbus_based_screensavers(); #endif // HAVE_GLIB_DBUS return flags; } void screensaver_connect(void) { #if HAVE_GLIB_DBUS if (connection) g_object_unref(connection); GError *error = NULL; connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error); if (connection == NULL) { trace_error("%s, can't connect to dbus, %s\n", __func__, error->message); g_clear_error(&error); } #endif // HAVE_GLIB_DBUS } void screensaver_disconnect(void) { #if HAVE_GLIB_DBUS g_object_unref(connection); connection = NULL; #endif // HAVE_GLIB_DBUS } freshplayerplugin-0.3.9/src/screensaver_control.h000066400000000000000000000032361321746453100223200ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include enum screensaver_types { SST_XSCREENSAVER = (1 << 0), SST_FDO_SCREENSAVER = (1 << 1), // freedesktop.org screensaver interface spec SST_GNOME_SCREENSAVER = (1 << 2), SST_KDE_SCREENSAVER = (1 << 3), SST_CINNAMON_SCREENSAVER = (1 << 4), }; uint32_t screensaver_type_detect(Display *dpy); void screensaver_deactivate(Display *dpy, uint32_t types); void screensaver_connect(void); void screensaver_disconnect(void); freshplayerplugin-0.3.9/src/shader_translator.cc000066400000000000000000000044511321746453100221150ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "shader_translator.h" #include #include #include static void __attribute__((constructor)) constructor_shader_translator(void) { ShInitialize(); } static void __attribute__((destructor)) destructor_shader_translator(void) { ShFinalize(); } char * translate_shader(GLenum type, const char *str) { ShBuiltInResources resources; ShInitBuiltInResources(&resources); resources.MaxVertexAttribs = 8; resources.MaxVertexUniformVectors = 128; resources.MaxVaryingVectors = 8; resources.MaxVertexTextureImageUnits = 0; resources.MaxCombinedTextureImageUnits = 8; resources.MaxTextureImageUnits = 8; resources.MaxFragmentUniformVectors = 16; resources.MaxDrawBuffers = 1; resources.OES_standard_derivatives = 0; resources.OES_EGL_image_external = 0; ShHandle compiler = ShConstructCompiler(type, SH_GLES2_SPEC, SH_GLSL_OUTPUT, &resources); ShCompile(compiler, &str, 1, SH_OBJECT_CODE); char *result = g_strdup(ShGetObjectCode(compiler).c_str()); ShDestruct(compiler); return result; } freshplayerplugin-0.3.9/src/shader_translator.h000066400000000000000000000024671321746453100217640ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #ifdef __cplusplus extern "C" { #endif char * translate_shader(GLenum type, const char *str); #ifdef __cplusplus } #endif freshplayerplugin-0.3.9/src/static_assert.h000066400000000000000000000034151321746453100211070ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))) #define STATIC_ASSERT_ATTRIBUTE_UNUSED __attribute__((unused)) #else #define STATIC_ASSERT_ATTRIBUTE_UNUSED #endif #define STATIC_ASSERT_HELPER1(expr, msg) typedef char static_assertion_##msg[(!!(expr))*2 - 1] \ STATIC_ASSERT_ATTRIBUTE_UNUSED #define STATIC_ASSERT_HELPER2(expr, msg) STATIC_ASSERT_HELPER1(expr, msg) #define STATIC_ASSERT(expr) STATIC_ASSERT_HELPER2(expr, __LINE__) #define STATIC_ASSERT_LESS_OR_EQ(expr1, expr2) STATIC_ASSERT(expr1 <= expr2) freshplayerplugin-0.3.9/src/symbolmap000066400000000000000000000002441321746453100200110ustar00rootroot00000000000000{ global: NP_GetMIMEDescription; NP_GetPluginVersion; NP_GetValue; NP_Initialize; NP_Shutdown; local: *; }; freshplayerplugin-0.3.9/src/tables.c000066400000000000000000000362671321746453100175170ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "config.h" #include "ppb_instance.h" #include "screensaver_control.h" #include "tables.h" #include "trace_core.h" #include #include #include #include #include #include #include #include #include #include #include #include NPNetscapeFuncs npn; struct display_s display; static GHashTable *pp_to_np_ht; static GHashTable *npobj_to_npp_ht = NULL; // NPObject-to-NPP mapping static PangoContext *pango_ctx = NULL; static PangoFontMap *pango_fm = NULL; static pthread_mutex_t lock; static int urandom_fd = -1; static void __attribute__((constructor)) constructor_tables(void) { // hash tables pp_to_np_ht = g_hash_table_new(g_direct_hash, g_direct_equal); npobj_to_npp_ht = g_hash_table_new(g_direct_hash, g_direct_equal); // pango pango_fm = pango_ft2_font_map_new(); pango_ctx = pango_font_map_create_context(pango_fm); // mutex pthread_mutex_init(&lock, NULL); // urandom urandom_fd = open("/dev/urandom", O_RDONLY); srand(time(NULL) + 42); } static void __attribute__((destructor)) destructor_tables(void) { // hash tables g_hash_table_unref(pp_to_np_ht); g_hash_table_unref(npobj_to_npp_ht); // pango g_object_unref(pango_ctx); g_object_unref(pango_fm); pango_ctx = NULL; pango_fm = NULL; // mutex pthread_mutex_destroy(&lock); // urandom close(urandom_fd); } int tables_get_urandom_fd(void) { return urandom_fd; } struct pp_instance_s * tables_get_pp_instance(PP_Instance instance) { pthread_mutex_lock(&lock); struct pp_instance_s *pp_i = g_hash_table_lookup(pp_to_np_ht, GINT_TO_POINTER(instance)); pthread_mutex_unlock(&lock); return pp_i; } void tables_add_pp_instance(PP_Instance instance, struct pp_instance_s *pp_i) { pthread_mutex_lock(&lock); g_hash_table_replace(pp_to_np_ht, GINT_TO_POINTER(instance), pp_i); pthread_mutex_unlock(&lock); } void tables_remove_pp_instance(PP_Instance instance) { pthread_mutex_lock(&lock); g_hash_table_remove(pp_to_np_ht, GINT_TO_POINTER(instance)); pthread_mutex_unlock(&lock); } struct pp_instance_s * tables_get_some_pp_instance(void) { GHashTableIter iter; gpointer key, value; gpointer result = NULL; pthread_mutex_lock(&lock); g_hash_table_iter_init (&iter, pp_to_np_ht); while (g_hash_table_iter_next(&iter, &key, &value)) { struct pp_instance_s *pp_i = value; if (pp_i && pp_i->npp) result = value; } pthread_mutex_unlock(&lock); return result; } PangoContext * tables_get_pango_ctx(void) { return pango_ctx; } PangoFontMap * tables_get_pango_font_map(void) { return pango_fm; } void tables_add_npobj_npp_mapping(NPObject *npobj, NPP npp) { pthread_mutex_lock(&lock); g_hash_table_insert(npobj_to_npp_ht, npobj, npp); pthread_mutex_unlock(&lock); } NPP tables_get_npobj_npp_mapping(NPObject *npobj) { pthread_mutex_lock(&lock); NPP npp = g_hash_table_lookup(npobj_to_npp_ht, npobj); pthread_mutex_unlock(&lock); return npp; } void tables_remove_npobj_npp_mapping(NPObject *npobj) { pthread_mutex_lock(&lock); g_hash_table_remove(npobj_to_npp_ht, npobj); pthread_mutex_unlock(&lock); } static void check_glx_extensions(void) { const char *glx_ext_str = glXQueryExtensionsString(display.x, 0); if (!glx_ext_str) return; display.glx_arb_create_context = !!strstr(glx_ext_str, "GLX_ARB_create_context"); display.glx_arb_create_context_profile = !!strstr(glx_ext_str, "GLX_ARB_create_context_profile"); display.glx_ext_create_context_es2_profile = !!strstr(glx_ext_str, "GLX_EXT_create_context_es2_profile"); display.glXCreateContextAttribsARB = (glx_create_context_attribs_arb_f) glXGetProcAddressARB((const GLubyte *)"glXCreateContextAttribsARB"); display.glXBindTexImageEXT = (glx_bind_tex_image_ext_f) glXGetProcAddress((GLubyte *)"glXBindTexImageEXT"); display.glXReleaseTexImageEXT = (glx_release_tex_image_ext_f) glXGetProcAddress((GLubyte *)"glXReleaseTexImageEXT"); display.glXGetVideoSyncSGI = (glx_get_video_sync_sgi_f) glXGetProcAddress((GLubyte *)"glXGetVideoSyncSGI"); display.glXWaitVideoSyncSGI = (glx_wait_video_sync_sgi_f) glXGetProcAddress((GLubyte *)"glXWaitVideoSyncSGI"); } #if HAVE_HWDEC static void * get_proc_helper(VdpFuncId func_id) { void *func = NULL; if (display.vdp_get_proc_address(display.vdp_device, func_id, &func) != VDP_STATUS_OK) { trace_error("%s, can't get VDPAU function %d address\n", __func__, (int)func_id); func = NULL; } return func; } static void initialize_vaapi(void) { VAStatus st; int major, minor; display.va = vaGetDisplay(display.x); st = vaInitialize(display.va, &major, &minor); if (st == VA_STATUS_SUCCESS) { trace_info_f("libva version %d.%d\n", major, minor); trace_info_f("libva driver vendor: %s\n", vaQueryVendorString(display.va)); display.va_available = 1; } else { trace_info_f("%s, failed to initialize VA device, %d, %s\n", __func__, (int)st, vaErrorStr(st)); trace_info_f("%s, no VA-API available\n", __func__); } } static void deinitialize_vaapi(void) { if (display.va) vaTerminate(display.va); display.va = NULL; } static void initialize_vdpau(void) { VdpStatus st; display.vdp_device = VDP_INVALID_HANDLE; st = vdp_device_create_x11(display.x, DefaultScreen(display.x), &display.vdp_device, &display.vdp_get_proc_address); if (st == VDP_STATUS_OK && display.vdp_get_proc_address) { display.vdp_get_error_string = get_proc_helper(VDP_FUNC_ID_GET_ERROR_STRING); display.vdp_get_information_string = get_proc_helper(VDP_FUNC_ID_GET_INFORMATION_STRING); display.vdp_device_destroy = get_proc_helper(VDP_FUNC_ID_DEVICE_DESTROY); display.vdp_decoder_create = get_proc_helper(VDP_FUNC_ID_DECODER_CREATE); display.vdp_decoder_destroy = get_proc_helper(VDP_FUNC_ID_DECODER_DESTROY); display.vdp_decoder_render = get_proc_helper(VDP_FUNC_ID_DECODER_RENDER); display.vdp_video_surface_create = get_proc_helper(VDP_FUNC_ID_VIDEO_SURFACE_CREATE); display.vdp_video_surface_destroy = get_proc_helper(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY); display.vdp_presentation_queue_target_create_x11 = get_proc_helper(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11); display.vdp_presentation_queue_target_destroy = get_proc_helper(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY); display.vdp_presentation_queue_create = get_proc_helper(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE); display.vdp_presentation_queue_destroy = get_proc_helper(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY); display.vdp_presentation_queue_display = get_proc_helper(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY); display.vdp_output_surface_create = get_proc_helper(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE); display.vdp_output_surface_destroy = get_proc_helper(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY); display.vdp_video_mixer_create = get_proc_helper(VDP_FUNC_ID_VIDEO_MIXER_CREATE); display.vdp_video_mixer_destroy = get_proc_helper(VDP_FUNC_ID_VIDEO_MIXER_DESTROY); display.vdp_video_mixer_render = get_proc_helper(VDP_FUNC_ID_VIDEO_MIXER_RENDER); if (display.vdp_get_error_string && display.vdp_get_information_string && display.vdp_device_destroy && display.vdp_decoder_create && display.vdp_decoder_destroy && display.vdp_decoder_render && display.vdp_video_surface_create && display.vdp_video_surface_destroy && display.vdp_presentation_queue_target_create_x11 && display.vdp_presentation_queue_target_destroy && display.vdp_presentation_queue_create && display.vdp_presentation_queue_destroy && display.vdp_presentation_queue_display && display.vdp_output_surface_create && display.vdp_output_surface_destroy && display.vdp_video_mixer_create && display.vdp_video_mixer_destroy && display.vdp_video_mixer_render) { display.vdpau_available = 1; const char *info_str; if (display.vdp_get_information_string(&info_str) == VDP_STATUS_OK) trace_info_f("VDPAU driver: %s\n", info_str); else trace_error("%s, failed to get VDPAU driver version\n", __func__); } else { trace_error("%s, some essential VDPAU functions missing\n", __func__); } } else { trace_info_f("%s, failed to initialize VDPAU device, no VDPAU available\n", __func__); } } static void deinitialize_vdpau(void) { if (display.vdp_device_destroy && display.vdp_device != VDP_INVALID_HANDLE) { display.vdp_device_destroy(display.vdp_device); display.vdp_device = VDP_INVALID_HANDLE; } } #endif // HAVE_HWDEC int tables_open_display(void) { int retval = 0; int major, minor; pthread_mutexattr_init(&display.mutex_attr_recursive); pthread_mutexattr_settype(&display.mutex_attr_recursive, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&display.lock, &display.mutex_attr_recursive); pthread_mutex_lock(&display.lock); display.x = XOpenDisplay(NULL); if (!display.x) { trace_error("%s, can't open X Display\n", __func__); retval = 1; goto quit; } if (config.quirks.x_synchronize) XSynchronize(display.x, True); display.dri_fd = open("/dev/dri/card0", O_RDWR); #if HAVE_HWDEC display.va_available = 0; display.vdpau_available = 0; if (config.enable_hwdec) { if (config.enable_vaapi) initialize_vaapi(); if (config.enable_vdpau) initialize_vdpau(); } #endif // HAVE_HWDEC if (!glXQueryVersion(display.x, &major, &minor)) { trace_error("%s, glXQueryVersion returned False\n", __func__); } else { trace_info_f("GLX version %d.%d\n", major, minor); } check_glx_extensions(); // initialize screensaver inhibition library screensaver_connect(); display.screensaver_types = screensaver_type_detect(display.x); gchar *s = g_strdup_printf("screensavers found:%s%s%s%s%s", (display.screensaver_types & SST_XSCREENSAVER) ? " XScreenSaver" : "", (display.screensaver_types & SST_FDO_SCREENSAVER) ? " fd.o-screensaver" : "", (display.screensaver_types & SST_CINNAMON_SCREENSAVER) ? " cinnamon-screensaver" : "", (display.screensaver_types & SST_GNOME_SCREENSAVER) ? " gnome-screensaver" : "", (display.screensaver_types & SST_KDE_SCREENSAVER) ? " kscreensaver" : ""); trace_info_f("%s\n", s); g_free(s); // create transparent cursor const char t_pixmap_data = 0; XColor t_color = {}; Pixmap t_pixmap = XCreateBitmapFromData(display.x, DefaultRootWindow(display.x), &t_pixmap_data, 1, 1); display.transparent_cursor = XCreatePixmapCursor(display.x, t_pixmap, t_pixmap, &t_color, &t_color, 0, 0); XFreePixmap(display.x, t_pixmap); // determine minimal size across all screens display.min_width = (uint32_t)-1; display.min_height = (uint32_t)-1; XRRScreenResources *sr = XRRGetScreenResources(display.x, DefaultRootWindow(display.x)); if (sr) { for (int k = 0; k < sr->ncrtc; k ++) { XRRCrtcInfo *ci = XRRGetCrtcInfo(display.x, sr, sr->crtcs[k]); if (ci && ci->width > 0 && ci->height > 0) { display.min_width = MIN(display.min_width, ci->width); display.min_height = MIN(display.min_height, ci->height); } if (ci) XRRFreeCrtcInfo(ci); } XRRFreeScreenResources(sr); } if (display.min_width == (uint32_t)-1 || display.min_height == (uint32_t)-1) { display.min_width = 300; display.min_height = 300; } // apply size override from the configuration file if (config.fullscreen_width > 0) display.min_width = config.fullscreen_width; if (config.fullscreen_height > 0) display.min_height = config.fullscreen_height; int xrender_event_base, xrender_error_base; if (XRenderQueryExtension(display.x, &xrender_event_base, &xrender_error_base)) { trace_info_f("found XRender\n"); display.have_xrender = 1; } else { trace_info_f("no XRender available\n"); display.have_xrender = 0; } if (!config.enable_xrender) { trace_info_f("XRender is disabled\n"); display.have_xrender = 0; } if (display.have_xrender) { display.pictfmt_rgb24 = XRenderFindStandardFormat(display.x, PictStandardRGB24); display.pictfmt_argb32 = XRenderFindStandardFormat(display.x, PictStandardARGB32); } quit: pthread_mutex_unlock(&display.lock); return retval; } void tables_close_display(void) { pthread_mutex_lock(&display.lock); screensaver_disconnect(); #if HAVE_HWDEC if (config.enable_hwdec) { if (config.enable_vaapi) deinitialize_vaapi(); if (config.enable_vdpau) deinitialize_vdpau(); } #endif // HAVE_HWDEC close(display.dri_fd); display.dri_fd = -1; XFreeCursor(display.x, display.transparent_cursor); XCloseDisplay(display.x); pthread_mutex_unlock(&display.lock); pthread_mutex_destroy(&display.lock); pthread_mutexattr_destroy(&display.mutex_attr_recursive); } PP_Instance tables_generate_new_pp_instance_id(void) { static int32_t instance_id = 10; pthread_mutex_lock(&lock); int32_t result = instance_id++; pthread_mutex_unlock(&lock); return result; } freshplayerplugin-0.3.9/src/tables.h000066400000000000000000000131661321746453100175150ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include "glx.h" #include #include #include #include #include #include #include #include #include #if HAVE_HWDEC #include #include #include #endif // HAVE_HWDEC #define NPString_literal(str) { .UTF8Characters = str, .UTF8Length = strlen(str) } typedef GLXContext (*glx_create_context_attribs_arb_f)(Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); typedef void (*glx_bind_tex_image_ext_f)(Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list); typedef void (*glx_release_tex_image_ext_f)(Display *dpy, GLXDrawable drawable, int buffer); typedef int (*glx_get_video_sync_sgi_f)(unsigned int *count); typedef int (*glx_wait_video_sync_sgi_f)(int divisor, int remainder, unsigned int *count); struct display_s { Display *x; #if HAVE_HWDEC unsigned int va_available; VADisplay va; unsigned int vdpau_available; VdpDevice vdp_device; VdpGetProcAddress *vdp_get_proc_address; VdpGetInformationString *vdp_get_information_string; VdpDeviceDestroy *vdp_device_destroy; VdpGetErrorString *vdp_get_error_string; VdpDecoderCreate *vdp_decoder_create; VdpDecoderDestroy *vdp_decoder_destroy; VdpDecoderRender *vdp_decoder_render; VdpVideoSurfaceCreate *vdp_video_surface_create; VdpVideoSurfaceDestroy *vdp_video_surface_destroy; VdpPresentationQueueTargetCreateX11 *vdp_presentation_queue_target_create_x11; VdpPresentationQueueTargetDestroy *vdp_presentation_queue_target_destroy; VdpPresentationQueueCreate *vdp_presentation_queue_create; VdpPresentationQueueDestroy *vdp_presentation_queue_destroy; VdpPresentationQueueDisplay *vdp_presentation_queue_display; VdpOutputSurfaceCreate *vdp_output_surface_create; VdpOutputSurfaceDestroy *vdp_output_surface_destroy; VdpVideoMixerCreate *vdp_video_mixer_create; VdpVideoMixerDestroy *vdp_video_mixer_destroy; VdpVideoMixerRender *vdp_video_mixer_render; #endif // HAVE_HWDEC Cursor transparent_cursor; pthread_mutexattr_t mutex_attr_recursive; pthread_mutex_t lock; uint32_t have_xrender; XRenderPictFormat *pictfmt_rgb24; XRenderPictFormat *pictfmt_argb32; uint32_t min_width; ///< smallest screen width uint32_t min_height; ///< smallest screen height uint32_t screensaver_types; glx_create_context_attribs_arb_f glXCreateContextAttribsARB; glx_bind_tex_image_ext_f glXBindTexImageEXT; glx_release_tex_image_ext_f glXReleaseTexImageEXT; glx_get_video_sync_sgi_f glXGetVideoSyncSGI; glx_wait_video_sync_sgi_f glXWaitVideoSyncSGI; uint32_t glx_arb_create_context; uint32_t glx_arb_create_context_profile; uint32_t glx_ext_create_context_es2_profile; int dri_fd; }; extern NPNetscapeFuncs npn; extern struct display_s display; int tables_get_urandom_fd(void); struct pp_instance_s *tables_get_pp_instance(PP_Instance instance); void tables_add_pp_instance(PP_Instance instance, struct pp_instance_s *pp_i); void tables_remove_pp_instance(PP_Instance instance); struct pp_instance_s *tables_get_some_pp_instance(void); PP_Instance tables_generate_new_pp_instance_id(void); PangoContext *tables_get_pango_ctx(void); PangoFontMap *tables_get_pango_font_map(void); void tables_add_npobj_npp_mapping(NPObject *npobj, NPP npp); NPP tables_get_npobj_npp_mapping(NPObject *npobj); void tables_remove_npobj_npp_mapping(NPObject *npobj); int tables_open_display(void); void tables_close_display(void); freshplayerplugin-0.3.9/src/trace_core.c000066400000000000000000000054061321746453100203420ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "config.h" #include "trace_core.h" #include #include #include #include #include #include static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; static __thread struct timespec tictoc_ts; void trace_info(const char *fmt, ...) { if (config.quiet) return; if (config.quirks.avoid_stdout) return; pthread_mutex_lock(&lock); va_list args; // fprintf(stdout, "[fresh] "); fprintf(stdout, "[fresh %5d] ", (int)syscall(__NR_gettid)); va_start(args, fmt); vfprintf(stdout, fmt, args); va_end(args); pthread_mutex_unlock(&lock); } void trace_warning(const char *fmt, ...) { if (config.quirks.avoid_stdout) return; pthread_mutex_lock(&lock); va_list args; fprintf(stdout, "[fresh] [warning] "); va_start(args, fmt); vfprintf(stdout, fmt, args); va_end(args); pthread_mutex_unlock(&lock); } void trace_error(const char *fmt, ...) { pthread_mutex_lock(&lock); va_list args; fprintf(stderr, "[fresh] [error] "); va_start(args, fmt); vfprintf(stderr, fmt, args); va_end(args); if (!config.quirks.avoid_stdout) { fprintf(stdout, "[fresh] [error] "); va_start(args, fmt); vfprintf(stdout, fmt, args); va_end(args); } pthread_mutex_unlock(&lock); } void trace_duration_tic(void) { clock_gettime(CLOCK_REALTIME, &tictoc_ts); } double trace_duration_toc(void) { struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); return (ts.tv_sec - tictoc_ts.tv_sec) + 1e-9 * (ts.tv_nsec - tictoc_ts.tv_nsec); } freshplayerplugin-0.3.9/src/trace_core.h000066400000000000000000000040341321746453100203430ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #define TRACE_WRAPPER static __attribute__((unused)) // trace non-implemeted or partially implemented function based on build type #ifndef NDEBUG // debug build have tracing enabled #define TWRAPZ(fname) trace_##fname #else #define TWRAPZ(fname) fname #endif // trace implemented function only if TRACE_ALL defined #ifdef TRACE_ALL #define TWRAPF(fname) trace_##fname #define trace_info_f(...) trace_info(__VA_ARGS__) #else #define TWRAPF(fname) fname #define trace_info_f(...) #endif #define trace_info_z(...) trace_info(__VA_ARGS__) void trace_info(const char *fmt, ...) __attribute__((format (printf, 1, 2))); void trace_warning(const char *fmt, ...) __attribute__((format (printf, 1, 2))); void trace_error(const char *fmt, ...) __attribute__((format (printf, 1, 2))); void trace_duration_tic(void); double trace_duration_toc(void); freshplayerplugin-0.3.9/src/trace_helpers.c000066400000000000000000000270151321746453100210540ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "ppb_var.h" #include "trace_helpers.h" #include #include #include #include #include #include #include static char * dictionary_var_to_string(struct PP_Var dict) { if (dict.type != PP_VARTYPE_DICTIONARY) return g_strdup("{}"); GString *s = g_string_new("{"); int first = 1; struct PP_Var keys = ppb_var_dictionary_get_keys(dict); const uint32_t count = ppb_var_array_get_length(keys); for (uint32_t k = 0; k < count; k ++) { struct PP_Var key = ppb_var_array_get(keys, k); struct PP_Var val = ppb_var_dictionary_get(dict, key); if (!first) g_string_append(s, ","); first = 0; char *s_key = trace_var_as_string(key); char *s_val = trace_var_as_string(val); g_string_append_printf(s, "%s:%s", s_key, s_val); g_free(s_key); g_free(s_val); ppb_var_release(key); ppb_var_release(val); } g_string_append(s, "}"); return g_string_free(s, FALSE); } char * trace_var_as_string(struct PP_Var var) { char *res = NULL; const char *tmp; char *s_dict; int ref_count; switch (var.type) { case PP_VARTYPE_UNDEFINED: res = g_strdup_printf("{UNDEFINED}"); break; case PP_VARTYPE_NULL: res = g_strdup_printf("{NULL}"); break; case PP_VARTYPE_BOOL: res = g_strdup_printf("{BOOL:%s}", var.value.as_int ? "TRUE" : "FALSE"); break; case PP_VARTYPE_INT32: res = g_strdup_printf("{INT32:%d}", var.value.as_int); break; case PP_VARTYPE_DOUBLE: res = g_strdup_printf("{DOUBLE:%f}", var.value.as_double); break; case PP_VARTYPE_STRING: tmp = ppb_var_var_to_utf8(var, NULL); ref_count = ppb_var_get_ref_count(var); res = g_strdup_printf("{STRING:%d:%p:%s}", ref_count, tmp, tmp); break; case PP_VARTYPE_OBJECT: res = ppb_var_trace_object_var(var); break; case PP_VARTYPE_ARRAY: ref_count = ppb_var_get_ref_count(var); res = g_strdup_printf("{ARRAY:%d:%"PRId64"}", ref_count, var.value.as_id); break; case PP_VARTYPE_DICTIONARY: s_dict = dictionary_var_to_string(var); ref_count = ppb_var_get_ref_count(var); res = g_strdup_printf("{DICTIONARY:%d:%"PRId64":%s}", ref_count, var.value.as_id, s_dict); g_free(s_dict); break; case PP_VARTYPE_ARRAY_BUFFER: ref_count = ppb_var_get_ref_count(var); res = g_strdup_printf("{ARRAY_BUFFER:%d}", ref_count); break; case PP_VARTYPE_RESOURCE: ref_count = ppb_var_get_ref_count(var); res = g_strdup_printf("{RESOURCE:%d}", ref_count); break; default: res = g_strdup_printf("{NOTIMPLEMENTED:%d}", var.type); break; } return res; } char * trace_rect_as_string(const struct PP_Rect *rect) { char *res = NULL; if (rect) { res = g_strdup_printf("{.x=%d, .y=%d, .w=%d, .h=%d}", rect->point.x, rect->point.y, rect->size.width, rect->size.height); } else { res = g_strdup_printf("(nil)"); } return res; } char * trace_size_as_string(const struct PP_Size *size) { char *res = NULL; if (size) { res = g_strdup_printf("{.w=%d, .h=%d}", size->width, size->height); } else { res = g_strdup_printf("(nil)"); } return res; } char * trace_point_as_string(const struct PP_Point *point) { char *res = NULL; if (point) res = g_strdup_printf("{.x=%d, .y=%d}", point->x, point->y); else res = g_strdup_printf("(nil)"); return res; } char * trace_float_point_as_string(const struct PP_FloatPoint *point) { char *res = NULL; if (point) res = g_strdup_printf("{.x=%f, .y=%f}", point->x, point->y); else res = g_strdup_printf("(nil)"); return res; } char * trace_touch_point_as_string(const struct PP_TouchPoint *point) { char *res = NULL; if (point) { char *s_position = trace_float_point_as_string(&point->position); char *s_radius = trace_float_point_as_string(&point->radius); res = g_strdup_printf("{.id=%u, .position=%s, .radius=%s, .rotation_angle=%f, .presure=%f}", point->id, s_position, s_radius, point->rotation_angle, point->pressure); g_free(s_position); g_free(s_radius); } else { res = g_strdup_printf("(nil)"); } return res; } char * trace_np_window_as_string(const NPWindow *window) { char *res = NULL; if (window) { res = g_strdup_printf("{.window=%p, .x=%u, .y=%u, .width=%u, .height=%u, " ".clipRect={.top=%u, .left=%u, .bottom=%u, .right=%u}, .ws_info=%p, " ".type=%d}", window->window, window->x, window->y, window->width, window->height, window->clipRect.top, window->clipRect.left, window->clipRect.bottom, window->clipRect.right, window->ws_info, window->type); } else { res = g_strdup_printf("(nil)"); } return res; } char * trace_event_classes_as_string(uint32_t ec) { int req_len = 0; char *res; req_len += (ec & PP_INPUTEVENT_CLASS_MOUSE) ? strlen("MOUSE|") : 0; req_len += (ec & PP_INPUTEVENT_CLASS_KEYBOARD) ? strlen("KEYBOARD|") : 0; req_len += (ec & PP_INPUTEVENT_CLASS_WHEEL) ? strlen("WHEEL|") : 0; req_len += (ec & PP_INPUTEVENT_CLASS_TOUCH) ? strlen("TOUCH|") : 0; req_len += (ec & PP_INPUTEVENT_CLASS_IME) ? strlen("IME|") : 0; req_len += 1; res = malloc(req_len); strcpy(res, ""); if (ec & PP_INPUTEVENT_CLASS_MOUSE) strcat(res, "MOUSE|"); if (ec & PP_INPUTEVENT_CLASS_KEYBOARD) strcat(res, "KEYBOARD|"); if (ec & PP_INPUTEVENT_CLASS_WHEEL) strcat(res, "WHEEL|"); if (ec & PP_INPUTEVENT_CLASS_TOUCH) strcat(res, "TOUCH|"); if (ec & PP_INPUTEVENT_CLASS_IME) strcat(res, "IME|"); // delete trailing '|' if (strlen(res) > 0) res[strlen(res) - 1] = 0; return res; } char * trace_graphics3d_attributes_as_string(const int32_t attrib_list[]) { GString *s = g_string_new("{"); int k = 0; int done = 0; while (!done) { switch (attrib_list[k]) { case PP_GRAPHICS3DATTRIB_ALPHA_SIZE: g_string_append_printf(s, "ALPHA=%d, ", attrib_list[k + 1]); k += 2; break; case PP_GRAPHICS3DATTRIB_BLUE_SIZE: g_string_append_printf(s, "BLUE=%d, ", attrib_list[k + 1]); k += 2; break; case PP_GRAPHICS3DATTRIB_GREEN_SIZE: g_string_append_printf(s, "GREEN=%d, ", attrib_list[k + 1]); k += 2; break; case PP_GRAPHICS3DATTRIB_RED_SIZE: g_string_append_printf(s, "RED=%d, ", attrib_list[k + 1]); k += 2; break; case PP_GRAPHICS3DATTRIB_DEPTH_SIZE: g_string_append_printf(s, "DEPTH=%d, ", attrib_list[k + 1]); k += 2; break; case PP_GRAPHICS3DATTRIB_STENCIL_SIZE: g_string_append_printf(s, "STENCIL=%d, ", attrib_list[k + 1]); k += 2; break; case PP_GRAPHICS3DATTRIB_SAMPLES: g_string_append_printf(s, "SAMPLES=%d, ", attrib_list[k + 1]); k += 2; break; case PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS: g_string_append_printf(s, "SAMPLE_BUFFERS=%d, ", attrib_list[k + 1]); k += 2; break; case PP_GRAPHICS3DATTRIB_NONE: done = 1; break; case PP_GRAPHICS3DATTRIB_HEIGHT: g_string_append_printf(s, "HEIGHT=%d, ", attrib_list[k + 1]); k += 2; break; case PP_GRAPHICS3DATTRIB_WIDTH: g_string_append_printf(s, "WIDTH=%d, ", attrib_list[k + 1]); k += 2; break; case PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR: switch (attrib_list[k + 1]) { case PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED: g_string_append(s, "SWAP_BEHAVIOR=BUFFER_PRESERVED, "); break; case PP_GRAPHICS3DATTRIB_BUFFER_DESTROYED: g_string_append(s, "SWAP_BEHAVIOR=BUFFER_DESTROYED, "); break; default: g_string_append_printf(s, "SWAP_BEHAVIOR=unknown(0x%04x), ", attrib_list[k + 1]); break; } k += 2; break; case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE: switch (attrib_list[k + 1]) { case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_LOW_POWER: g_string_append(s, "GPU_PREFERENCE=LOW_POWER, "); break; case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_PERFORMANCE: g_string_append(s, "GPU_PREFERENCE=PERFORMANCE, "); break; default: g_string_append_printf(s, "GPU_PREFERENCE=unknown(0x%04x), ", attrib_list[k + 1]); break; } k += 2; break; default: g_string_append_printf(s, "unknown(0x%04x), ", attrib_list[k]); k += 1; break; } } // delete trailing if (s->len >= 3) g_string_truncate(s, s->len - 2); g_string_append(s, "}"); // return combined string return g_string_free(s, FALSE); } char * trace_netaddress_ipv4_as_string(const struct PP_NetAddress_IPv4 *addr) { if (!addr) return g_strdup_printf("(nil)"); return g_strdup_printf("%u.%u.%u.%u:%u", addr->addr[0], addr->addr[1], addr->addr[2], addr->addr[3], ntohs(addr->port)); } char * trace_netaddress_ipv6_as_string(const struct PP_NetAddress_IPv6 *addr) { if (!addr) return g_strdup_printf("(nil)"); return g_strdup_printf("[%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:" "%02x%02x]:%u", addr->addr[0], addr->addr[1], addr->addr[2], addr->addr[3], addr->addr[4], addr->addr[5], addr->addr[6], addr->addr[7], addr->addr[8], addr->addr[9], addr->addr[10], addr->addr[11], addr->addr[12], addr->addr[13], addr->addr[14], addr->addr[15], ntohs(addr->port)); } freshplayerplugin-0.3.9/src/trace_helpers.h000066400000000000000000000040251321746453100210550ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include #include #include #include char *trace_var_as_string(struct PP_Var var); char *trace_size_as_string(const struct PP_Size *size); char *trace_rect_as_string(const struct PP_Rect *rect); char *trace_point_as_string(const struct PP_Point *point); char *trace_float_point_as_string(const struct PP_FloatPoint *point); char *trace_touch_point_as_string(const struct PP_TouchPoint *point); char *trace_event_classes_as_string(uint32_t event_classes); char *trace_np_window_as_string(const NPWindow *window); char *trace_graphics3d_attributes_as_string(const int32_t attrib_list[]); char *trace_netaddress_ipv4_as_string(const struct PP_NetAddress_IPv4 *addr); char *trace_netaddress_ipv6_as_string(const struct PP_NetAddress_IPv6 *addr); freshplayerplugin-0.3.9/src/uri_parser/000077500000000000000000000000001321746453100202365ustar00rootroot00000000000000freshplayerplugin-0.3.9/src/uri_parser/CMakeLists.txt000066400000000000000000000010041321746453100227710ustar00rootroot00000000000000set(URI_PARSER_FSM_C "${CMAKE_CURRENT_BINARY_DIR}/uri_parser_fsm.c") include_directories("${CMAKE_CURRENT_BINARY_DIR}") add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/uri_parser_fsm.c" DEPENDS uri_parser_fsm.rl COMMAND "${RAGEL}" ARGS -G2 "${CMAKE_CURRENT_SOURCE_DIR}/uri_parser_fsm.rl" -o "${URI_PARSER_FSM_C}" VERBATIM ) add_custom_target(generate_fsm DEPENDS "${URI_PARSER_FSM_C}") add_library(uri-parser-obj OBJECT uri_parser.c ) add_dependencies(uri-parser-obj generate_fsm) freshplayerplugin-0.3.9/src/uri_parser/uri_parser.c000066400000000000000000000230621321746453100225600ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "../compat.h" #include "uri_parser.h" #include #include #include typedef struct { int len; char *data; } str_t; static void set_url_component(struct PP_URLComponent_Dev *c, const char *s, const char *b, const char *e) { c->begin = b - s; c->len = e - b; } static void reset_url_component(struct PP_URLComponent_Dev *c) { c->begin = 0; c->len = -1; } static void reset_url_components(struct PP_URLComponents_Dev *c) { reset_url_component(&c->scheme); reset_url_component(&c->username); reset_url_component(&c->password); reset_url_component(&c->host); reset_url_component(&c->port); reset_url_component(&c->path); reset_url_component(&c->query); reset_url_component(&c->ref); } void uri_parser_parse_uri(const char *s, struct PP_URLComponents_Dev *components) { const char *p = s; const char *pe = s + strlen(s); const char *eof = pe; struct { const char *scheme; const char *username; const char *password; const char *host; const char *port; const char *path; const char *query; const char *fragment; } mark; const char *end_username = NULL, *end_password = NULL; int cs; struct PP_URLComponents_Dev c2; reset_url_components(components); reset_url_components(&c2); memset(&mark, 0, sizeof(mark)); #include // silence unused-variable warnings (void)uri_parser_en_main; (void)uri_parser_error; (void)uri_parser_first_final; (void)end_password; (void)end_username; } static inline int urlcomponent_is_empty(const struct PP_URLComponent_Dev *c) { return c->begin == 0 && c->len == -1; } static inline int urlcomponent_is_not_empty(const struct PP_URLComponent_Dev *c) { return !urlcomponent_is_empty(c); } static inline int authority_is_not_empty(const struct PP_URLComponents_Dev *c) { return urlcomponent_is_not_empty(&c->username) || urlcomponent_is_not_empty(&c->password) || urlcomponent_is_not_empty(&c->host) || urlcomponent_is_not_empty(&c->port); } static str_t extract_component(const char *s, const struct PP_URLComponent_Dev *c) { str_t res; res.data = (char *)s + c->begin; res.len = (c->len >= 0) ? c->len : 0; return res; } static str_t extract_authority(const char *s, struct PP_URLComponents_Dev *c) { int32_t begin = 0; if (c->port.len >= 0) begin = c->port.begin; if (c->host.len >= 0) begin = c->host.begin; if (c->password.len >= 0) begin = c->password.begin; if (c->username.len >= 0) begin = c->username.begin; int32_t end = -1; if (c->username.len >= 0) end = c->username.begin + c->username.len; if (c->password.len >= 0) end = c->password.begin + c->password.len; if (c->host.len >= 0) end = c->host.begin + c->host.len; if (c->port.len >= 0) end = c->port.begin + c->port.len; struct PP_URLComponent_Dev cc = { .begin = begin, .len = end - begin }; return extract_component(s, &cc); } static str_t merge_path(const char *base_uri, const struct PP_URLComponents_Dev *base_c, const char *rel_uri, const struct PP_URLComponents_Dev *rel_c, GList **m) { gchar *s; str_t rel_path = extract_component(rel_uri, &rel_c->path); if (base_c->host.len > 0 && base_c->path.len <= 0) { s = g_strdup_printf("/%.*s", rel_path.len, rel_path.data); } else { str_t base_path = extract_component(base_uri, &base_c->path); int len = base_path.len; while (len > 0 && base_path.data[len - 1] != '/') len --; s = g_strdup_printf("%.*s%.*s", len, base_path.data, rel_path.len, rel_path.data); } *m = g_list_prepend(*m, s); return (str_t){ .data = s, .len = strlen(s) }; } static str_t remove_dot_segments(str_t s, GList **m) { // make a working copy str_t res; res.data = g_strndup(s.data, s.len); res.len = strlen(res.data); *m = g_list_prepend(*m, res.data); int pdst = 0; int dot_cnt = 0; int after_slash = 1; for (int psrc = 0; psrc < s.len; psrc ++) { char c = s.data[psrc]; switch (c) { case '/': if (dot_cnt == 1 || dot_cnt == 2) { for (int k = 0; k < dot_cnt; k ++) { while (pdst > 0 && res.data[pdst - 1] != '/') pdst --; if (pdst > 0) pdst --; } } res.data[pdst++] = '/'; dot_cnt = 0; after_slash = 1; break; case '.': res.data[pdst++] = '.'; if (after_slash) dot_cnt ++; break; default: dot_cnt = 0; after_slash = 0; res.data[pdst++] = c; break; } } // treat trailing "/.." and "/." if (after_slash && (dot_cnt == 1 || dot_cnt == 2)) { for (int k = 0; k < dot_cnt; k ++) { while (pdst > 0 && res.data[pdst - 1] != '/') pdst --; if (pdst > 0) pdst --; } res.data[pdst++] = '/'; } res.len = pdst; return res; } gchar * uri_parser_merge_uris(const char *base_uri, const char *rel_uri) { struct PP_URLComponents_Dev base_c, rel_c; str_t scheme, authority, path, query, fragment; GList *m = NULL; // list of allocated memory blocks int scheme_is_file = 0; uri_parser_parse_uri(base_uri, &base_c); // if base_uri is local file, remove heading slashed from rel_uri to make it relative. // That will emulate webserver root if (base_c.scheme.len > 0 && strncmp(base_uri + base_c.scheme.begin, "file", 4) == 0 && base_c.scheme.len == 4) { scheme_is_file = 1; while (rel_uri && *rel_uri == '/') rel_uri ++; } uri_parser_parse_uri(rel_uri, &rel_c); // See RFC 3986, 5.2. Relative Resolution if (urlcomponent_is_not_empty(&rel_c.scheme)) { scheme = extract_component(rel_uri, &rel_c.scheme); authority = extract_authority(rel_uri, &rel_c); path = extract_component(rel_uri, &rel_c.path); path = remove_dot_segments(path, &m); query = extract_component(rel_uri, &rel_c.query); } else { if (authority_is_not_empty(&rel_c)) { authority = extract_authority(rel_uri, &rel_c); path = extract_component(rel_uri, &rel_c.path); path = remove_dot_segments(path, &m); query = extract_component(rel_uri, &rel_c.query); } else { if (rel_c.path.len <= 0) { path = extract_component(base_uri, &base_c.path); if (urlcomponent_is_not_empty(&rel_c.query)) { query = extract_component(rel_uri, &rel_c.query); } else { query = extract_component(base_uri, &base_c.query); } } else { if (rel_c.path.len > 0 && rel_uri[rel_c.path.begin] == '/') { path = extract_component(rel_uri, &rel_c.path); path = remove_dot_segments(path, &m); } else { path = merge_path(base_uri, &base_c, rel_uri, &rel_c, &m); path = remove_dot_segments(path, &m); } query = extract_component(rel_uri, &rel_c.query); } authority = extract_authority(base_uri, &base_c); } scheme = extract_component(base_uri, &base_c.scheme); } fragment = extract_component(rel_uri, &rel_c.ref); gchar *res = g_strdup_printf( "%.*s" // scheme "%s" // ":" if scheme is defined "%s" // "//" if authority is defined "%.*s" // authority "%.*s" // path "%s" // "?" if query is defined "%.*s" // query "%s" // "#" if fragment is defined "%.*s", // fragment scheme.len, scheme.data, scheme.len > 0 ? ":" : "", (authority.len > 0 || scheme_is_file) ? "//" : "", authority.len, authority.data, path.len, path.data, query.len > 0 ? "?" : "", query.len, query.data, fragment.len > 0 ? "#" : "", fragment.len, fragment.data); // free temporary strings g_list_free_full(m, g_free); return res; } freshplayerplugin-0.3.9/src/uri_parser/uri_parser.h000066400000000000000000000025751321746453100225730ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include void uri_parser_parse_uri(const char *s, struct PP_URLComponents_Dev *components); gchar * uri_parser_merge_uris(const char *base_uri, const char *rel_uri); freshplayerplugin-0.3.9/src/uri_parser/uri_parser_fsm.rl000066400000000000000000000060761321746453100236260ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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. */ // URI parsing automaton // TODO: handle IPv6 addresses in "host" field %%{ machine uri_parser; action fin_scheme { set_url_component(&components->scheme, s, mark.scheme, p); } action fin_username { end_username = p; } action fin_password { end_password = p; } action fin_host { set_url_component(&components->host, s, mark.host, p); } action fin_port { set_url_component(&components->port, s, mark.port, p); } action fin_path { set_url_component(&components->path, s, mark.path, p); } action fin_query { set_url_component(&components->query, s, mark.query, p); } action fin_fragment { set_url_component(&components->ref, s, mark.fragment, p); } action fin_userpass { if (mark.username) set_url_component(&components->username, s, mark.username, end_username); if (mark.password) set_url_component(&components->password, s, mark.password, end_password); } scheme = [^:/?#]+ >{mark.scheme = p;} %fin_scheme; username = [^/?#@:]+ >{mark.username = p; end_username = p;} %fin_username; password = [^/?#@]+ >{mark.password = p; end_password = p;} %fin_password; host = [^/?#@:]+ >{mark.host = p;} %fin_host; port = digit+ >{mark.port = p;} %fin_port; path = ([^?#]*) >{mark.path = p;} %fin_path; query = ([^#]*) >{mark.query = p;} %fin_query; fragment = (any*) >{mark.fragment = p;} %fin_fragment; scheme_c = scheme . ":"; userpass = (username . (":" . password)? . "@") %fin_userpass; authority = userpass? . host . (":" . port)?; slashslash_authority = "//" . authority?; qm_query = "?" . query; sharp_fragment = "#" . fragment; main := scheme_c? . slashslash_authority? . path . qm_query? . sharp_fragment?; }%% %%{ write data; write init; write exec; }%% freshplayerplugin-0.3.9/src/utils.h000066400000000000000000000032631321746453100174000ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include #include #define free_and_nullify(item) \ do { \ free(item); \ (item) = NULL; \ } while (0) #define nullsafe_strdup(s) ((s) ? strdup(s) : NULL) #define PP_MakeCCB(func, user_data) PP_MakeCompletionCallback(func, user_data) static inline void make_nonblock(int fd) { int flags; flags = fcntl(fd, F_GETFL, 0) | O_NONBLOCK; (void)fcntl(fd, F_SETFL, flags); } freshplayerplugin-0.3.9/src/x11_event_thread.c000066400000000000000000000304041321746453100213710ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 "eintr_retry.h" #include "ppb_instance.h" #include "tables.h" #include "trace_core.h" #include "utils.h" #include "x11_event_thread.h" #include "xembed.h" #include #include #include #include #include #include #include #include static GHashTable *ht = NULL; // Window -> struct ht_entry_s static GHashTable *socket_ht = NULL; // plug_wnd -> socket wnd static Display *dpy = NULL; static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; static pthread_t thread; static uint32_t thread_started = 0; static pthread_barrier_t task_pass_barrier; static Atom xembed_atom; static Atom xembed_info_atom; static int task_pipe[2]; struct ht_entry_s { PP_Instance instance; NPP_HandleEventProcPtr proc; uint32_t is_xembed; Window plug_wnd; }; enum cmd_e { X11ET_CMD_UNDEFINED = 0, X11ET_CMD_REGISTER_WINDOW = 1, X11ET_CMD_UNREGISTER_WINDOW = 2, }; struct task_s { Window socket_wnd; enum cmd_e cmd; }; static void ht_entry_s_free(gpointer data) { g_slice_free1(sizeof(struct ht_entry_s), data); } static void __attribute__((constructor)) constructor_x11_event_thread(void) { ht = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, ht_entry_s_free); socket_ht = g_hash_table_new(g_direct_hash, g_direct_equal); pthread_barrier_init(&task_pass_barrier, NULL, 2); } static void __attribute__((destructor)) destructor_x11_event_thread(void) { g_hash_table_unref(ht); g_hash_table_unref(socket_ht); pthread_barrier_destroy(&task_pass_barrier); } static void send_xembed_message(Display *dpy, Window receiver, long int message, long int detail) { XEvent ev = { .xclient = { .type = ClientMessage, .window = receiver, .message_type = xembed_atom, .format = 32, .data.l[0] = CurrentTime, .data.l[1] = message, .data.l[2] = detail, } }; XSendEvent(dpy, receiver, False, NoEventMask, &ev); XFlush(dpy); } static void call_handle_event_ptac(void *param) { XEvent *ev = param; struct ht_entry_s *d; pthread_mutex_lock(&lock); Window socket_wnd = GPOINTER_TO_SIZE(g_hash_table_lookup(socket_ht, GSIZE_TO_POINTER(ev->xany.window))); d = g_hash_table_lookup(ht, GSIZE_TO_POINTER(socket_wnd)); pthread_mutex_unlock(&lock); if (d && d->proc) { struct pp_instance_s *pp_i = tables_get_pp_instance(d->instance); if (pp_i && pp_i->npp) { ev->xany.display = display.x; d->proc(pp_i->npp, ev); } } g_slice_free1(sizeof(*ev), ev); } static void x11et_handle_task(struct task_s *task) { struct ht_entry_s *entry; pthread_mutex_lock(&lock); entry = g_hash_table_lookup(ht, GSIZE_TO_POINTER(task->socket_wnd)); pthread_mutex_unlock(&lock); if (!entry) return; switch (task->cmd) { case X11ET_CMD_REGISTER_WINDOW: if (entry->is_xembed) { const int screen = DefaultScreen(dpy); XSetWindowAttributes attrs = { .background_pixel = 0x000000, .backing_store = Always, }; entry->plug_wnd = XCreateWindow(dpy, task->socket_wnd, 0, 0, 200, 200, 0, DefaultDepth(dpy, screen), InputOutput, CopyFromParent, CWBackPixel | CWBackingStore, &attrs); unsigned long buffer[2] = { 1, XEMBED_MAPPED }; XChangeProperty(dpy, entry->plug_wnd, xembed_info_atom, xembed_info_atom, 32, PropModeReplace, (unsigned char *)buffer, 2); } pthread_mutex_lock(&lock); g_hash_table_insert(socket_ht, GSIZE_TO_POINTER(entry->plug_wnd), GSIZE_TO_POINTER(task->socket_wnd)); pthread_mutex_unlock(&lock); const long event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | ExposureMask | FocusChangeMask; XSelectInput(dpy, entry->plug_wnd, event_mask); break; case X11ET_CMD_UNREGISTER_WINDOW: XSelectInput(dpy, entry->plug_wnd, 0); XFlush(dpy); if (entry->is_xembed) XDestroyWindow(dpy, entry->plug_wnd); pthread_mutex_lock(&lock); g_hash_table_remove(socket_ht, GSIZE_TO_POINTER(entry->plug_wnd)); pthread_mutex_unlock(&lock); break; default: // should not happen break; } XFlush(dpy); } static void x11et_handle_xevent(void) { XEvent *ev = g_slice_alloc0(sizeof(*ev)); XNextEvent(dpy, ev); Window plug_wnd = ev->xany.window; Window socket_wnd = GPOINTER_TO_SIZE(g_hash_table_lookup(socket_ht, GSIZE_TO_POINTER(plug_wnd))); struct ht_entry_s *d = g_hash_table_lookup(ht, GSIZE_TO_POINTER(socket_wnd)); int skip_event = 0; if (d && d->is_xembed) { switch (ev->type) { case ClientMessage: switch (ev->xclient.data.l[1]) { case XEMBED_EMBEDDED_NOTIFY: skip_event = 1; break; case XEMBED_WINDOW_ACTIVATE: case XEMBED_WINDOW_DEACTIVATE: case XEMBED_MODALITY_ON: case XEMBED_MODALITY_OFF: // not handled skip_event = 1; break; case XEMBED_FOCUS_IN: memset(ev, 0, sizeof(*ev)); ev->xfocus.type = FocusIn; ev->xfocus.window = plug_wnd; ev->xfocus.mode = NotifyNormal; ev->xfocus.detail = NotifyDetailNone; break; case XEMBED_FOCUS_OUT: memset(ev, 0, sizeof(*ev)); ev->xfocus.type = FocusOut; ev->xfocus.window = plug_wnd; ev->xfocus.mode = NotifyNormal; ev->xfocus.detail = NotifyDetailNone; break; default: trace_error("%s, unknown XEmbed message %d\n", __func__, (int)ev->xclient.data.l[1]); skip_event = 1; break; } break; case ButtonPress: send_xembed_message(dpy, socket_wnd, XEMBED_REQUEST_FOCUS, 0); break; case FocusIn: case FocusOut: // native focus events should be skipped if XEmbed is in use skip_event = 1; break; } } if (d && !skip_event) { struct pp_instance_s *pp_i = tables_get_pp_instance(d->instance); if (pp_i && pp_i->npp) npn.pluginthreadasynccall(pp_i->npp, call_handle_event_ptac, ev); else g_slice_free1(sizeof(*ev), ev); } else { g_slice_free1(sizeof(*ev), ev); } } static void * x11_event_thread_func(void *param) { int x11_fd = ConnectionNumber(dpy); struct pollfd fds[2] = { { .fd = task_pipe[0], .events = POLLIN, }, { .fd = x11_fd, .events = POLLIN, }, }; while (1) { int ret = poll(fds, sizeof(fds)/sizeof(fds[0]), -1); if (ret == -1) { trace_error("%s, poll() failed, errno=%d\n", __func__, errno); sleep(1); // relax tight loop continue; } if (fds[0].revents & POLLIN) { // task has come struct task_s task; ret = RETRY_ON_EINTR(read(task_pipe[0], &task, sizeof(task))); if (ret != sizeof(task)) trace_error("%s, read wrong number of bytes from task_fd\n", __func__); x11et_handle_task(&task); pthread_barrier_wait(&task_pass_barrier); continue; } if (fds[1].revents & POLLIN) { x11et_handle_xevent(); continue; } } // TODO: do we need to shutdown thread? close(task_pipe[0]); task_pipe[0] = -1; close(task_pipe[1]); task_pipe[1] = -1; return NULL; } static void x11et_start_thread(void) { dpy = XOpenDisplay(NULL); xembed_atom = XInternAtom(dpy, "_XEMBED", False); xembed_info_atom = XInternAtom(dpy, "_XEMBED_INFO", False); if (pipe(task_pipe) == 0) { make_nonblock(task_pipe[0]); make_nonblock(task_pipe[1]); } else { trace_error("%s, can't create pipe\n", __func__); task_pipe[0] = -1; task_pipe[1] = -1; } pthread_create(&thread, NULL, x11_event_thread_func, NULL); pthread_detach(thread); } Window x11et_register_window(PP_Instance instance, Window wnd, NPP_HandleEventProcPtr handle_event_cb, uint32_t is_xembed) { pthread_mutex_lock(&lock); if (!thread_started) { x11et_start_thread(); thread_started = 1; } struct ht_entry_s *entry = g_hash_table_lookup(ht, GSIZE_TO_POINTER(wnd)); pthread_mutex_unlock(&lock); if (entry) { // already registered return entry->plug_wnd; } entry = g_slice_alloc0(sizeof(*entry)); entry->instance = instance; entry->proc = handle_event_cb; entry->is_xembed = is_xembed; entry->plug_wnd = wnd; pthread_mutex_lock(&lock); g_hash_table_insert(ht, GSIZE_TO_POINTER(wnd), entry); pthread_mutex_unlock(&lock); struct task_s task; memset(&task, 0, sizeof(task)); // ensure all bytes are initialized task.socket_wnd = wnd; task.cmd = X11ET_CMD_REGISTER_WINDOW; if (task_pipe[1] >= 0) { int ret = RETRY_ON_EINTR(write(task_pipe[1], &task, sizeof(task))); if (ret != sizeof(task)) trace_error("%s, can't write to task_pipe\n", __func__); pthread_barrier_wait(&task_pass_barrier); } else { trace_warning("%s, no pipe to send message\n", __func__); } // entry->plug_wnd here will contain plug window if XEmbed is used return entry->plug_wnd; } void x11et_unregister_window(Window wnd) { pthread_mutex_lock(&lock); struct ht_entry_s *entry = g_hash_table_lookup(ht, GSIZE_TO_POINTER(wnd)); pthread_mutex_unlock(&lock); if (!entry) return; struct task_s task; memset(&task, 0, sizeof(task)); // ensure all bytes are initialized task.socket_wnd = wnd; task.cmd = X11ET_CMD_UNREGISTER_WINDOW; if (task_pipe[1] >= 0) { int ret = RETRY_ON_EINTR(write(task_pipe[1], &task, sizeof(task))); if (ret != sizeof(task)) trace_error("%s, can't write to task_pipe\n", __func__); pthread_barrier_wait(&task_pass_barrier); } else { trace_warning("%s, no pipe to send message\n", __func__); } pthread_mutex_lock(&lock); g_hash_table_remove(ht, GSIZE_TO_POINTER(wnd)); pthread_mutex_unlock(&lock); } freshplayerplugin-0.3.9/src/x11_event_thread.h000066400000000000000000000027121321746453100213770ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include #include #include Window x11et_register_window(PP_Instance instance, Window wnd, NPP_HandleEventProcPtr handle_event_cb, uint32_t is_xembed); void x11et_unregister_window(Window wnd); freshplayerplugin-0.3.9/src/xembed.h000066400000000000000000000026471321746453100175110ustar00rootroot00000000000000#pragma once // See http://standards.freedesktop.org/xembed-spec/xembed-spec-latest.html for details /* Flags for _XEMBED_INFO */ #define XEMBED_MAPPED (1 << 0) /* XEMBED messages */ #define XEMBED_EMBEDDED_NOTIFY 0 #define XEMBED_WINDOW_ACTIVATE 1 #define XEMBED_WINDOW_DEACTIVATE 2 #define XEMBED_REQUEST_FOCUS 3 #define XEMBED_FOCUS_IN 4 #define XEMBED_FOCUS_OUT 5 #define XEMBED_FOCUS_NEXT 6 #define XEMBED_FOCUS_PREV 7 /* 8-9 were used for XEMBED_GRAB_KEY/XEMBED_UNGRAB_KEY */ #define XEMBED_MODALITY_ON 10 #define XEMBED_MODALITY_OFF 11 #define XEMBED_REGISTER_ACCELERATOR 12 #define XEMBED_UNREGISTER_ACCELERATOR 13 #define XEMBED_ACTIVATE_ACCELERATOR 14 /* Details for XEMBED_FOCUS_IN: */ #define XEMBED_FOCUS_CURRENT 0 #define XEMBED_FOCUS_FIRST 1 #define XEMBED_FOCUS_LAST 2 /* Modifiers field for XEMBED_REGISTER_ACCELERATOR */ #define XEMBED_MODIFIER_SHIFT (1 << 0) #define XEMBED_MODIFIER_CONTROL (1 << 1) #define XEMBED_MODIFIER_ALT (1 << 2) #define XEMBED_MODIFIER_SUPER (1 << 3) #define XEMBED_MODIFIER_HYPER (1 << 4) /* Flags for XEMBED_ACTIVATE_ACCELERATOR */ #define XEMBED_ACCELERATOR_OVERLOADED (1 << 0) /* Directions for focusing */ #define XEMBED_DIRECTION_DEFAULT 0 #define XEMBED_DIRECTION_UP_DOWN 1 #define XEMBED_DIRECTION_LEFT_RIGHT 2 freshplayerplugin-0.3.9/tests/000077500000000000000000000000001321746453100164365ustar00rootroot00000000000000freshplayerplugin-0.3.9/tests/CMakeLists.txt000066400000000000000000000021551321746453100212010ustar00rootroot00000000000000enable_testing() add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) add_definitions(-DTEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data") set(test_list test_encoding_alias test_header_parser test_ppb_char_set test_ppb_flash_file test_ppb_url_request_info test_ppb_x509_certificate test_uri_parser test_ppb_net_address test_config_parser test_thread_specifier ) link_directories( ${REQ_LIBRARY_DIRS} ) # simplify inclusion of .c sources include_directories(..) foreach(item ${test_list}) add_executable(${item} ${item}.c $ $ $ $ ../src/config_pepperflash.c nih_test.c common.c) target_link_libraries(${item} "-Wl,-z,muldefs" ${REQ_LIBRARIES}) add_test(${item} ${item}) add_dependencies(check ${item}) endforeach() add_executable(util_glx_pixmap util_glx_pixmap.c) add_dependencies(check util_glx_pixmap) target_link_libraries(util_glx_pixmap ${REQ_LIBRARIES}) freshplayerplugin-0.3.9/tests/common.c000066400000000000000000000007171321746453100200770ustar00rootroot00000000000000#include "common.h" #include #include #include PP_Instance create_instance(void) { static int id = 10; struct pp_instance_s *pp_i = calloc(sizeof(*pp_i), 1); pp_i->id = id; tables_add_pp_instance(id, pp_i); return id++; } void destroy_instance(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); tables_remove_pp_instance(instance); free(pp_i); } freshplayerplugin-0.3.9/tests/common.h000066400000000000000000000003001321746453100200700ustar00rootroot00000000000000#pragma once #include #ifndef TEST_DATA_DIR #error TEST_DATA_DIR not defined #endif PP_Instance create_instance(void); void destroy_instance(PP_Instance instance); freshplayerplugin-0.3.9/tests/data/000077500000000000000000000000001321746453100173475ustar00rootroot00000000000000freshplayerplugin-0.3.9/tests/data/wikipedia.org.der000066400000000000000000000025231321746453100226010ustar00rootroot000000000000000O07!r@ٳOd(0  *H  0f1 0 UBE10U GlobalSign nv-sa1<0:U3GlobalSign Organization Validation CA - SHA256 - G20 141121180602Z 151122180602Z0y1 0 UUS10U California10U San Francisco1#0!U Wikimedia Foundation, Inc.10U *.wikipedia.org0"0  *H 0 lOJ-^QH:❷ܴ%RM;ak-Cga2J,jәX90JRی/&2I6k_i.<^eÓ*^y𳾀nm x n sEs&~߲+4g 0402+&https://www.globalsign.com/repository/0)U"0 *.wikipedia.org wikipedia.org0 U00U%0++0IUB0@0><:8http://crl.globalsign.com/gs/gsorganizationvalsha2g2.crl0+00M+0Ahttp://secure.globalsign.com/cacert/gsorganizationvalsha2g2r1.crt0?+03http://ocsp2.globalsign.com/gsorganizationvalsha2g20U struct testcase { char *name; void (*f)(void); struct testcase *next; }; static struct testcase head = {}; static struct testcase **next = &head.next; static void (*nih_test_setup_func)(void) = NULL; static void (*nih_test_teardown_func)(void) = NULL; static void (*nih_testsuite_setup_func)(void) = NULL; static void (*nih_testsuite_teardown_func)(void) = NULL; static int constructors_available = 0; void nih_test_add_func(const char *name, void (*f)(void)) { struct testcase *t = malloc(sizeof(*t)); if (t == NULL) { printf("memory allocation failure\n"); abort(); } t->name = strdup(name); t->f = f; t->next = NULL; *next = t; next = &t->next; } void nih_test_run_all(void) { // call all tests, one by one for (struct testcase *t = head.next; t != NULL; t = t->next) { printf("running %s\n", t->name); // initialize, if needed if (nih_test_setup_func) nih_test_setup_func(); // run actual test function t->f(); // deinitialize, if needed if (nih_test_teardown_func) nih_test_teardown_func(); } // cleanup memory while (head.next) { struct testcase *t = head.next; head.next = t->next; free(t->name); free(t); } } void nih_test_set_test_setup(void (*f)(void)) { nih_test_setup_func = f; } void nih_test_set_test_teardown(void (*f)(void)) { nih_test_teardown_func = f; } void nih_test_set_testsuite_setup(void (*f)(void)) { nih_testsuite_setup_func = f; } void nih_test_set_testsuite_teardown(void (*f)(void)) { nih_testsuite_teardown_func = f; } __attribute__((constructor)) static void nih_test_constructor_check_constructors(void) { constructors_available = 1; } // provides a main() function for a test that doesn't have any. __attribute__((weak)) int main(void) { if (!constructors_available) { printf("__attribute__((constructor)) doesn't work\n"); return 1; } if (nih_testsuite_setup_func) nih_testsuite_setup_func(); nih_test_run_all(); if (nih_testsuite_teardown_func) nih_testsuite_teardown_func(); printf("pass\n"); return 0; } freshplayerplugin-0.3.9/tests/nih_test.h000066400000000000000000000256571321746453100204430ustar00rootroot00000000000000/* * Copyright © 2013-2017 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * * 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 #include #include #include // ---------------------------------------------------------------------- #define TEST(suite_name, test_name) \ static \ void \ nih_test_ ## suite_name ## _ ## test_name(void); \ \ __attribute__((constructor)) \ static \ void \ nih_test_constructor_ ## suite_name ## _ ## test_name(void) \ { \ const char *testname = #suite_name ":" #test_name; \ nih_test_add_func(testname, \ nih_test_ ## suite_name ## _ ## test_name); \ } \ \ static \ void \ nih_test_ ## suite_name ## _ ## test_name(void) // ====================================================================== // ---------------------------------------------------------------------- #define TEST_SETUP(...) \ static \ void \ nih_test_setup(void); \ \ __attribute__((constructor)) \ static \ void \ nih_test_constructor_test_setup(void) \ { \ nih_test_set_test_setup(nih_test_setup); \ } \ \ static \ void \ nih_test_setup(void) // ====================================================================== // ---------------------------------------------------------------------- #define TEST_TEARDOWN(...) \ static \ void \ nih_test_teardown(void); \ \ __attribute__((constructor)) \ static \ void \ nih_test_constructor_test_teardown(void) \ { \ nih_test_set_test_teardown(nih_test_teardown); \ } \ \ static \ void \ nih_test_teardown(void) // ====================================================================== // ---------------------------------------------------------------------- #define TESTSUITE_SETUP(...) \ static \ void \ nih_testsuite_setup(void); \ \ __attribute__((constructor)) \ static \ void \ nih_test_constructor_testsuite_setup(void) \ { \ nih_test_set_testsuite_setup(nih_testsuite_setup); \ } \ \ static \ void \ nih_testsuite_setup(void) // ====================================================================== // ---------------------------------------------------------------------- #define TESTSUITE_TEARDOWN(...) \ static \ void \ nih_testsuite_teardown(void); \ \ __attribute__((constructor)) \ static \ void \ nih_test_constructor_testsuite_teardown(void) \ { \ nih_test_set_testsuite_teardown(nih_testsuite_teardown); \ } \ \ static \ void \ nih_testsuite_teardown(void) // ====================================================================== // ---------------------------------------------------------------------- #define ASSERT_OP(expr1, operation, expr2, name) \ do { \ __typeof(expr1) ____value1 = (expr1); \ __typeof(expr2) ____value2 = (expr2); \ int ____result = (____value1 operation ____value2); \ \ if (!____result) { \ printf("%s(%s, %s) failed\n", #name, #expr1, #expr2); \ abort(); \ } \ } while (0) // ====================================================================== // ---------------------------------------------------------------------- #define ASSERT_BOOL_OP(expr1, expr2, name) \ do { \ int ____value1 = !!(expr1); \ int ____value2 = !!(expr2); \ int ____result = (____value1 == ____value2); \ \ if (!____result) { \ printf("%s(%s) failed\n", #name, #expr1); \ abort(); \ } \ } while (0) // ====================================================================== #define ASSERT_TRUE(e) ASSERT_BOOL_OP(e, 1, ASSERT_TRUE) #define ASSERT_FALSE(e) ASSERT_BOOL_OP(e, 0, ASSERT_FALSE) #define ASSERT_EQ(e1, e2) ASSERT_OP(e1, ==, e2, ASSERT_EQ) #define ASSERT_NE(e1, e2) ASSERT_OP(e1, !=, e2, ASSERT_NE) #define ASSERT_LT(e1, e2) ASSERT_OP(e1, <, e2, ASSERT_LT) #define ASSERT_LE(e1, e2) ASSERT_OP(e1, <=, e2, ASSERT_LE) #define ASSERT_GT(e1, e2) ASSERT_OP(e1, >, e2, ASSERT_GT) #define ASSERT_GE(e1, e2) ASSERT_OP(e1, >=, e2, ASSERT_GE) // ---------------------------------------------------------------------- #define ASSERT_STREQ(expr1, expr2) \ do { \ int ____result = (strcmp((expr1), (expr2)) == 0); \ \ if (!____result) { \ printf("ASSERT_STREQ(%s, %s) failed\n", #expr1, #expr2); \ abort(); \ } \ } while (0) // ====================================================================== void nih_test_add_func(const char *name, void (*f)(void)); void nih_test_set_test_setup(void (*f)(void)); void nih_test_set_test_teardown(void (*f)(void)); void nih_test_set_testsuite_setup(void (*f)(void)); void nih_test_set_testsuite_teardown(void (*f)(void)); void nih_test_run_all(void); freshplayerplugin-0.3.9/tests/test_config_parser.c000066400000000000000000000052071321746453100224660ustar00rootroot00000000000000#include "nih_test.h" #include #include #include #include #include TEST(config_parser, test_1) { ASSERT_TRUE((void*)1); const char *s = "param1= value\n" // simple key-value "param2 = 123\r\n" // number value; different line ending "unknownkey = unknownvalue\n" // unknown key "param3 =qwe"; // no newline character at the end of a file char *value1 = strdup(""); int value2 = 0; char *value3 = strdup(""); char *value4 = strdup("defaultvalue"); cfg_opt_t opts[] = { CFG_SIMPLE_STR("param1", &value1), CFG_SIMPLE_INT("param2", &value2), CFG_SIMPLE_STR("param3", &value3), CFG_SIMPLE_STR("param4", &value4), CFG_END() }; cfg_t *cfg = cfg_init(opts, 0); ASSERT_NE(cfg, NULL); cfg_parse_string(cfg, s); ASSERT_TRUE(strcmp(value1, "value") == 0); ASSERT_TRUE(value2 == 123); ASSERT_TRUE(strcmp(value3, "qwe") == 0); ASSERT_TRUE(strcmp(value4, "defaultvalue") == 0); cfg_free(cfg); free(value1); free(value3); free(value4); } TEST(config_parser, test_2) { const char *s = "param1_float = qwe\n" // invalid float value " param2_float = 3.45 \n" // float value with leading and trailing spaces "param3_str = value3\n"; double value1 = 11.0; double value2 = 11.0; char *value3 = strdup("defaultvalue"); cfg_opt_t opts[] = { CFG_SIMPLE_FLOAT("param1_float", &value1), CFG_SIMPLE_FLOAT("param2_float", &value2), CFG_SIMPLE_STR("param3_str", &value3), CFG_END() }; cfg_t *cfg = cfg_init(opts, 0); ASSERT_NE(cfg, NULL); cfg_parse_string(cfg, s); ASSERT_TRUE(fabs(value1 - 0) < 1e-5); ASSERT_TRUE(fabs(value2 - 3.45) < 1e-5); ASSERT_TRUE(strcmp(value3, "value3") == 0); cfg_free(cfg); free(value3); } TEST(config_parser, test_3) { const char *s = "# commented line\n" // comment "\n" // empty line by itself "param1 = var1\n" // multiple definitions "param1 = var2\n" // of the same parameter "# param1 = var3\n"; // and one of them commented out char *value1 = strdup(""); cfg_opt_t opts[] = { CFG_SIMPLE_STR("param1", &value1), CFG_END() }; cfg_t *cfg = cfg_init(opts, 0); ASSERT_NE(cfg, NULL); cfg_parse_string(cfg, s); ASSERT_TRUE(strcmp(value1, "var2") == 0); cfg_free(cfg); free(value1); } freshplayerplugin-0.3.9/tests/test_encoding_alias.c000066400000000000000000000025511321746453100226030ustar00rootroot00000000000000#include "nih_test.h" #include TEST(encoding_alias, utf8) { // UTF-8 ASSERT_STREQ(encoding_alias_get_canonical_name("utf8"), "UTF-8"); // plain ASSERT_STREQ(encoding_alias_get_canonical_name("uTF8"), "UTF-8"); // partial uppercase ASSERT_STREQ(encoding_alias_get_canonical_name("uTF-8"), "UTF-8"); } TEST(encoding_alias, cp1251) { // cp1251 ASSERT_STREQ(encoding_alias_get_canonical_name("cp1251"), "windows-1251"); ASSERT_STREQ(encoding_alias_get_canonical_name("windows-1251"), "windows-1251"); } TEST(encoding_alias, GBK) { // GBK ASSERT_STREQ(encoding_alias_get_canonical_name("GBK"), "GBK"); ASSERT_STREQ(encoding_alias_get_canonical_name("gb2312"), "GBK"); ASSERT_STREQ(encoding_alias_get_canonical_name("gb2312-80"), "GBK"); } static void strip_enc_name_tst(const char *a, const char *b) { char *s = strip_enc_name(a); ASSERT_STREQ(s, b); free(s); } TEST(encoding_alias, strip_enc_name) { strip_enc_name_tst("UTF-8", "utf8"); strip_enc_name_tst(" U_t_F_8 ", "utf8"); strip_enc_name_tst("utf08", "utf8"); strip_enc_name_tst("utf0008", "utf8"); strip_enc_name_tst("0", "0"); strip_enc_name_tst("", ""); strip_enc_name_tst("00", "0"); strip_enc_name_tst("000", "0"); strip_enc_name_tst("0010", "10"); strip_enc_name_tst("asd0", "asd0"); } freshplayerplugin-0.3.9/tests/test_header_parser.c000066400000000000000000000041421321746453100224460ustar00rootroot00000000000000#include "nih_test.h" #include #include #include TEST(header_parser, test_1) { struct parsed_headers_s *ph = hp_parse_headers( "HTTP/1.1 200 OK\r\n" "Date: Sat, 19 Apr 2014 15:53:34 GMT\r\n" "Server: Apache/2.4.9 (Debian)\r\n" "Last-Modified: Tue, 12 Feb 2013 12:57:02 GMT\r\n" "Etag: \"1efbf-4d5868fd0c380\"\r\n" "Accept-Ranges: bytes\r\n" "Content-Length: 126911\r\n" "Keep-Alive: timeout=5, max=95\r\n" "Connection: Keep-Alive\r\n" "Content-Type: application/x-shockwave-flash\r\n" ); ASSERT_TRUE(ph); ASSERT_EQ(ph->http_code, 200); ASSERT_TRUE(hp_header_exists(ph, "Date")); ASSERT_TRUE(hp_header_exists(ph, "date")); ASSERT_FALSE(hp_header_exists(ph, "Date2")); ASSERT_TRUE(hp_header_exists(ph, "Content-Type")); ASSERT_FALSE(hp_header_exists(ph, "bytes")); ASSERT_STREQ(hp_get_header_value(ph, "Date"), "Sat, 19 Apr 2014 15:53:34 GMT"); ASSERT_STREQ(ph->status_line, "HTTP/1.1 200 OK"); hp_free_parsed_headers(ph); } TEST(header_parser, test_2) { struct parsed_headers_s *ph = hp_parse_headers( "HTTP/1.0 301 Moved Permanently\r\n" "Location: http://example.org\r\n" "Connection: Keep-Alive\r\n" ); ASSERT_EQ(ph->http_code, 301); ASSERT_STREQ(hp_get_header_value(ph, "Location"), "http://example.org"); ASSERT_STREQ(ph->status_line, "HTTP/1.0 301 Moved Permanently"); hp_free_parsed_headers(ph); } TEST(header_parser, test_3) { struct parsed_headers_s *ph = hp_parse_headers(NULL); ASSERT_EQ(ph->cnt, 0); hp_free_parsed_headers(ph); } TEST(header_parser, test_4) { // no \r\n at the end of last header line struct parsed_headers_s *ph = hp_parse_headers( "HTTP/1.0 301 Moved Permanently\r\n" "Location: http://example.org\r\n" "Connection: Keep-Alive" ); ASSERT_TRUE(hp_header_exists(ph, "Location")); ASSERT_TRUE(hp_header_exists(ph, "Connection")); ASSERT_STREQ(hp_get_header_value(ph, "Connection"), "Keep-Alive"); hp_free_parsed_headers(ph); } freshplayerplugin-0.3.9/tests/test_ppb_char_set.c000066400000000000000000000161761321746453100223050ustar00rootroot00000000000000#include "nih_test.h" #include #include #include #include #include static void * t_memalloc(uint32_t sz) { return malloc(sz); } TESTSUITE_SETUP(void) { // npn is globally visible struct npn.memalloc = t_memalloc; npn.memfree = free; } TEST(ppb_char_set, extract_relevant_part_from_locale_name) { char *s; s = extract_relevant_part_from_locale_name("ru_RU.UTF-8"); ASSERT_STREQ(s, "ru"); free(s); s = extract_relevant_part_from_locale_name("en_US"); ASSERT_STREQ(s, "en"); free(s); s = extract_relevant_part_from_locale_name("zh_CN.utf8"); ASSERT_STREQ(s, "zh-CN"); free(s); s = extract_relevant_part_from_locale_name("zh_TW.utf8"); ASSERT_STREQ(s, "zh-TW"); free(s); } TEST(ppb_char_set, to_utf16_all_ASCII) { const char *in = "Hello, world!"; const uint8_t out[] = {'H', 0, 'e', 0, 'l', 0, 'l', 0, 'o', 0, ',', 0, ' ', 0, 'w', 0, 'o', 0, 'r', 0, 'l', 0, 'd', 0, '!', 0}; uint32_t res_len = 7777; uint16_t *res = ppb_char_set_char_set_to_utf16(0, in, strlen(in), "UTF-8", PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); ASSERT_EQ(sizeof(out) / sizeof(uint16_t), res_len); ASSERT_EQ(memcmp(res, out, sizeof(out)), 0); free(res); } TEST(ppb_char_set, to_utf16_basic_UTF_8) { const char *in = "Привет, мир!"; const uint8_t out[] = {0x1f, 0x04, 0x40, 0x04, 0x38, 0x04, 0x32, 0x04, 0x35, 0x04, 0x42, 0x04, 0x2c, 0x00, 0x20, 0x00, 0x3c, 0x04, 0x38, 0x04, 0x40, 0x04, 0x21, 0x00}; uint32_t res_len = 7777; uint16_t *res = ppb_char_set_char_set_to_utf16(0, in, strlen(in), "UTF-8", PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); ASSERT_EQ(sizeof(out) / sizeof(uint16_t), res_len); ASSERT_EQ(memcmp(res, out, sizeof(out)), 0); free(res); } TEST(ppb_char_set, to_utf16_wrong_UTF_8_with_error) { const char *in = "Hel\x80lo"; uint32_t res_len = 7777; uint16_t *res = ppb_char_set_char_set_to_utf16(0, in, strlen(in), "UTF-8", PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); ASSERT_EQ(res_len, 0); ASSERT_EQ(res, NULL); free(res); } // testing PP_CHARSET_CONVERSIONERROR_SKIP or PP_CHARSET_CONVERSIONERROR_SUBSTITUTE // have no much sense since every unicode character can be represented in UTF-16 TEST(ppb_char_set, from_utf16_all_ASCII) { const uint8_t in[] = {'H', 0, 'e', 0, 'l', 0, 'l', 0, 'o', 0, ',', 0, ' ', 0, 'w', 0, 'o', 0, 'r', 0, 'l', 0, 'd', 0, '!', 0}; const char *out = "Hello, world!"; uint32_t res_len = 7777; char *res = ppb_char_set_utf16_to_char_set(0, (const uint16_t *)in, sizeof(in) / sizeof(uint16_t), "cp1251", PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); ASSERT_EQ(strlen(out), res_len); ASSERT_EQ(memcmp(res, out, res_len), 0); free(res); } TEST(ppb_char_set, to_utf16_non_ASCII_all_correct) { const uint8_t in[] = {0x1f, 0x04, 0x40, 0x04, 0x38, 0x04, 0x32, 0x04, 0x35, 0x04, 0x42, 0x04, 0x2c, 0x00, 0x20, 0x00, 0x3c, 0x04, 0x38, 0x04, 0x40, 0x04, 0x21, 0x00}; // "Привет, мир!" const char *out = "\xcf\xf0\xe8\xe2\xe5\xf2\x2c\x20\xec\xe8\xf0\x21"; // "Привет, мир!" uint32_t res_len = 7777; char *res = ppb_char_set_utf16_to_char_set(0, (const uint16_t *)in, sizeof(in) / sizeof(uint16_t), "cp1251", PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); ASSERT_EQ(strlen(out), res_len); ASSERT_EQ(memcmp(res, out, res_len), 0); free(res); } TEST(ppb_char_set, to_utf16_non_ASCII_PP_CHARSET_CONVERSIONERROR_FAIL) { const uint8_t in[] = {0x1f, 0x04, 0x40, 0x04, 0x38, 0x04, 0x32, 0x04, 0x35, 0x04, 0x42, 0x04, 0x2c, 0x00, 0x20, 0x00, 0x6b, 0x26, 0x3c, 0x04, 0x38, 0x04, 0x40, 0x04, 0x21, 0x00}; // "Привет, ♫мир!" // const char *out = "\xcf\xf0\xe8\xe2\xe5\xf2\x2c\x20\xec\xe8\xf0\x21"; // "Привет, мир!" uint32_t res_len = 7777; char *res = ppb_char_set_utf16_to_char_set(0, (const uint16_t *)in, sizeof(in) / sizeof(uint16_t), "cp1251", PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); ASSERT_EQ(res_len, 0); ASSERT_EQ(res, NULL); free(res); } TEST(ppb_char_set, to_utf16_non_ASCII_PP_CHARSET_CONVERSIONERROR_SKIP) { const uint8_t in[] = {0x1f, 0x04, 0x40, 0x04, 0x38, 0x04, 0x32, 0x04, 0x35, 0x04, 0x42, 0x04, 0x2c, 0x00, 0x20, 0x00, 0x6b, 0x26, 0x3c, 0x04, 0x38, 0x04, 0x40, 0x04, 0x21, 0x00}; // "Привет, ♫мир!" const char *out = "\xcf\xf0\xe8\xe2\xe5\xf2\x2c\x20\xec\xe8\xf0\x21"; // "Привет, мир!" uint32_t res_len = 7777; char *res = ppb_char_set_utf16_to_char_set(0, (const uint16_t *)in, sizeof(in) / sizeof(uint16_t), "cp1251", PP_CHARSET_CONVERSIONERROR_SKIP, &res_len); ASSERT_EQ(strlen(out), res_len); ASSERT_EQ(memcmp(res, out, res_len), 0); free(res); } TEST(ppb_char_set, to_utf16_non_ASCII_PP_CHARSET_CONVERSIONERROR_SUBSTITUTE) { const uint8_t in[] = {0x1f, 0x04, 0x40, 0x04, 0x38, 0x04, 0x32, 0x04, 0x35, 0x04, 0x42, 0x04, 0x2c, 0x00, 0x20, 0x00, 0x6b, 0x26, 0x3c, 0x04, 0x38, 0x04, 0x40, 0x04, 0x21, 0x00}; // "Привет, ♫мир!" const char *out = "\xcf\xf0\xe8\xe2\xe5\xf2\x2c\x20\x3f\xec\xe8\xf0\x21";// "Привет, ?мир!" uint32_t res_len = 7777; char *res = ppb_char_set_utf16_to_char_set(0, (const uint16_t *)in, sizeof(in) / sizeof(uint16_t), "cp1251", PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &res_len); ASSERT_EQ(strlen(out), res_len); ASSERT_EQ(memcmp(res, out, res_len), 0); free(res); } TEST(ppb_char_set, gb2312_ASCII_to_utf16) { // gb2312 is a variable-length encoding, with ASCII encoded as is // "Hello, world!" in ASCII const uint8_t in[] = {0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x21}; // "Hello, world!" in UTF16-LE const uint8_t out[] = {0x48, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x2c, 0x00, 0x20, 0x00, 0x77, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x6c, 0x00, 0x64, 0x00, 0x21, 0x00}; uint32_t res_len = 7777; uint16_t *res = ppb_char_set_char_set_to_utf16(0, (const char *)in, sizeof(in), "gb2312", PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); ASSERT_EQ(res_len, sizeof(out) / sizeof(uint16_t)); ASSERT_EQ(memcmp(res, out, sizeof(out)), 0); free(res); } freshplayerplugin-0.3.9/tests/test_ppb_flash_file.c000066400000000000000000000021761321746453100226040ustar00rootroot00000000000000#include "nih_test.h" #include #include #include static void test_case(const char *s, const char *res) { printf(" /%s -> %s\n", s, res); char *got = to_abs_path("/start", s); ASSERT_STREQ(got, res); free(got); } TEST(ppb_flash_file, to_abs_path) { test_case("WritableRoot/#SharedObjects/4TVF7XJR/macromedia.com/support/flashplayer/sys/#127.0.0.1", "/start/WritableRoot/#SharedObjects/4TVF7XJR/macromedia.com/support/flashplayer/sys/#127.0.0.1"); test_case("qw/../../../../", "/start/"); test_case("qw/../../../..", "/start/"); test_case("p1/p2/p3/../p4", "/start/p1/p2/p4"); test_case("p1/p2/p3/./p4", "/start/p1/p2/p3/p4"); test_case("././p3", "/start/p3"); test_case("p1/.../p2", "/start/p1/.../p2"); test_case("p1/p2/./../p3", "/start/p1/p3"); test_case("..", "/start/"); test_case(".", "/start/"); test_case("../", "/start/"); test_case("./", "/start/"); test_case("g..", "/start/g.."); test_case("g.", "/start/g."); test_case("g../a", "/start/g../a"); test_case("g./a", "/start/g./a"); } freshplayerplugin-0.3.9/tests/test_ppb_net_address.c000066400000000000000000000235571321746453100230110ustar00rootroot00000000000000#include "common.h" #include "nih_test.h" #include "src/ppb_core.h" #include "src/ppb_var.h" #include #include #include TEST(ppb_net_address_private, ipv4_compose_decompose) { const uint8_t ip[4] = {192, 168, 1, 2}; const uint16_t port = 1234; uint8_t ip_out[sizeof(ip)] = {}; struct PP_NetAddress_Private addr; ppb_net_address_private_create_from_ipv4_address(ip, port, &addr); ppb_net_address_private_get_address(&addr, ip_out, sizeof(ip_out)); ASSERT_EQ(memcmp(ip, ip_out, sizeof(ip)), 0); ASSERT_EQ(ppb_net_address_private_get_port(&addr), port); ASSERT_EQ(ppb_net_address_private_get_family(&addr), PP_NETADDRESSFAMILY_PRIVATE_IPV4); ASSERT_EQ(ppb_net_address_private_get_scope_id(&addr), 0); } TEST(ppb_net_address_private, ipv4_equality) { const uint8_t ip[4] = {192, 168, 1, 2}; const uint16_t port1 = 1234; const uint16_t port2 = 5678; struct PP_NetAddress_Private addr1; struct PP_NetAddress_Private addr2; ppb_net_address_private_create_from_ipv4_address(ip, port1, &addr1); ppb_net_address_private_create_from_ipv4_address(ip, port2, &addr2); // different ports, hence are different ASSERT_EQ(ppb_net_address_private_are_equal(&addr1, &addr2), PP_FALSE); ASSERT_EQ(ppb_net_address_private_are_hosts_equal(&addr1, &addr2), PP_TRUE); ppb_net_address_private_create_from_ipv4_address(ip, port2, &addr1); ppb_net_address_private_create_from_ipv4_address(ip, port2, &addr2); // should be equal ASSERT_EQ(ppb_net_address_private_are_equal(&addr1, &addr2), PP_TRUE); ASSERT_EQ(ppb_net_address_private_are_hosts_equal(&addr1, &addr2), PP_TRUE); } TEST(ppb_net_address_private, ipv4_replace_port) { const uint8_t ip[4] = {192, 168, 1, 2}; const uint16_t port1 = 1234; const uint16_t port2 = 1234; struct PP_NetAddress_Private addr1; struct PP_NetAddress_Private addr2; ppb_net_address_private_create_from_ipv4_address(ip, port1, &addr1); ASSERT_EQ(ppb_net_address_private_get_port(&addr1), port1); ppb_net_address_private_replace_port(&addr1, port2, &addr2); ASSERT_EQ(ppb_net_address_private_get_port(&addr2), port2); } TEST(ppb_net_address_private, ipv4_describe) { const uint8_t ip[4] = {192, 168, 1, 2}; const uint16_t port = 1234; struct PP_NetAddress_Private addr; struct PP_Var s; ppb_net_address_private_create_from_ipv4_address(ip, port, &addr); s = ppb_net_address_private_describe(0, &addr, PP_TRUE); ASSERT_STREQ(ppb_var_var_to_utf8(s, NULL), "192.168.1.2:1234"); ppb_var_release(s); s = ppb_net_address_private_describe(0, &addr, PP_FALSE); ASSERT_STREQ(ppb_var_var_to_utf8(s, NULL), "192.168.1.2"); ppb_var_release(s); } TEST(ppb_net_address_private, ipv6_compose_decompose) { const uint8_t ip[16] = { 0x01, 0x23, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xef, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; const uint16_t port = 3333; const uint32_t scope_id = 555; struct PP_NetAddress_Private addr; uint8_t ip_out[sizeof(ip)] = {}; ppb_net_address_private_create_from_ipv6_address(ip, scope_id, port, &addr); ppb_net_address_private_get_address(&addr, ip_out, sizeof(ip_out)); ASSERT_EQ(memcmp(ip, ip_out, sizeof(ip)), 0); ASSERT_EQ(ppb_net_address_private_get_port(&addr), port); ASSERT_EQ(ppb_net_address_private_get_family(&addr), PP_NETADDRESSFAMILY_PRIVATE_IPV6); ASSERT_EQ(ppb_net_address_private_get_scope_id(&addr), scope_id); } TEST(ppb_net_address_private, ipv6_equality) { const uint8_t ip[16] = { 0x01, 0x23, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xef, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; const uint16_t port1 = 3333; const uint16_t port2 = 5555; struct PP_NetAddress_Private addr1; struct PP_NetAddress_Private addr2; // different ports ppb_net_address_private_create_from_ipv6_address(ip, 0, port1, &addr1); ppb_net_address_private_create_from_ipv6_address(ip, 0, port2, &addr2); // different, but hosts are the same ASSERT_EQ(ppb_net_address_private_are_equal(&addr1, &addr2), PP_FALSE); ASSERT_EQ(ppb_net_address_private_are_hosts_equal(&addr1, &addr2), PP_TRUE); // same ports ppb_net_address_private_create_from_ipv6_address(ip, 0, port2, &addr1); ppb_net_address_private_create_from_ipv6_address(ip, 0, port2, &addr2); // should be equal ASSERT_EQ(ppb_net_address_private_are_equal(&addr1, &addr2), PP_TRUE); ASSERT_EQ(ppb_net_address_private_are_hosts_equal(&addr1, &addr2), PP_TRUE); } TEST(ppb_net_address_private, ipv6_replace_port) { const uint8_t ip[16] = { 0x01, 0x23, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xef, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; const uint16_t port1 = 1234; const uint16_t port2 = 1234; struct PP_NetAddress_Private addr1; struct PP_NetAddress_Private addr2; ppb_net_address_private_create_from_ipv6_address(ip, 0, port1, &addr1); ASSERT_EQ(ppb_net_address_private_get_port(&addr1), port1); ppb_net_address_private_replace_port(&addr1, port2, &addr2); ASSERT_EQ(ppb_net_address_private_get_port(&addr2), port2); } TEST(ppb_net_address_private, ipv6_describe) { const uint8_t ip[16] = { 0x01, 0x23, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xef, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; const uint16_t port = 1234; struct PP_NetAddress_Private addr; struct PP_Var s; ppb_net_address_private_create_from_ipv6_address(ip, 0, port, &addr); s = ppb_net_address_private_describe(0, &addr, PP_TRUE); ASSERT_STREQ(ppb_var_var_to_utf8(s, NULL), "[123:3456:789a:bcde:ef11:2233:4455:6677]:1234"); ppb_var_release(s); s = ppb_net_address_private_describe(0, &addr, PP_FALSE); ASSERT_STREQ(ppb_var_var_to_utf8(s, NULL), "123:3456:789a:bcde:ef11:2233:4455:6677"); ppb_var_release(s); } TEST(ppb_net_address_private, ill_formed_PP_NetAddress_Private) { const uint8_t ip[4] = {192, 168, 1, 2}; const uint16_t port = 1234; struct PP_NetAddress_Private addr1; struct PP_NetAddress_Private addr2 = {}; struct PP_NetAddress_Private addr3 = {}; struct PP_Var s; uint8_t ip_out[4]; ppb_net_address_private_create_from_ipv4_address(ip, port, &addr1); ASSERT_EQ(ppb_net_address_private_are_equal(&addr1, &addr2), PP_FALSE); ASSERT_EQ(ppb_net_address_private_are_hosts_equal(&addr1, &addr2), PP_FALSE); ASSERT_EQ(ppb_net_address_private_get_family(&addr2), PP_NETADDRESSFAMILY_PRIVATE_UNSPECIFIED); ASSERT_EQ(ppb_net_address_private_get_port(&addr2), 0); ASSERT_EQ(ppb_net_address_private_get_address(&addr2, ip_out, sizeof(ip_out)), PP_FALSE); ASSERT_EQ(ppb_net_address_private_replace_port(&addr2, port, &addr3), PP_FALSE); s = ppb_net_address_private_describe(0, &addr2, PP_TRUE); ASSERT_EQ(s.type, PP_VARTYPE_UNDEFINED); } TEST(ppb_net_address_private, ipv4_get_any_address) { const uint8_t all_zeroes[4] = {}; uint8_t ip[4]; struct PP_NetAddress_Private addr; memset(&addr, 5, sizeof(addr)); // overwrite with something ppb_net_address_private_get_any_address(PP_FALSE, &addr); ASSERT_EQ(ppb_net_address_private_get_family(&addr), PP_NETADDRESSFAMILY_PRIVATE_IPV4); ppb_net_address_private_get_address(&addr, ip, sizeof(ip)); ASSERT_EQ(memcmp(ip, all_zeroes, sizeof(ip)), 0); } TEST(ppb_net_address, ipv6_get_any_address) { const uint8_t all_zeroes[16] = {}; uint8_t ip[16]; struct PP_NetAddress_Private addr; memset(&addr, 5, sizeof(addr)); // overwrite with something ppb_net_address_private_get_any_address(PP_TRUE, &addr); ASSERT_EQ(ppb_net_address_private_get_family(&addr), PP_NETADDRESSFAMILY_PRIVATE_IPV6); ppb_net_address_private_get_address(&addr, ip, sizeof(ip)); ASSERT_EQ(memcmp(ip, all_zeroes, sizeof(ip)), 0); } TEST(ppb_net_address, ipv4_compose_decompose) { PP_Instance instance = create_instance(); const struct PP_NetAddress_IPv4 ipv4 = { .addr = {192, 168, 1, 2}, .port = htons(3456) }; struct PP_NetAddress_IPv4 ipv4_a = {}; struct PP_NetAddress_IPv6 ipv6 = {}; PP_Resource addr = ppb_net_address_create_from_ipv4_address(instance, &ipv4); ASSERT_EQ(ppb_net_address_is_net_address(addr), PP_TRUE); ASSERT_EQ(ppb_net_address_get_family(addr), PP_NETADDRESS_FAMILY_IPV4); ASSERT_EQ(ppb_net_address_describe_as_ipv6_address(addr, &ipv6), PP_FALSE); ASSERT_EQ(ppb_net_address_describe_as_ipv4_address(addr, &ipv4_a), PP_TRUE); ASSERT_EQ(memcmp(&ipv4, &ipv4_a, sizeof(ipv4_a)), 0); struct PP_Var s = ppb_net_address_describe_as_string(addr, PP_TRUE); ASSERT_STREQ(ppb_var_var_to_utf8(s, NULL), "192.168.1.2:3456"); ppb_var_release(s); ppb_core_release_resource(addr); destroy_instance(instance); } TEST(ppb_net_address, ipv6_compose_decompose) { PP_Instance instance = create_instance(); const struct PP_NetAddress_IPv6 ipv6 = { .addr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, .port = htons(3456) }; struct PP_NetAddress_IPv6 ipv6_a = {}; struct PP_NetAddress_IPv4 ipv4 = {}; PP_Resource addr = ppb_net_address_create_from_ipv6_address(instance, &ipv6); ASSERT_EQ(ppb_net_address_is_net_address(addr), PP_TRUE); ASSERT_EQ(ppb_net_address_get_family(addr), PP_NETADDRESS_FAMILY_IPV6); ASSERT_EQ(ppb_net_address_describe_as_ipv4_address(addr, &ipv4), PP_FALSE); ASSERT_EQ(ppb_net_address_describe_as_ipv6_address(addr, &ipv6_a), PP_TRUE); ASSERT_EQ(memcmp(&ipv6, &ipv6_a, sizeof(ipv6_a)), 0); struct PP_Var s = ppb_net_address_describe_as_string(addr, PP_TRUE); ASSERT_STREQ(ppb_var_var_to_utf8(s, NULL), "[102:304:506:708:90a:b0c:d0e:f10]:3456"); ppb_var_release(s); ppb_core_release_resource(addr); destroy_instance(instance); } freshplayerplugin-0.3.9/tests/test_ppb_url_request_info.c000066400000000000000000000011131321746453100240630ustar00rootroot00000000000000#include "nih_test.h" #include #include #define test_ltrim(in, out) \ do { \ const char *s = ltrim(in); \ ASSERT_TRUE(strcmp(s, out) == 0); \ } while (0) TEST(ppb_url_request_info, ltrim) { test_ltrim("", ""); test_ltrim("hello", "hello"); test_ltrim(" hello", "hello"); test_ltrim(" \t hello", "hello"); test_ltrim("\n\nhello", "hello"); } freshplayerplugin-0.3.9/tests/test_ppb_x509_certificate.c000066400000000000000000000064541321746453100235620ustar00rootroot00000000000000#include "nih_test.h" #include #include #include #include #include #include #include #include static void test_hlp(const char *s, int type, double target, double eps) { ASN1_TIME at = { .data = (unsigned char *)s, .length = strlen(s), .type = type }; struct PP_Var var = convert_asn1_time_to_pp_var(&at); if (target > 0) { // expecting success ASSERT_EQ(var.type, PP_VARTYPE_DOUBLE); ASSERT_TRUE(fabs(var.value.as_double - target) < eps); } else { // expecting failure ASSERT_EQ(var.type, PP_VARTYPE_NULL); } } TEST(ppb_x509_certificate, convert_asn1_time_to_pp_var) { printf("V_ASN1_UTCTIME\n"); test_hlp("9912312359Z", V_ASN1_UTCTIME, 946684740, 1e-3); test_hlp("991231235959+0200", V_ASN1_UTCTIME, 946684799 - 3600 * 2, 1e-3); printf("V_ASN1_GENERALIZEDTIME\n"); test_hlp("20001231235959.999", V_ASN1_GENERALIZEDTIME, 978307199.999, 1e-3); test_hlp("20001231235959.999+0300", V_ASN1_GENERALIZEDTIME, 978307199.999 - 3600 * 3, 1e-3); } TEST(ppb_x509_certificate, main) { struct PP_Var var; const char *s; PP_Resource x509; PP_Instance instance = create_instance(); x509 = ppb_x509_certificate_create(instance); ASSERT_TRUE(x509); gchar *buf; gsize len; gboolean ret1 = g_file_get_contents(TEST_DATA_DIR "/wikipedia.org.der", &buf, &len, NULL); ASSERT_TRUE(ret1); PP_Bool ret2 = ppb_x509_certificate_initialize(x509, buf, len); ASSERT_EQ(ret2, PP_TRUE); g_free(buf); #define TST_GET_FIELD(fname) \ printf(#fname "\n"); \ var = ppb_x509_certificate_get_field(x509, fname); // ======== TST_GET_FIELD(PP_X509CERTIFICATE_PRIVATE_ISSUER_COMMON_NAME); s = ppb_var_var_to_utf8(var, NULL); ASSERT_TRUE(strcmp(s, "GlobalSign Organization Validation CA - SHA256 - G2") == 0); ppb_var_release(var); // ======== TST_GET_FIELD(PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_NAME); s = ppb_var_var_to_utf8(var, NULL); ASSERT_TRUE(strcmp(s, "GlobalSign nv-sa") == 0); ppb_var_release(var); // ======== TST_GET_FIELD(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COMMON_NAME); s = ppb_var_var_to_utf8(var, NULL); ASSERT_TRUE(strcmp(s, "*.wikipedia.org") == 0); ppb_var_release(var); // ======== TST_GET_FIELD(PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_NAME); s = ppb_var_var_to_utf8(var, NULL); ASSERT_TRUE(strcmp(s, "Wikimedia Foundation, Inc.") == 0); ppb_var_release(var); // ======== TST_GET_FIELD(PP_X509CERTIFICATE_PRIVATE_SUBJECT_LOCALITY_NAME); s = ppb_var_var_to_utf8(var, NULL); ASSERT_TRUE(strcmp(s, "San Francisco") == 0); ppb_var_release(var); // ======== TST_GET_FIELD(PP_X509CERTIFICATE_PRIVATE_SUBJECT_STATE_OR_PROVINCE_NAME); s = ppb_var_var_to_utf8(var, NULL); ASSERT_TRUE(strcmp(s, "California") == 0); ppb_var_release(var); // ======== TST_GET_FIELD(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COUNTRY_NAME); s = ppb_var_var_to_utf8(var, NULL); ASSERT_TRUE(strcmp(s, "US") == 0); ppb_var_release(var); ppb_core_release_resource(x509); destroy_instance(instance); } freshplayerplugin-0.3.9/tests/test_thread_specifier.c000066400000000000000000000022021321746453100231350ustar00rootroot00000000000000// testing that "__thread" specifier works #include "nih_test.h" #include #include static pthread_barrier_t b1, b2; static pthread_t t; static __thread int v; static int *vaddr1; static int *vaddr2; static void * thread_func(void *param) { vaddr2 = &v; v = 2; // setting this shouldn't change "v" value in main thread pthread_barrier_wait(&b1); pthread_barrier_wait(&b2); return NULL; } TEST(thread_specifier, test_1) { ASSERT_EQ(0, pthread_barrier_init(&b1, NULL, 2)); ASSERT_EQ(0, pthread_barrier_init(&b2, NULL, 2)); vaddr1 = &v; v = 1; // assign thread local variable a value ASSERT_EQ(0, pthread_create(&t, NULL, thread_func, NULL)); // wait for thread to set "v" ASSERT_EQ(0, pthread_barrier_wait(&b1)); // ensure this "v" is not affected by other thread ASSERT_EQ(v, 1); // allow other thread to continue pthread_barrier_wait(&b2); pthread_join(t, NULL); ASSERT_EQ(0, pthread_barrier_destroy(&b1)); ASSERT_EQ(0, pthread_barrier_destroy(&b2)); printf("vaddr1 = %p\n", vaddr1); printf("vaddr2 = %p\n", vaddr2); } freshplayerplugin-0.3.9/tests/test_uri_parser.c000066400000000000000000000142171321746453100220210ustar00rootroot00000000000000#undef NDEBUG #include #include #include #include #include static void fill_parse_map(char *pm, char type, struct PP_URLComponent_Dev c) { for (int k = c.begin; k < c.begin + c.len; k ++) { assert(pm[k] == '.'); pm[k] = type; } } static void check_parse_uri(const char *uri, const char *pm) { size_t uri_len = strlen(uri); size_t pr_len = strlen(uri); printf("checking %s\n", uri); // length should be the same assert(uri_len == pr_len); // make room for another parse map char *pm2 = strdup(uri); assert(pm2); for (int k = 0; k < pr_len; k ++) pm2[k] = '.'; // parse URI struct PP_URLComponents_Dev c; uri_parser_parse_uri(uri, &c); // fill parse map fill_parse_map(pm2, '1', c.scheme); fill_parse_map(pm2, '2', c.username); fill_parse_map(pm2, '3', c.password); fill_parse_map(pm2, '4', c.host); fill_parse_map(pm2, '5', c.port); fill_parse_map(pm2, '6', c.path); fill_parse_map(pm2, '7', c.query); fill_parse_map(pm2, '8', c.ref); printf("result %s\nexpecting %s\n\n", pm, pm2); assert(strcmp(pm, pm2) == 0); free(pm2); } static void test_parser(void) { check_parse_uri("", ""); check_parse_uri("http://user:pass@example.org:3128/path1/path2/?q=query#fragment", "1111...2222.3333.44444444444.55556666666666666.7777777.88888888"); check_parse_uri("http://user@example.org:3128/path1/path2/?q=query#fragment", "1111...2222.44444444444.55556666666666666.7777777.88888888"); check_parse_uri("http://user:pass@example.org/path1/path2/?q=query#fragment", "1111...2222.3333.444444444446666666666666.7777777.88888888"); check_parse_uri("https://user@example.org/path1/path2/?q=query#fragment", "11111...2222.444444444446666666666666.7777777.88888888"); check_parse_uri("http://example.org/path1/path2/?q=query#fragment", "1111...444444444446666666666666.7777777.88888888"); check_parse_uri("/path1/path2/?q=query#fragment", "6666666666666.7777777.88888888"); check_parse_uri("?q=query#fragment", ".7777777.88888888"); check_parse_uri("#fragment", ".88888888"); check_parse_uri("example.org", "66666666666"); check_parse_uri("http://example.org/path1/path2/?q=query#fragment", "1111...444444444446666666666666.7777777.88888888"); check_parse_uri("file:///usr/share/doc/coreutils/README", "1111...6666666666666666666666666666666"); check_parse_uri("//example.com:80/#h1", "..44444444444.556.88"); check_parse_uri("/just/path", "6666666666"); check_parse_uri("http://example.org/?q=spaces in query,errors in %encodings, unicode%u8888#1", "1111...444444444446.77777777777777777777777777777777777777777777777777777.8"); check_parse_uri("relative/path", "6666666666666"); check_parse_uri("../another/relative%path", "666666666666666666666666"); } static void check_path_merge(const char *base, const char *rel, const char *sample) { gchar *merged = uri_parser_merge_uris(base, rel); printf("merging %s\nwith %s\nresult %s\n", base, rel, merged); printf("expecting %s\n\n", sample); assert(strcmp(merged, sample) == 0); g_free(merged); } static void test_path_merging(void) { check_path_merge("http://example.com/path/qw", "asdf", "http://example.com/path/asdf"); // test cases from from RFC 3986 const char *base = "http://a/b/c/d;p?q"; // 5.4.1. Normal Examples check_path_merge(base, "g:h", "g:h"); check_path_merge(base, "g", "http://a/b/c/g"); check_path_merge(base, "./g", "http://a/b/c/g"); check_path_merge(base, "g/", "http://a/b/c/g/"); check_path_merge(base, "/g", "http://a/g"); check_path_merge(base, "//g", "http://g"); check_path_merge(base, "?y", "http://a/b/c/d;p?y"); check_path_merge(base, "g?y", "http://a/b/c/g?y"); check_path_merge(base, "#s", "http://a/b/c/d;p?q#s"); check_path_merge(base, "g#s", "http://a/b/c/g#s"); check_path_merge(base, "g?y#s", "http://a/b/c/g?y#s"); check_path_merge(base, ";x", "http://a/b/c/;x"); check_path_merge(base, "g;x", "http://a/b/c/g;x"); check_path_merge(base, "g;x?y#s", "http://a/b/c/g;x?y#s"); check_path_merge(base, "", "http://a/b/c/d;p?q"); check_path_merge(base, ".", "http://a/b/c/"); check_path_merge(base, "./", "http://a/b/c/"); check_path_merge(base, "..", "http://a/b/"); check_path_merge(base, "../", "http://a/b/"); check_path_merge(base, "../g", "http://a/b/g"); check_path_merge(base, "../..", "http://a/"); check_path_merge(base, "../../", "http://a/"); check_path_merge(base, "../../g", "http://a/g"); // 5.4.2. Abnormal Examples check_path_merge(base, "../../../g", "http://a/g"); check_path_merge(base, "../../../../g", "http://a/g"); check_path_merge(base, "/./g", "http://a/g"); check_path_merge(base, "/../g", "http://a/g"); check_path_merge(base, "g.", "http://a/b/c/g."); check_path_merge(base, ".g", "http://a/b/c/.g"); check_path_merge(base, "g..", "http://a/b/c/g.."); check_path_merge(base, "..g", "http://a/b/c/..g"); check_path_merge(base, "./../g", "http://a/b/g"); check_path_merge(base, "./g/.", "http://a/b/c/g/"); check_path_merge(base, "g/./h", "http://a/b/c/g/h"); check_path_merge(base, "g/../h", "http://a/b/c/h"); check_path_merge(base, "g;x=1/./y", "http://a/b/c/g;x=1/y"); check_path_merge(base, "g;x=1/../y", "http://a/b/c/y"); check_path_merge(base, "g?y/./x", "http://a/b/c/g?y/./x"); check_path_merge(base, "g?y/../x", "http://a/b/c/g?y/../x"); check_path_merge(base, "g#s/./x", "http://a/b/c/g#s/./x"); check_path_merge(base, "g#s/../x", "http://a/b/c/g#s/../x"); check_path_merge(base, "g../e", "http://a/b/c/g../e"); } int main(void) { test_parser(); test_path_merging(); printf("pass\n"); return 0; } freshplayerplugin-0.3.9/tests/util_egl_pixmap.c000066400000000000000000000053601321746453100217700ustar00rootroot00000000000000#include #include #include #include #include #include Window wnd; Window root_wnd; Display *dpy; Pixmap pixmap; EGLDisplay egl_dpy; EGLContext glc; EGLSurface egl_surf; void handle_graphics_expose(XEvent *ev) { EGLBoolean ret; ret = eglMakeCurrent(egl_dpy, egl_surf, egl_surf, glc); if (!ret) { printf("eglMakeCurrent failed\n"); exit(1); } printf("eglMakeCurrent ok\n"); glClearColor(1, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); glClearColor(0, 1, 0, 1); glClear(GL_COLOR_BUFFER_BIT); glFinish(); eglWaitGL(); XCopyArea(dpy, pixmap, wnd, DefaultGC(dpy, 0), 0, 0, 400, 300, 10, 10); XSync(dpy, False); } int main(void) { dpy = XOpenDisplay(NULL); root_wnd = DefaultRootWindow(dpy); wnd = XCreateSimpleWindow(dpy, root_wnd, 0, 0, 400+20, 300+20, 0, 0, 0xa0a0f0); printf("root_wnd = %p\n", (void *)root_wnd); XSelectInput(dpy, wnd, ExposureMask); XMapWindow(dpy, wnd); XSync(dpy, False); printf("wnd = %p\n", (void *)wnd); egl_dpy = eglGetDisplay(dpy); eglInitialize(egl_dpy, NULL, NULL); int nconfigs = -1; EGLConfig egl_config; EGLint cfg_attrs[] = { EGL_ALPHA_SIZE, 0, EGL_BLUE_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_RED_SIZE, 8, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_SURFACE_TYPE, EGL_PIXMAP_BIT, EGL_NONE }; eglChooseConfig(egl_dpy, cfg_attrs, &egl_config, 1, &nconfigs); printf("nconfigs = %d\n", nconfigs); printf("egl_config = %p\n", egl_config); EGLint ctx_attrs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; glc = eglCreateContext(egl_dpy, egl_config, EGL_NO_CONTEXT, ctx_attrs); if (glc == EGL_NO_CONTEXT) { printf("eglCreateContext returned EGL_NO_CONTEXT\n"); exit(1); } printf("context ok\n"); pixmap = XCreatePixmap(dpy, wnd, 400, 300, DefaultDepth(dpy, 0)); egl_surf = eglCreatePixmapSurface(egl_dpy, egl_config, pixmap, NULL); if (egl_surf == EGL_NO_SURFACE) { printf("eglCreatePixmapSurface returned EGL_NO_SURFACE\n"); exit(1); } printf("pixmap and surface ok\n"); // message loop while (1) { XEvent ev; XNextEvent(dpy, &ev); switch (ev.type) { case GraphicsExpose: case Expose: handle_graphics_expose(&ev); break; default: // do nothing break; } } eglTerminate(egl_dpy); XFreePixmap(dpy, pixmap); XDestroyWindow(dpy, wnd); XCloseDisplay(dpy); return 0; } freshplayerplugin-0.3.9/tests/util_glx_pixmap.c000066400000000000000000000054321321746453100220130ustar00rootroot00000000000000#undef NDEBUG #include #include #include #include #include #include Window wnd; Window root_wnd; Display *dpy; Pixmap pixmap; GLXContext glc; GLXPixmap glx_pixmap; PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB; void handle_graphics_expose(XEvent *ev) { int ret = glXMakeCurrent(dpy, glx_pixmap, glc); assert(ret); printf("glXMakeCurrent ok\n"); glClearColor(1, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); glClearColor(0, 1, 0, 1); glClear(GL_COLOR_BUFFER_BIT); glFinish(); XCopyArea(dpy, pixmap, wnd, DefaultGC(dpy, 0), 0, 0, 400, 300, 10, 10); XSync(dpy, False); } int main(void) { dpy = XOpenDisplay(NULL); root_wnd = DefaultRootWindow(dpy); wnd = XCreateSimpleWindow(dpy, root_wnd, 0, 0, 400+20, 300+20, 0, 0, 0xa0a0f0); glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC) glXGetProcAddressARB((const GLubyte *)"glXCreateContextAttribsARB"); printf("root_wnd = %p\n", (void *)root_wnd); XSelectInput(dpy, wnd, ExposureMask); XMapWindow(dpy, wnd); XSync(dpy, False); printf("wnd = %p\n", (void *)wnd); int nconfigs = -1; GLXFBConfig fb_config; int cfg_attrs[] = { GLX_ALPHA_SIZE, 0, GLX_BLUE_SIZE, 8, GLX_GREEN_SIZE, 8, GLX_RED_SIZE, 8, GLX_X_RENDERABLE, True, GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT | GLX_PIXMAP_BIT, None }; GLXFBConfig *fb_cfgs = glXChooseFBConfig(dpy, 0, cfg_attrs, &nconfigs); fb_config = fb_cfgs[0]; XFree(fb_cfgs); printf("nconfigs = %d\n", nconfigs); printf("fb_config = %p\n", fb_config); const int ctx_attrs[] = { GLX_RENDER_TYPE, GLX_RGBA_TYPE, GLX_CONTEXT_MAJOR_VERSION_ARB, 2, GLX_CONTEXT_MINOR_VERSION_ARB, 0, GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_ES2_PROFILE_BIT_EXT, None, }; glc = glXCreateContextAttribsARB(dpy, fb_config, NULL, True, ctx_attrs); assert(glc); printf("context ok\n"); pixmap = XCreatePixmap(dpy, wnd, 400, 300, DefaultDepth(dpy, 0)); glx_pixmap = glXCreatePixmap(dpy, fb_config, pixmap, NULL); assert(glx_pixmap); printf("pixmap and surface ok\n"); // message loop while (1) { XEvent ev; XNextEvent(dpy, &ev); switch (ev.type) { case GraphicsExpose: case Expose: handle_graphics_expose(&ev); break; default: // do nothing break; } } glXDestroyPixmap(dpy, glx_pixmap); XFreePixmap(dpy, pixmap); XDestroyWindow(dpy, wnd); XCloseDisplay(dpy); return 0; } freshplayerplugin-0.3.9/tools/000077500000000000000000000000001321746453100164345ustar00rootroot00000000000000freshplayerplugin-0.3.9/tools/encodings/000077500000000000000000000000001321746453100204055ustar00rootroot00000000000000freshplayerplugin-0.3.9/tools/encodings/encodings.json000066400000000000000000000207271321746453100232610ustar00rootroot00000000000000[ { "encodings": [ { "labels": [ "unicode-1-1-utf-8", "utf-8", "utf8" ], "name": "UTF-8" } ], "heading": "The Encoding" }, { "encodings": [ { "labels": [ "866", "cp866", "csibm866", "ibm866" ], "name": "IBM866" }, { "labels": [ "csisolatin2", "iso-8859-2", "iso-ir-101", "iso8859-2", "iso88592", "iso_8859-2", "iso_8859-2:1987", "l2", "latin2" ], "name": "ISO-8859-2" }, { "labels": [ "csisolatin3", "iso-8859-3", "iso-ir-109", "iso8859-3", "iso88593", "iso_8859-3", "iso_8859-3:1988", "l3", "latin3" ], "name": "ISO-8859-3" }, { "labels": [ "csisolatin4", "iso-8859-4", "iso-ir-110", "iso8859-4", "iso88594", "iso_8859-4", "iso_8859-4:1988", "l4", "latin4" ], "name": "ISO-8859-4" }, { "labels": [ "csisolatincyrillic", "cyrillic", "iso-8859-5", "iso-ir-144", "iso8859-5", "iso88595", "iso_8859-5", "iso_8859-5:1988" ], "name": "ISO-8859-5" }, { "labels": [ "arabic", "asmo-708", "csiso88596e", "csiso88596i", "csisolatinarabic", "ecma-114", "iso-8859-6", "iso-8859-6-e", "iso-8859-6-i", "iso-ir-127", "iso8859-6", "iso88596", "iso_8859-6", "iso_8859-6:1987" ], "name": "ISO-8859-6" }, { "labels": [ "csisolatingreek", "ecma-118", "elot_928", "greek", "greek8", "iso-8859-7", "iso-ir-126", "iso8859-7", "iso88597", "iso_8859-7", "iso_8859-7:1987", "sun_eu_greek" ], "name": "ISO-8859-7" }, { "labels": [ "csiso88598e", "csisolatinhebrew", "hebrew", "iso-8859-8", "iso-8859-8-e", "iso-ir-138", "iso8859-8", "iso88598", "iso_8859-8", "iso_8859-8:1988", "visual" ], "name": "ISO-8859-8" }, { "labels": [ "csiso88598i", "iso-8859-8-i", "logical" ], "name": "ISO-8859-8-I" }, { "labels": [ "csisolatin6", "iso-8859-10", "iso-ir-157", "iso8859-10", "iso885910", "l6", "latin6" ], "name": "ISO-8859-10" }, { "labels": [ "iso-8859-13", "iso8859-13", "iso885913" ], "name": "ISO-8859-13" }, { "labels": [ "iso-8859-14", "iso8859-14", "iso885914" ], "name": "ISO-8859-14" }, { "labels": [ "csisolatin9", "iso-8859-15", "iso8859-15", "iso885915", "iso_8859-15", "l9" ], "name": "ISO-8859-15" }, { "labels": [ "iso-8859-16" ], "name": "ISO-8859-16" }, { "labels": [ "cskoi8r", "koi", "koi8", "koi8-r", "koi8_r" ], "name": "KOI8-R" }, { "labels": [ "koi8-ru", "koi8-u" ], "name": "KOI8-U" }, { "labels": [ "csmacintosh", "mac", "macintosh", "x-mac-roman" ], "name": "macintosh" }, { "labels": [ "dos-874", "iso-8859-11", "iso8859-11", "iso885911", "tis-620", "windows-874" ], "name": "windows-874" }, { "labels": [ "cp1250", "windows-1250", "x-cp1250" ], "name": "windows-1250" }, { "labels": [ "cp1251", "windows-1251", "x-cp1251" ], "name": "windows-1251" }, { "labels": [ "ansi_x3.4-1968", "ascii", "cp1252", "cp819", "csisolatin1", "ibm819", "iso-8859-1", "iso-ir-100", "iso8859-1", "iso88591", "iso_8859-1", "iso_8859-1:1987", "l1", "latin1", "us-ascii", "windows-1252", "x-cp1252" ], "name": "windows-1252" }, { "labels": [ "cp1253", "windows-1253", "x-cp1253" ], "name": "windows-1253" }, { "labels": [ "cp1254", "csisolatin5", "iso-8859-9", "iso-ir-148", "iso8859-9", "iso88599", "iso_8859-9", "iso_8859-9:1989", "l5", "latin5", "windows-1254", "x-cp1254" ], "name": "windows-1254" }, { "labels": [ "cp1255", "windows-1255", "x-cp1255" ], "name": "windows-1255" }, { "labels": [ "cp1256", "windows-1256", "x-cp1256" ], "name": "windows-1256" }, { "labels": [ "cp1257", "windows-1257", "x-cp1257" ], "name": "windows-1257" }, { "labels": [ "cp1258", "windows-1258", "x-cp1258" ], "name": "windows-1258" }, { "labels": [ "x-mac-cyrillic", "x-mac-ukrainian" ], "name": "x-mac-cyrillic" } ], "heading": "Legacy single-byte encodings" }, { "encodings": [ { "labels": [ "chinese", "csgb2312", "csiso58gb231280", "gb2312", "gb_2312", "gb_2312-80", "gbk", "iso-ir-58", "x-gbk" ], "name": "GBK" }, { "labels": [ "gb18030" ], "name": "gb18030" } ], "heading": "Legacy multi-byte Chinese (simplified) encodings" }, { "encodings": [ { "labels": [ "big5", "big5-hkscs", "cn-big5", "csbig5", "x-x-big5" ], "name": "Big5" } ], "heading": "Legacy multi-byte Chinese (traditional) encodings" }, { "encodings": [ { "labels": [ "cseucpkdfmtjapanese", "euc-jp", "x-euc-jp" ], "name": "EUC-JP" }, { "labels": [ "csiso2022jp", "iso-2022-jp" ], "name": "ISO-2022-JP" }, { "labels": [ "csshiftjis", "ms932", "ms_kanji", "shift-jis", "shift_jis", "sjis", "windows-31j", "x-sjis" ], "name": "Shift_JIS" } ], "heading": "Legacy multi-byte Japanese encodings" }, { "encodings": [ { "labels": [ "cseuckr", "csksc56011987", "euc-kr", "iso-ir-149", "korean", "ks_c_5601-1987", "ks_c_5601-1989", "ksc5601", "ksc_5601", "windows-949" ], "name": "EUC-KR" } ], "heading": "Legacy multi-byte Korean encodings" }, { "encodings": [ { "labels": [ "csiso2022kr", "hz-gb-2312", "iso-2022-cn", "iso-2022-cn-ext", "iso-2022-kr" ], "name": "replacement" }, { "labels": [ "utf-16be" ], "name": "UTF-16BE" }, { "labels": [ "utf-16", "utf-16le" ], "name": "UTF-16LE" }, { "labels": [ "x-user-defined" ], "name": "x-user-defined" } ], "heading": "Legacy miscellaneous encodings" } ] freshplayerplugin-0.3.9/tools/encodings/gen-encoding-aliases.py000066400000000000000000000010041321746453100247260ustar00rootroot00000000000000import json # https://raw.githubusercontent.com/whatwg/encoding/master/encodings.json with open("encodings.json") as f: s = json.loads(f.read()) print "// autogenerated by /tools/encodings/gen-encoding-aliases.py\n" for gr in s: print "// {}".format((gr["heading"])) for dst in gr["encodings"]: dst_enc = dst["name"] print '{{ "{}", "{}" }},'.format(dst_enc, dst_enc) for src_enc in dst["labels"]: print '{{ "{}", "{}" }},'.format(dst_enc, src_enc) print "" freshplayerplugin-0.3.9/tools/stub_helper.py000066400000000000000000000126561321746453100213340ustar00rootroot00000000000000from __future__ import print_function import sys import glob from pycparser import c_parser, c_ast, parse_file, c_generator c_gen = c_generator.CGenerator() def lowcase_name(iname, fname): s = list(iname.replace("PPB_", "ppb") + fname) s2 = [] for b in s: if b.isupper(): s2.append('_') s2.append(b.lower()) else: s2.append(b) return "".join(s2).replace("__", "_") def gen_impl_functions(ast, gen_prototypes_only=False): class MyVisitor(c_ast.NodeVisitor): def visit_Struct(self, node): if node.name is not None and node.name.startswith("PPB_") and node.decls is not None: for a in node.decls: a_func = a.children()[0][1].children()[0][1].children() a_func_args = a_func[0][1] a_func_rettype = a_func[1][1] fname = "unknown" if isinstance(a_func_rettype, c_ast.TypeDecl): fname = a_func_rettype.declname a_func_rettype.declname = "" print(c_gen.visit(c_ast.Typedef("dummy", [], [], a_func_rettype))) a_func_rettype.declname = fname elif isinstance(a_func_rettype, c_ast.PtrDecl): a_func_rettype = a_func_rettype.children()[0][1] fname = a_func_rettype.declname a_func_rettype.declname = "" print (c_gen.visit(c_ast.Typedef("dummy", [], [], a_func_rettype)) + " *") a_func_rettype.declname = fname arg_names = (list(c[1].name for c in a_func_args.children() if c[1].name is not None)) print(lowcase_name(node.name, fname) + "(" + c_gen.visit(a_func_args) + ")", end="") if gen_prototypes_only: print(";") else: print("") print("{") print("}") print("") v = MyVisitor() v.visit(ast) def gen_trace_functions(ast): class MyVisitor(c_ast.NodeVisitor): def visit_Struct(self, node): if node.name is not None and node.name.startswith("PPB_") and node.decls is not None: for a in node.decls: a_func = a.children()[0][1].children()[0][1].children() a_func_args = a_func[0][1] a_func_rettype = a_func[1][1] print("TRACE_WRAPPER") fname = "unknown" if isinstance(a_func_rettype, c_ast.TypeDecl): fname = a_func_rettype.declname a_func_rettype.declname = "" print(c_gen.visit(c_ast.Typedef("dummy", [], [], a_func_rettype))) a_func_rettype.declname = fname elif isinstance(a_func_rettype, c_ast.PtrDecl): a_func_rettype = a_func_rettype.children()[0][1] fname = a_func_rettype.declname a_func_rettype.declname = "" print (c_gen.visit(c_ast.Typedef("dummy", [], [], a_func_rettype)) + " *") a_func_rettype.declname = fname arg_names = (list(c[1].name for c in a_func_args.children() if c[1].name is not None)) print("trace_" + lowcase_name(node.name, fname) + "(" + c_gen.visit(a_func_args) + ")") print("{") print(' trace_info("[PPB] {zilch} %s\\n", __func__+6);') print(" return " + lowcase_name(node.name, fname) + "(" + ", ".join(arg_names) + ");") print("}") print("") v = MyVisitor() v.visit(ast) def gen_structs(ast): class MyVisitor(c_ast.NodeVisitor): def visit_Struct(self, node): if node.name is not None and (node.name.startswith("PPB_") or node.name.startswith("PPP_")) and node.decls is not None: print("const struct " + node.name + " " + lowcase_name(node.name, "") + " = {") for a in node.decls: a_func = a.children()[0][1].children()[0][1].children() a_func_args = a_func[0][1] a_func_rettype = a_func[1][1] fname = "unknown" if isinstance(a_func_rettype, c_ast.TypeDecl): fname = a_func_rettype.declname elif isinstance(a_func_rettype, c_ast.PtrDecl): a_func_rettype = a_func_rettype.children()[0][1] fname = a_func_rettype.declname print(" ." + fname + " = TWRAPZ(" + lowcase_name(node.name, fname) + "),") print("};") v = MyVisitor() v.visit(ast) prep_file = sys.argv[1] ast = parse_file(prep_file, use_cpp=False) guardian_name = "FPP_" + prep_file.replace(".prep", "").upper().replace(".", "_") print("#ifndef " + guardian_name) print("#define " + guardian_name) print("") print("// includes here") print("") print("") gen_impl_functions(ast, True) print("#endif // " + guardian_name) print("") print("#include \"" +prep_file.replace(".prep", "") + "\"") print("#include ") print("#include \"trace.h\"") print("") print("") gen_impl_functions(ast) print("\n// trace wrappers") gen_trace_functions(ast) gen_structs(ast)